xref: /llvm-project/clang/test/Driver/darwin-embedded-search-paths-libcxx.c (revision b9c932e5d6269fb0233ad5e70084e99e36ed4472)
1 // REQUIRES: default-cxx-stdlib=libc++
2 // UNSUPPORTED: system-windows
3 //   Windows is unsupported because we use the Unix path separator `/` in the test.
4 
5 // Unlike the Darwin driver, the MachO driver doesn't add any framework search paths,
6 // only the normal header ones.
7 // RUN: %clang -x c -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk -### -c %s 2>&1 \
8 // RUN: | FileCheck --check-prefixes=CC1,NO-CXX,ULI,CI,UI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
9 
10 // Unlike the Darwin driver, the MachO driver doesn't default to libc++, but when
11 // CLANG_DEFAULT_CXX_STDLIB is libc++ then the MachO driver should find the search path.
12 // RUN: %clang -x c++ -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk -### -c %s 2>&1 \
13 // RUN: | FileCheck --check-prefixes=CC1,CXX,ULI,CI,UI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
14 
15 // If the user requests libc++, the MachO driver should still find the search path.
16 // RUN: %clang -x c++ -stdlib=libc++ -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk -### -c %s 2>&1 \
17 // RUN: | FileCheck --check-prefixes=CC1,CXX,ULI,CI,UI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
18 
19 // Verify that embedded uses can swap in alternate usr/include and usr/local/include directories.
20 // usr/local/include is specified in the driver as -internal-isystem, however, the driver generated
21 // paths come before the paths in the driver arguments. In order to keep usr/local/include in the
22 // same position, -isystem has to be used instead of -Xclang -internal-isystem. There isn't an
23 // -externc-isystem, but it's ok to use -Xclang -internal-externc-isystem since the driver doesn't
24 // use that if -nostdlibinc or -nostdinc is passed.
25 // RUN: %clang -x c++ -stdlib=libc++ -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk \
26 // RUN:        -nostdlibinc -isystem %S/Inputs/MacOSX15.1.sdk/embedded/usr/local/include \
27 // RUN:        -Xclang -internal-externc-isystem -Xclang %S/Inputs/MacOSX15.1.sdk/embedded/usr/include \
28 // RUN:        -### -c %s 2>&1 | FileCheck --check-prefixes=CC1,NO-CXX,EULI,CI,EUI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
29 
30 
31 // The ordering of these flags doesn't matter, and so this test is a little
32 // fragile. i.e. all of the -internal-isystem paths will be searched before the
33 // -internal-externc-isystem ones, and their order on the command line doesn't
34 // matter. The line order here is just the current order that the driver writes
35 // the cc1 arguments.
36 
37 // CC1: "-cc1"
38 // NO-CXX-NOT: "-internal-isystem" "{{.*}}/include/c++/v1"
39 // CXX-SAME: "-internal-isystem" "{{.*}}/include/c++/v1"
40 // ULI-SAME: "-internal-isystem" "[[SDKROOT]]/usr/local/include"
41 // EULI-SAME: "-isystem" "[[SDKROOT]]/embedded/usr/local/include"
42 // CI-SAME: "-internal-isystem" "{{.*}}/clang/{{[[:digit:].]*}}/include"
43 // UI-SAME: "-internal-externc-isystem" "[[SDKROOT]]/usr/include"
44 // EUI-SAME: "-internal-externc-isystem" "[[SDKROOT]]/embedded/usr/include"
45 // NO-FW-NOT: "-internal-iframework"
46