Skip to content

Conversation

@ldionne
Copy link
Member

@ldionne ldionne commented Dec 5, 2025

Specify the path to the linker explicitly so that we can run the test on all platforms regardless of what linker is being used.

Specify the path to the linker explicitly so that we can run the
test on all platforms regardless of what linker is being used.
@ldionne ldionne requested a review from Kewen12 December 5, 2025 21:29
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Dec 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 5, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Louis Dionne (ldionne)

Changes

Specify the path to the linker explicitly so that we can run the test on all platforms regardless of what linker is being used.


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

1 Files Affected:

  • (modified) clang/test/Driver/darwin-link-libcxx.cpp (+20-9)
diff --git a/clang/test/Driver/darwin-link-libcxx.cpp b/clang/test/Driver/darwin-link-libcxx.cpp
index fca1e3c6f3d6f..fee48f43fb14b 100644
--- a/clang/test/Driver/darwin-link-libcxx.cpp
+++ b/clang/test/Driver/darwin-link-libcxx.cpp
@@ -1,11 +1,10 @@
 // UNSUPPORTED: system-windows
 
-// TODO: Make this test portable across platforms
-// REQUIRES: system-darwin
-
 // Tests to check that we link against the toolchain-provided libc++ built library when it is provided.
 // This is required to prefer the toolchain's libc++ over the system's libc++, which matches the behavior
 // we have for header search paths.
+//
+// Note that we explicitly specify the linker path to use to make this test portable across platforms.
 
 // When libc++.dylib is NOT in the toolchain, we should use -lc++ and fall back to the libc++
 // in the sysroot.
@@ -13,21 +12,25 @@
 // (1) Without -fexperimental-library.
 // RUN: %clangxx -### %s 2>&1                                                   \
 // RUN:     --target=x86_64-apple-darwin                                        \
+// RUN:     --ld-path=%S/Inputs/lld/ld.lld                                      \
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx    \
+// RUN:               -DINPUTS=%S/Inputs                                        \
 // RUN:               --check-prefix=CHECK-1 %s
-// CHECK-1: "/usr/bin/ld"
+// CHECK-1: "[[INPUTS]]/lld/ld.lld"
 // CHECK-1: "-lc++"
 // CHECK-1-NOT: "[[TOOLCHAIN]]/usr/lib"
 //
 // (2) With -fexperimental-library.
 // RUN: %clangxx -### %s 2>&1                                                   \
 // RUN:     --target=x86_64-apple-darwin                                        \
+// RUN:     --ld-path=%S/Inputs/lld/ld.lld                                      \
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN:     -fexperimental-library                                              \
 // RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx    \
+// RUN:               -DINPUTS=%S/Inputs                                        \
 // RUN:               --check-prefix=CHECK-2 %s
-// CHECK-2: "/usr/bin/ld"
+// CHECK-2: "[[INPUTS]]/lld/ld.lld"
 // CHECK-2: "-lc++" "-lc++experimental"
 // CHECK-2-NOT: "[[TOOLCHAIN]]/usr/lib"
 
@@ -37,21 +40,25 @@
 // (1) Without -fexperimental-library.
 // RUN: %clangxx -### %s 2>&1                                                   \
 // RUN:     --target=x86_64-apple-darwin                                        \
+// RUN:     --ld-path=%S/Inputs/lld/ld.lld                                      \
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin           \
 // RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain              \
+// RUN:               -DINPUTS=%S/Inputs                                        \
 // RUN:               --check-prefix=CHECK-3 %s
-// CHECK-3: "/usr/bin/ld"
+// CHECK-3: "[[INPUTS]]/lld/ld.lld"
 // CHECK-3: "[[TOOLCHAIN]]/usr/lib/libc++.dylib"
 // CHECK-3-NOT: "-lc++"
 //
 // (2) With -fexperimental-library.
 // RUN: %clangxx -### %s 2>&1                                                   \
 // RUN:     --target=x86_64-apple-darwin                                        \
+// RUN:     --ld-path=%S/Inputs/lld/ld.lld                                      \
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin           \
 // RUN:     -fexperimental-library                                              \
 // RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain              \
+// RUN:               -DINPUTS=%S/Inputs                                        \
 // RUN:               --check-prefix=CHECK-4 %s
-// CHECK-4: "/usr/bin/ld"
+// CHECK-4: "[[INPUTS]]/lld/ld.lld"
 // CHECK-4: "[[TOOLCHAIN]]/usr/lib/libc++.dylib"
 // CHECK-4: "[[TOOLCHAIN]]/usr/lib/libc++experimental.a"
 // CHECK-4-NOT: "-lc++"
@@ -63,21 +70,25 @@
 // (1) Without -fexperimental-library.
 // RUN: %clangxx -### %s 2>&1                                                   \
 // RUN:     --target=x86_64-apple-darwin                                        \
+// RUN:     --ld-path=%S/Inputs/lld/ld.lld                                      \
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain_static/usr/bin    \
 // RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_static       \
+// RUN:               -DINPUTS=%S/Inputs                                        \
 // RUN:               --check-prefix=CHECK-5 %s
-// CHECK-5: "/usr/bin/ld"
+// CHECK-5: "[[INPUTS]]/lld/ld.lld"
 // CHECK-5: "[[TOOLCHAIN]]/usr/lib/libc++.a"
 // CHECK-5-NOT: "-lc++"
 //
 // (2) With -fexperimental-library.
 // RUN: %clangxx -### %s 2>&1                                                   \
 // RUN:     --target=x86_64-apple-darwin                                        \
+// RUN:     --ld-path=%S/Inputs/lld/ld.lld                                      \
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain_static/usr/bin    \
 // RUN:     -fexperimental-library                                              \
 // RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_static       \
+// RUN:               -DINPUTS=%S/Inputs                                        \
 // RUN:               --check-prefix=CHECK-6 %s
-// CHECK-6: "/usr/bin/ld"
+// CHECK-6: "[[INPUTS]]/lld/ld.lld"
 // CHECK-6: "[[TOOLCHAIN]]/usr/lib/libc++.a"
 // CHECK-6: "[[TOOLCHAIN]]/usr/lib/libc++experimental.a"
 // CHECK-6-NOT: "-lc++"

@ldionne ldionne closed this Dec 5, 2025
@ldionne ldionne deleted the review/make-clang-test-more-portable branch December 5, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants