Skip to content

Commit 0d83ff7

Browse files
committed
[clang] Make test for linking libc++ on Darwin more portable
Specify the path to the linker explicitly so that we can run the test on all platforms regardless of what linker is being used.
1 parent bad1a88 commit 0d83ff7

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

clang/test/Driver/darwin-link-libcxx.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
// UNSUPPORTED: system-windows
22

3-
// TODO: Make this test portable across platforms
4-
// REQUIRES: system-darwin
5-
63
// Tests to check that we link against the toolchain-provided libc++ built library when it is provided.
74
// This is required to prefer the toolchain's libc++ over the system's libc++, which matches the behavior
85
// we have for header search paths.
6+
//
7+
// Note that we explicitly specify the linker path to use to make this test portable across platforms.
98

109
// When libc++.dylib is NOT in the toolchain, we should use -lc++ and fall back to the libc++
1110
// in the sysroot.
1211
//
1312
// (1) Without -fexperimental-library.
1413
// RUN: %clangxx -### %s 2>&1 \
1514
// RUN: --target=x86_64-apple-darwin \
15+
// RUN: --ld-path=%S/Inputs/lld/ld.lld \
1616
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
1717
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \
18+
// RUN: -DINPUTS=%S/Inputs \
1819
// RUN: --check-prefix=CHECK-1 %s
19-
// CHECK-1: "/usr/bin/ld"
20+
// CHECK-1: "[[INPUTS]]/lld/ld.lld"
2021
// CHECK-1: "-lc++"
2122
// CHECK-1-NOT: "[[TOOLCHAIN]]/usr/lib"
2223
//
2324
// (2) With -fexperimental-library.
2425
// RUN: %clangxx -### %s 2>&1 \
2526
// RUN: --target=x86_64-apple-darwin \
27+
// RUN: --ld-path=%S/Inputs/lld/ld.lld \
2628
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
2729
// RUN: -fexperimental-library \
2830
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \
31+
// RUN: -DINPUTS=%S/Inputs \
2932
// RUN: --check-prefix=CHECK-2 %s
30-
// CHECK-2: "/usr/bin/ld"
33+
// CHECK-2: "[[INPUTS]]/lld/ld.lld"
3134
// CHECK-2: "-lc++" "-lc++experimental"
3235
// CHECK-2-NOT: "[[TOOLCHAIN]]/usr/lib"
3336

@@ -37,21 +40,25 @@
3740
// (1) Without -fexperimental-library.
3841
// RUN: %clangxx -### %s 2>&1 \
3942
// RUN: --target=x86_64-apple-darwin \
43+
// RUN: --ld-path=%S/Inputs/lld/ld.lld \
4044
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
4145
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
46+
// RUN: -DINPUTS=%S/Inputs \
4247
// RUN: --check-prefix=CHECK-3 %s
43-
// CHECK-3: "/usr/bin/ld"
48+
// CHECK-3: "[[INPUTS]]/lld/ld.lld"
4449
// CHECK-3: "[[TOOLCHAIN]]/usr/lib/libc++.dylib"
4550
// CHECK-3-NOT: "-lc++"
4651
//
4752
// (2) With -fexperimental-library.
4853
// RUN: %clangxx -### %s 2>&1 \
4954
// RUN: --target=x86_64-apple-darwin \
55+
// RUN: --ld-path=%S/Inputs/lld/ld.lld \
5056
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
5157
// RUN: -fexperimental-library \
5258
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
59+
// RUN: -DINPUTS=%S/Inputs \
5360
// RUN: --check-prefix=CHECK-4 %s
54-
// CHECK-4: "/usr/bin/ld"
61+
// CHECK-4: "[[INPUTS]]/lld/ld.lld"
5562
// CHECK-4: "[[TOOLCHAIN]]/usr/lib/libc++.dylib"
5663
// CHECK-4: "[[TOOLCHAIN]]/usr/lib/libc++experimental.a"
5764
// CHECK-4-NOT: "-lc++"
@@ -63,21 +70,25 @@
6370
// (1) Without -fexperimental-library.
6471
// RUN: %clangxx -### %s 2>&1 \
6572
// RUN: --target=x86_64-apple-darwin \
73+
// RUN: --ld-path=%S/Inputs/lld/ld.lld \
6674
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_static/usr/bin \
6775
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_static \
76+
// RUN: -DINPUTS=%S/Inputs \
6877
// RUN: --check-prefix=CHECK-5 %s
69-
// CHECK-5: "/usr/bin/ld"
78+
// CHECK-5: "[[INPUTS]]/lld/ld.lld"
7079
// CHECK-5: "[[TOOLCHAIN]]/usr/lib/libc++.a"
7180
// CHECK-5-NOT: "-lc++"
7281
//
7382
// (2) With -fexperimental-library.
7483
// RUN: %clangxx -### %s 2>&1 \
7584
// RUN: --target=x86_64-apple-darwin \
85+
// RUN: --ld-path=%S/Inputs/lld/ld.lld \
7686
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_static/usr/bin \
7787
// RUN: -fexperimental-library \
7888
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_static \
89+
// RUN: -DINPUTS=%S/Inputs \
7990
// RUN: --check-prefix=CHECK-6 %s
80-
// CHECK-6: "/usr/bin/ld"
91+
// CHECK-6: "[[INPUTS]]/lld/ld.lld"
8192
// CHECK-6: "[[TOOLCHAIN]]/usr/lib/libc++.a"
8293
// CHECK-6: "[[TOOLCHAIN]]/usr/lib/libc++experimental.a"
8394
// CHECK-6-NOT: "-lc++"

0 commit comments

Comments
 (0)