| 1 |
// UNSUPPORTED: system-windows |
| 2 |
|
| 3 |
// General tests that the header search paths for libc++ detected by the driver |
| 4 |
// and passed to CC1 are correct on Darwin platforms. |
| 5 |
|
| 6 |
// Check without a sysroot and without headers alongside the installation |
| 7 |
// (no include path should be added, and no warning or error). |
| 8 |
// |
| 9 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 10 |
// RUN: --target=x86_64-apple-darwin \ |
| 11 |
// RUN: -stdlib=libc++ \ |
| 12 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ |
| 13 |
// RUN: | FileCheck --check-prefix=CHECK-LIBCXX-NONE %s |
| 14 |
// CHECK-LIBCXX-NONE: "-cc1" |
| 15 |
|
| 16 |
// Check with only headers alongside the installation (those should be used). |
| 17 |
// |
| 18 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 19 |
// RUN: --target=x86_64-apple-darwin \ |
| 20 |
// RUN: -stdlib=libc++ \ |
| 21 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 22 |
// RUN: --sysroot="" \ |
| 23 |
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 24 |
// RUN: --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s |
| 25 |
// CHECK-LIBCXX-TOOLCHAIN-1: "-cc1" |
| 26 |
// CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 27 |
// CHECK-LIBCXX-TOOLCHAIN-1-NOT: "-internal-isystem" "/usr/include/c++/v1" |
| 28 |
// |
| 29 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 30 |
// RUN: --target=x86_64-apple-darwin \ |
| 31 |
// RUN: -stdlib=libc++ \ |
| 32 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 33 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libcxx \ |
| 34 |
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 35 |
// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \ |
| 36 |
// RUN: --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s |
| 37 |
// CHECK-LIBCXX-TOOLCHAIN-2: "-cc1" |
| 38 |
// CHECK-LIBCXX-TOOLCHAIN-2: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 39 |
// CHECK-LIBCXX-TOOLCHAIN-2-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |
| 40 |
|
| 41 |
// Check with only headers in the sysroot (those should be used). |
| 42 |
// |
| 43 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 44 |
// RUN: --target=x86_64-apple-darwin \ |
| 45 |
// RUN: -stdlib=libc++ \ |
| 46 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ |
| 47 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 48 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 49 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \ |
| 50 |
// RUN: --check-prefix=CHECK-LIBCXX-SYSROOT-1 %s |
| 51 |
// CHECK-LIBCXX-SYSROOT-1: "-cc1" |
| 52 |
// CHECK-LIBCXX-SYSROOT-1: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |
| 53 |
// CHECK-LIBCXX-SYSROOT-1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 54 |
|
| 55 |
// Check with both headers in the sysroot and headers alongside the installation |
| 56 |
// (the headers in the toolchain should be preferred over the <sysroot> headers). |
| 57 |
// Ensure that both -isysroot and --sysroot work, and that isysroot has precedence |
| 58 |
// over --sysroot. |
| 59 |
// |
| 60 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 61 |
// RUN: --target=x86_64-apple-darwin \ |
| 62 |
// RUN: -stdlib=libc++ \ |
| 63 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 64 |
// RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 65 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 66 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 67 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 68 |
// RUN: --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s |
| 69 |
// |
| 70 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 71 |
// RUN: --target=x86_64-apple-darwin \ |
| 72 |
// RUN: -stdlib=libc++ \ |
| 73 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 74 |
// RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 75 |
// RUN: --sysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 76 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 77 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 78 |
// RUN: --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s |
| 79 |
// |
| 80 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 81 |
// RUN: --target=x86_64-apple-darwin \ |
| 82 |
// RUN: -stdlib=libc++ \ |
| 83 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 84 |
// RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 85 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 86 |
// RUN: --sysroot %S/Inputs/basic_darwin_sdk_no_libcxx \ |
| 87 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 88 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 89 |
// RUN: --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s |
| 90 |
// |
| 91 |
// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-cc1" |
| 92 |
// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 93 |
// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |
| 94 |
|
| 95 |
// Make sure that using -nostdinc, -nostdinc++ or -nostdlib will drop both the toolchain |
| 96 |
// C++ include path and the sysroot one. |
| 97 |
// |
| 98 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 99 |
// RUN: --target=x86_64-apple-darwin16 \ |
| 100 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 101 |
// RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 102 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr \ |
| 103 |
// RUN: -stdlib=platform \ |
| 104 |
// RUN: -nostdinc \ |
| 105 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \ |
| 106 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 107 |
// RUN: --check-prefix=CHECK-LIBCXX-NOSTDLIBINC %s |
| 108 |
// CHECK-LIBCXX-NOSTDINC: "-cc1" |
| 109 |
// CHECK-LIBCXX-NOSTDINC-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 110 |
// CHECK-LIBCXX-NOSTDINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |
| 111 |
// |
| 112 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 113 |
// RUN: --target=x86_64-apple-darwin16 \ |
| 114 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 115 |
// RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 116 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 117 |
// RUN: -stdlib=platform \ |
| 118 |
// RUN: -nostdinc++ \ |
| 119 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \ |
| 120 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 121 |
// RUN: --check-prefix=CHECK-LIBCXX-NOSTDINCXX %s |
| 122 |
// CHECK-LIBCXX-NOSTDINCXX: "-cc1" |
| 123 |
// CHECK-LIBCXX-NOSTDINCXX-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 124 |
// CHECK-LIBCXX-NOSTDINCXX-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |
| 125 |
// |
| 126 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 127 |
// RUN: --target=x86_64-apple-darwin16 \ |
| 128 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ |
| 129 |
// RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 130 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr \ |
| 131 |
// RUN: -stdlib=platform \ |
| 132 |
// RUN: -nostdlibinc \ |
| 133 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \ |
| 134 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ |
| 135 |
// RUN: --check-prefix=CHECK-LIBCXX-NOSTDLIBINC %s |
| 136 |
// CHECK-LIBCXX-NOSTDLIBINC: "-cc1" |
| 137 |
// CHECK-LIBCXX-NOSTDLIBINC-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 138 |
// CHECK-LIBCXX-NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |
| 139 |
|
| 140 |
// Make sure we explain that we considered a path but didn't add it when it |
| 141 |
// doesn't exist. |
| 142 |
// |
| 143 |
// RUN: %clang %s -fsyntax-only -v 2>&1 \ |
| 144 |
// RUN: --target=x86_64-apple-darwin \ |
| 145 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ |
| 146 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk \ |
| 147 |
// RUN: -stdlib=libc++ \ |
| 148 |
// RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \ |
| 149 |
// RUN: --check-prefix=CHECK-LIBCXX-MISSING-TOOLCHAIN %s |
| 150 |
// CHECK-LIBCXX-MISSING-TOOLCHAIN: ignoring nonexistent directory "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 151 |
// |
| 152 |
// RUN: %clang %s -fsyntax-only -v 2>&1 \ |
| 153 |
// RUN: --target=x86_64-apple-darwin \ |
| 154 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ |
| 155 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libcxx \ |
| 156 |
// RUN: -stdlib=libc++ \ |
| 157 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \ |
| 158 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \ |
| 159 |
// RUN: --check-prefix=CHECK-LIBCXX-MISSING-BOTH %s |
| 160 |
// CHECK-LIBCXX-MISSING-BOTH: ignoring nonexistent directory "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" |
| 161 |
// CHECK-LIBCXX-MISSING-BOTH: ignoring nonexistent directory "[[SYSROOT]]/usr/include/c++/v1" |
| 162 |
|
| 163 |
// Make sure that on Darwin, we use libc++ header search paths by default even when |
| 164 |
// -stdlib= isn't passed. |
| 165 |
// |
| 166 |
// RUN: %clang -### %s -fsyntax-only 2>&1 \ |
| 167 |
// RUN: --target=x86_64-apple-darwin \ |
| 168 |
// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ |
| 169 |
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 170 |
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ |
| 171 |
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \ |
| 172 |
// RUN: --check-prefix=CHECK-LIBCXX-STDLIB-UNSPECIFIED %s |
| 173 |
// CHECK-LIBCXX-STDLIB-UNSPECIFIED: "-cc1" |
| 174 |
// CHECK-LIBCXX-STDLIB-UNSPECIFIED: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" |