|
| 1 | +// UNSUPPORTED: system-windows |
| 2 | + |
| 3 | +// Tests to check that we link against the toolchain-provided libc++ built library when it is provided. |
| 4 | +// This is required to prefer the toolchain's libc++ over the system's libc++, which matches the behavior |
| 5 | +// we have for header search paths. |
| 6 | + |
| 7 | +// When libc++.dylib is NOT in the toolchain, we should use -lc++ and fall back to the libc++ |
| 8 | +// in the sysroot. |
| 9 | +// |
| 10 | +// (1) Without -fexperimental-library. |
| 11 | +// RUN: %clangxx -### %s 2>&1 \ |
| 12 | +// RUN: --target=x86_64-apple-darwin \ |
| 13 | +// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ |
| 14 | +// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \ |
| 15 | +// RUN: --check-prefix=CHECK-1 %s |
| 16 | +// CHECK-1: "/usr/bin/ld" |
| 17 | +// CHECK-1: "-lc++" |
| 18 | +// CHECK-1-NOT: "[[TOOLCHAIN]]/usr/lib" |
| 19 | +// |
| 20 | +// (2) With -fexperimental-library. |
| 21 | +// RUN: %clangxx -### %s 2>&1 \ |
| 22 | +// RUN: --target=x86_64-apple-darwin \ |
| 23 | +// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ |
| 24 | +// RUN: -fexperimental-library \ |
| 25 | +// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \ |
| 26 | +// RUN: --check-prefix=CHECK-2 %s |
| 27 | +// CHECK-2: "/usr/bin/ld" |
| 28 | +// CHECK-2: "-lc++" "-lc++experimental" |
| 29 | +// CHECK-2-NOT: "[[TOOLCHAIN]]/usr/lib" |
| 30 | + |
| 31 | +// When we have libc++.dylib in the toolchain, it should be used over the one in the sysroot. |
| 32 | +// There are a few cases worth testing. |
| 33 | +// |
| 34 | +// (1) Without -fexperimental-library. |
| 35 | +// RUN: %clangxx -### %s 2>&1 \ |
| 36 | +// RUN: --target=x86_64-apple-darwin \ |
| 37 | +// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 38 | +// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 39 | +// RUN: --check-prefix=CHECK-3 %s |
| 40 | +// CHECK-3: "/usr/bin/ld" |
| 41 | +// CHECK-3: "[[TOOLCHAIN]]/usr/lib/libc++.dylib" |
| 42 | +// CHECK-3-NOT: "-lc++" |
| 43 | +// |
| 44 | +// (2) With -fexperimental-library. |
| 45 | +// RUN: %clangxx -### %s 2>&1 \ |
| 46 | +// RUN: --target=x86_64-apple-darwin \ |
| 47 | +// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 48 | +// RUN: -fexperimental-library \ |
| 49 | +// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 50 | +// RUN: --check-prefix=CHECK-4 %s |
| 51 | +// CHECK-4: "/usr/bin/ld" |
| 52 | +// CHECK-4: "[[TOOLCHAIN]]/usr/lib/libc++.dylib" |
| 53 | +// CHECK-4: "[[TOOLCHAIN]]/usr/lib/libc++experimental.a" |
| 54 | +// CHECK-4-NOT: "-lc++" |
| 55 | +// CHECK-4-NOT: "-lc++experimental" |
| 56 | + |
| 57 | +// When we have libc++.a in the toolchain instead of libc++.dylib, it should be |
| 58 | +// used over the one in the sysroot. |
| 59 | +// |
| 60 | +// (1) Without -fexperimental-library. |
| 61 | +// RUN: %clangxx -### %s 2>&1 \ |
| 62 | +// RUN: --target=x86_64-apple-darwin \ |
| 63 | +// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_static/usr/bin \ |
| 64 | +// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_static \ |
| 65 | +// RUN: --check-prefix=CHECK-5 %s |
| 66 | +// CHECK-5: "/usr/bin/ld" |
| 67 | +// CHECK-5: "[[TOOLCHAIN]]/usr/lib/libc++.a" |
| 68 | +// CHECK-5-NOT: "-lc++" |
| 69 | +// |
| 70 | +// (2) With -fexperimental-library. |
| 71 | +// RUN: %clangxx -### %s 2>&1 \ |
| 72 | +// RUN: --target=x86_64-apple-darwin \ |
| 73 | +// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_static/usr/bin \ |
| 74 | +// RUN: -fexperimental-library \ |
| 75 | +// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_static \ |
| 76 | +// RUN: --check-prefix=CHECK-6 %s |
| 77 | +// CHECK-6: "/usr/bin/ld" |
| 78 | +// CHECK-6: "[[TOOLCHAIN]]/usr/lib/libc++.a" |
| 79 | +// CHECK-6: "[[TOOLCHAIN]]/usr/lib/libc++experimental.a" |
| 80 | +// CHECK-6-NOT: "-lc++" |
| 81 | +// CHECK-6-NOT: "-lc++experimental" |
0 commit comments