|
| 1 | +// General tests that the header search paths for libc++ detected by the driver |
| 2 | +// and passed to CC1 are correct on Darwin platforms. This test copies the clang |
| 3 | +// binary, which won't work if it uses any dynamic libraries (BUILD_SHARED_LIBS, |
| 4 | +// LLVM_LINK_LLVM_DYLIB, or CLANG_LINK_CLANG_DYLIB). |
| 5 | + |
| 6 | +// UNSUPPORTED: system-windows |
| 7 | +// REQUIRES: static-libs |
| 8 | + |
| 9 | +// ---------------------------------------------------------------------------- |
| 10 | +// On Darwin, libc++ can be installed in one of the following places: |
| 11 | +// 1. Alongside the compiler in <install>/include/c++/v1 |
| 12 | +// 2. Alongside the compiler in <clang-executable-folder>/../include/c++/v1 |
| 13 | +// 3. In a SDK (or a custom sysroot) in <sysroot>/usr/include/c++/v1 |
| 14 | + |
| 15 | +// The build folders do not have an `include/c++/v1`; create a new |
| 16 | +// local folder hierarchy that meets this requirement. |
| 17 | +// Note: this might not work with weird RPATH configurations. |
| 18 | +// RUN: rm -rf %t/install |
| 19 | +// RUN: mkdir -p %t/install/bin |
| 20 | +// RUN: cp %clang %t/install/bin/clang |
| 21 | +// RUN: mkdir -p %t/install/include/c++/v1 |
| 22 | + |
| 23 | +// Headers in (1) and in (2) -> (1) is preferred over (2) |
| 24 | +// RUN: rm -rf %t/symlinked1 |
| 25 | +// RUN: mkdir -p %t/symlinked1/bin |
| 26 | +// RUN: ln -sf %t/install/bin/clang %t/symlinked1/bin/clang |
| 27 | +// RUN: mkdir -p %t/symlinked1/include/c++/v1 |
| 28 | + |
| 29 | +// RUN: %t/symlinked1/bin/clang -### %s -no-canonical-prefixes -fsyntax-only 2>&1 \ |
| 30 | +// RUN: --target=x86_64-apple-darwin \ |
| 31 | +// RUN: -stdlib=libc++ \ |
| 32 | +// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 33 | +// RUN: | FileCheck -DSYMLINKED=%t/symlinked1 \ |
| 34 | +// RUN: -DTOOLCHAIN=%t/install \ |
| 35 | +// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 36 | +// RUN: --check-prefix=CHECK-SYMLINKED-INCLUDE-CXX-V1 %s |
| 37 | +// CHECK-SYMLINKED-INCLUDE-CXX-V1: "-internal-isystem" "[[SYMLINKED]]/bin/../include/c++/v1" |
| 38 | +// CHECK-SYMLINKED-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1" |
| 39 | +// CHECK-SYMLINKED-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |
| 40 | + |
| 41 | +// Headers in (2) and in (3) -> (2) is preferred over (3) |
| 42 | +// RUN: rm -rf %t/symlinked2 |
| 43 | +// RUN: mkdir -p %t/symlinked2/bin |
| 44 | +// RUN: ln -sf %t/install/bin/clang %t/symlinked2/bin/clang |
| 45 | + |
| 46 | +// RUN: %t/symlinked2/bin/clang -### %s -fsyntax-only 2>&1 \ |
| 47 | +// RUN: --target=x86_64-apple-darwin \ |
| 48 | +// RUN: -stdlib=libc++ \ |
| 49 | +// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 50 | +// RUN: | FileCheck -DTOOLCHAIN=%t/install \ |
| 51 | +// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 52 | +// RUN: --check-prefix=CHECK-TOOLCHAIN-INCLUDE-CXX-V1 %s |
| 53 | +// CHECK-TOOLCHAIN-INCLUDE-CXX-V1: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1" |
| 54 | +// CHECK-TOOLCHAIN-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |
| 55 | + |
| 56 | +// Headers in (2) and nowhere else -> (2) is used |
| 57 | +// RUN: %t/symlinked2/bin/clang -### %s -fsyntax-only 2>&1 \ |
| 58 | +// RUN: --target=x86_64-apple-darwin \ |
| 59 | +// RUN: -stdlib=libc++ \ |
| 60 | +// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 61 | +// RUN: | FileCheck -DTOOLCHAIN=%t/install \ |
| 62 | +// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \ |
| 63 | +// RUN: --check-prefix=CHECK-TOOLCHAIN-NO-SYSROOT %s |
| 64 | +// CHECK-TOOLCHAIN-NO-SYSROOT: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1" |
0 commit comments