xref: /llvm-project/clang/test/Driver/modules-print-library-module-manifest-path.cpp (revision 2c34632a9977a82ce6262d95f07addb772ba7014)
1 // Test that -print-library-module-manifest-path finds the correct file.
2 
3 // RUN: rm -rf %t && split-file %s %t && cd %t
4 // RUN: mkdir -p %t/Inputs/usr/lib/x86_64-linux-gnu
5 // RUN: touch %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.so
6 // RUN: touch %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.a
7 
8 // RUN: %clang -print-library-module-manifest-path \
9 // RUN:     -stdlib=libc++ \
10 // RUN:     -resource-dir=%t/Inputs/usr/lib/x86_64-linux-gnu \
11 // RUN:     --target=x86_64-linux-gnu 2>&1 \
12 // RUN:   | FileCheck libcxx-no-module-json.cpp
13 
14 // RUN: touch %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.modules.json
15 // RUN: %clang -print-library-module-manifest-path \
16 // RUN:     -stdlib=libc++ \
17 // RUN:     -resource-dir=%t/Inputs/usr/lib/x86_64-linux-gnu \
18 // RUN:     --target=x86_64-linux-gnu 2>&1 \
19 // RUN:   | FileCheck libcxx.cpp
20 
21 // for macos there is a different directory structure
22 // where the library and libc++.modules.json file are in lib
23 // directly but headers are in clang/ver directory which
24 // is the resource directory
25 // RUN: mkdir -p %t/Inputs/usr/lib/clang/20
26 // RUN: touch %t/Inputs/usr/lib/libc++.so
27 // RUN: touch %t/Inputs/usr/lib/libc++.modules.json
28 // RUN: %clang -print-library-module-manifest-path \
29 // RUN:     -stdlib=libc++ \
30 // RUN:     -resource-dir=%t/Inputs/usr/lib/clang/20 \
31 // RUN:     --target=arm64-apple-darwin24.1.0 2>&1 \
32 // RUN:   | FileCheck libcxx.cpp.macos
33 
34 // RUN: rm %t/Inputs/usr/lib/libc++.so
35 // RUN: touch %t/Inputs/usr/lib/libc++.a
36 // RUN: touch %t/Inputs/usr/lib/libc++.modules.json
37 // RUN: %clang -print-library-module-manifest-path \
38 // RUN:     -stdlib=libc++ \
39 // RUN:     -resource-dir=%t/Inputs/usr/lib/clang/20 \
40 // RUN:     --target=arm64-apple-darwin24.1.0 2>&1 \
41 // RUN:   | FileCheck libcxx.cpp.macos
42 
43 // RUN: rm %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.so
44 // RUN: touch %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.a
45 // RUN: %clang -print-library-module-manifest-path \
46 // RUN:     -stdlib=libc++ \
47 // RUN:     -resource-dir=%t/Inputs/usr/lib/x86_64-linux-gnu \
48 // RUN:     --target=x86_64-linux-gnu 2>&1 \
49 // RUN:   | FileCheck libcxx-no-shared-lib.cpp
50 
51 // Testing with libstdc++
52 // RUN: touch %t/Inputs/usr/lib/x86_64-linux-gnu/libstdc++.so
53 // RUN: touch %t/Inputs/usr/lib/x86_64-linux-gnu/libstdc++.modules.json
54 // RUN: %clang -print-library-module-manifest-path \
55 // RUN:     -stdlib=libstdc++ \
56 // RUN:     -resource-dir=%t/Inputs/usr/lib/x86_64-linux-gnu \
57 // RUN:     --target=x86_64-linux-gnu 2>&1 \
58 // RUN:   | FileCheck libstdcxx.cpp
59 
60 //--- libcxx-no-module-json.cpp
61 
62 // CHECK: <NOT PRESENT>
63 
64 //--- libcxx.cpp
65 
66 // CHECK: {{.*}}/Inputs/usr/lib/x86_64-linux-gnu{{/|\\}}libc++.modules.json
67 
68 //--- libcxx.cpp.macos
69 
70 // CHECK: {{.*}}libc++.modules.json
71 
72 //--- libcxx-no-shared-lib.cpp
73 
74 // Note this might find a different path depending whether search path
75 // contains a different libc++.so.
76 // CHECK: {{.*}}libc++.modules.json
77 
78 //--- libstdcxx.cpp
79 
80 // CHECK: {{.*}}libstdc++.modules.json