[compiler-rt] Pass the linker version to libfuzzer tests on darwin (PR #87719)

Usama Hameed via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 4 15:01:03 PDT 2024


https://github.com/usama54321 created https://github.com/llvm/llvm-project/pull/87719

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

>From e9a6b273846ea4b6e63a8ccc791900990ac1f926 Mon Sep 17 00:00:00 2001
From: usama <u_hameed at apple.com>
Date: Thu, 4 Apr 2024 14:59:07 -0700
Subject: [PATCH] Pass the linker version to libfuzzer tests on darwin

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
---
 compiler-rt/test/fuzzer/lit.cfg.py | 3 +++
 1 file changed, 3 insertions(+)

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,



More information about the llvm-commits mailing list