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 -no-canonical-prefixes %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: "{{[^"]*}}clang{{[^"]*}}" "-cc1" 15 16 // Check with only headers alongside the installation (those should be used). 17 // 18 // RUN: %clang -no-canonical-prefixes %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: "{{[^"]*}}clang{{[^"]*}}" "-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 -no-canonical-prefixes %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: "{{[^"]*}}clang{{[^"]*}}" "-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 -no-canonical-prefixes %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: "{{[^"]*}}clang{{[^"]*}}" "-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 -no-canonical-prefixes %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 -no-canonical-prefixes %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 -no-canonical-prefixes %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: "{{[^"]*}}clang{{[^"]*}}" "-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 does not drop any C++ library include path. 96 // This behavior is strange, but it is compatible with the legacy CC1 behavior. 97 // 98 // RUN: %clang -no-canonical-prefixes %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_cxx_v1 \ 103 // RUN: -stdlib=platform \ 104 // RUN: -nostdinc \ 105 // RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ 106 // RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ 107 // RUN: --check-prefix=CHECK-LIBCXX-NOSTDINC-1 %s 108 // CHECK-LIBCXX-NOSTDINC-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1" 109 // CHECK-LIBCXX-NOSTDINC-1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" 110 // CHECK-LIBCXX-NOSTDINC-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" 111 // 112 // RUN: %clang -no-canonical-prefixes %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_no_libcxx \ 117 // RUN: -stdlib=platform \ 118 // RUN: -nostdinc \ 119 // RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \ 120 // RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ 121 // RUN: --check-prefix=CHECK-LIBCXX-NOSTDINC-2 %s 122 // CHECK-LIBCXX-NOSTDINC-2: "{{[^"]*}}clang{{[^"]*}}" "-cc1" 123 // CHECK-LIBCXX-NOSTDINC-2: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" 124 // CHECK-LIBCXX-NOSTDINC-2-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" 125 126 // Make sure that using -nostdinc++ or -nostdlib will drop both the toolchain 127 // C++ include path and the sysroot one. 128 // 129 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ 130 // RUN: -target x86_64-apple-darwin16 \ 131 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ 132 // RUN: -resource-dir=%S/Inputs/resource_dir \ 133 // RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \ 134 // RUN: -stdlib=platform \ 135 // RUN: -nostdinc++ \ 136 // RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \ 137 // RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ 138 // RUN: --check-prefix=CHECK-LIBCXX-NOSTDINCXX %s 139 // CHECK-LIBCXX-NOSTDINCXX: "{{[^"]*}}clang{{[^"]*}}" "-cc1" 140 // CHECK-LIBCXX-NOSTDINCXX-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" 141 // CHECK-LIBCXX-NOSTDINCXX-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" 142 // 143 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ 144 // RUN: -target x86_64-apple-darwin16 \ 145 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \ 146 // RUN: -resource-dir=%S/Inputs/resource_dir \ 147 // RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr \ 148 // RUN: -stdlib=platform \ 149 // RUN: -nostdlibinc \ 150 // RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \ 151 // RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \ 152 // RUN: --check-prefix=CHECK-LIBCXX-NOSTDLIBINC %s 153 // CHECK-LIBCXX-NOSTDLIBINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1" 154 // CHECK-LIBCXX-NOSTDLIBINC-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" 155 // CHECK-LIBCXX-NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" 156 157 // Make sure we explain that we considered a path but didn't add it when it 158 // doesn't exist. 159 // 160 // RUN: %clang -no-canonical-prefixes %s -fsyntax-only -v 2>&1 \ 161 // RUN: -target x86_64-apple-darwin \ 162 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ 163 // RUN: -isysroot %S/Inputs/basic_darwin_sdk \ 164 // RUN: -stdlib=libc++ \ 165 // RUN: | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \ 166 // RUN: --check-prefix=CHECK-LIBCXX-MISSING-TOOLCHAIN %s 167 // CHECK-LIBCXX-MISSING-TOOLCHAIN: ignoring nonexistent directory "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" 168 // 169 // RUN: %clang -no-canonical-prefixes %s -fsyntax-only -v 2>&1 \ 170 // RUN: -target x86_64-apple-darwin \ 171 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \ 172 // RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libcxx \ 173 // RUN: -stdlib=libc++ \ 174 // RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \ 175 // RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \ 176 // RUN: --check-prefix=CHECK-LIBCXX-MISSING-BOTH %s 177 // CHECK-LIBCXX-MISSING-BOTH: ignoring nonexistent directory "[[TOOLCHAIN]]/usr/bin/../include/c++/v1" 178 // CHECK-LIBCXX-MISSING-BOTH: ignoring nonexistent directory "[[SYSROOT]]/usr/include/c++/v1" 179