Skip to content

Pass the linker version to libfuzzer tests on darwin #87719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

usama54321
Copy link
Member

The HOST_LINK_VERSION is a hardcoded string in Darwin clang that detects the linker version at configure time. The driver uses this information to build the correct set of arguments for the linker. This patch detects the linker version again during compiler-rt configuration and passes it to the libfuzzer tests. This allows a clang built on a machine with a new linker to run compiler-rt tests on a machine with an old linker.

rdar://125932376

@llvmbot
Copy link
Member

llvmbot commented Apr 4, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Usama Hameed (usama54321)

Changes

The HOST_LINK_VERSION is a hardcoded string in Darwin clang that detects the linker version at configure time. The driver uses this information to build the correct set of arguments for the linker. This patch detects the linker version again during compiler-rt configuration and passes it to the libfuzzer tests. This allows a clang built on a machine with a new linker to run compiler-rt tests on a machine with an old linker.

rdar://125932376


Full diff: https://github.com/llvm/llvm-project/pull/87719.diff

1 Files Affected:

  • (modified) compiler-rt/test/fuzzer/lit.cfg.py (+3)
diff --git a/compiler-rt/test/fuzzer/lit.cfg.py b/compiler-rt/test/fuzzer/lit.cfg.py
index 4e203236b16708..9ecf162339f707 100644
--- a/compiler-rt/test/fuzzer/lit.cfg.py
+++ b/compiler-rt/test/fuzzer/lit.cfg.py
@@ -98,6 +98,9 @@ def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=False):
     if "windows" in config.available_features:
         extra_cmd = extra_cmd + " -D_DISABLE_VECTOR_ANNOTATION -D_DISABLE_STRING_ANNOTATION"
 
+    if "darwin" in config.available_features and getattr(config, "darwin_linker_version", None):
+        extra_cmd = extra_cmd + " -mlinker-version=" + config.darwin_linker_version
+
     return " ".join(
         [
             compiler_cmd,

@wrotki
Copy link
Contributor

wrotki commented Apr 4, 2024

LGTM

Copy link

github-actions bot commented Apr 4, 2024

⚠️ Python code formatter, darker found issues in your code. ⚠️

You can test this locally with the following command:
darker --check --diff -r aa6ba23235b4418d528fe8df4d1cd6d2ad50ceb2...e9a6b273846ea4b6e63a8ccc791900990ac1f926 compiler-rt/test/fuzzer/lit.cfg.py
View the diff from darker here.
--- lit.cfg.py	2024-04-04 21:59:07.000000 +0000
+++ lit.cfg.py	2024-04-04 22:03:54.966410 +0000
@@ -96,11 +96,13 @@
     # Avoids linker error:
     #   /failifmismatch: mismatch detected for 'annotate_string'
     if "windows" in config.available_features:
         extra_cmd = extra_cmd + " -D_DISABLE_VECTOR_ANNOTATION -D_DISABLE_STRING_ANNOTATION"
 
-    if "darwin" in config.available_features and getattr(config, "darwin_linker_version", None):
+    if "darwin" in config.available_features and getattr(
+        config, "darwin_linker_version", None
+    ):
         extra_cmd = extra_cmd + " -mlinker-version=" + config.darwin_linker_version
 
     return " ".join(
         [
             compiler_cmd,

The HOST_LINK_VERSION is a hardcoded string in Darwin clang that detects
the linker version at configure time. The driver uses this information
to build the correct set of arguments for the linker. This patch detects
the linker version again during compiler-rt configuration and passes it
to the libfuzzer tests. This allows a clang built on a machine with a
new linker to run compiler-rt tests on a machine with an old linker.

rdar://125932376
@usama54321 usama54321 force-pushed the darwin-linker-version-libfuzzer branch from e9a6b27 to 93c2485 Compare April 5, 2024 21:47
@usama54321 usama54321 merged commit 65e5391 into llvm:main Apr 5, 2024
usama54321 added a commit to usama54321/apple-llvm-project that referenced this pull request Apr 17, 2024
The HOST_LINK_VERSION is a hardcoded string in Darwin clang that detects
the linker version at configure time. The driver uses this information
to build the correct set of arguments for the linker. This patch detects
the linker version again during compiler-rt configuration and passes it
to the libfuzzer tests. This allows a clang built on a machine with a
new linker to run compiler-rt tests on a machine with an old linker.

rdar://125932376
usama54321 added a commit to swiftlang/llvm-project that referenced this pull request Apr 17, 2024
The HOST_LINK_VERSION is a hardcoded string in Darwin clang that detects
the linker version at configure time. The driver uses this information
to build the correct set of arguments for the linker. This patch detects
the linker version again during compiler-rt configuration and passes it
to the libfuzzer tests. This allows a clang built on a machine with a
new linker to run compiler-rt tests on a machine with an old linker.

rdar://125932376
usama54321 added a commit to usama54321/apple-llvm-project that referenced this pull request Apr 30, 2024
The HOST_LINK_VERSION is a hardcoded string in Darwin clang that detects
the linker version at configure time. The driver uses this information
to build the correct set of arguments for the linker. This patch detects
the linker version again during compiler-rt configuration and passes it
to the libfuzzer tests. This allows a clang built on a machine with a
new linker to run compiler-rt tests on a machine with an old linker.

rdar://125932376
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants