xref: /llvm-project/clang/test/Driver/hexagon-toolchain-linux.c (revision 9cc2502c048b1403ba8ba5cc5a655d867c329d12)
1 // UNSUPPORTED: system-windows
2 
3 // -----------------------------------------------------------------------------
4 // Passing --musl
5 // -----------------------------------------------------------------------------
6 // RUN: %clang -### --target=hexagon-unknown-linux-musl \
7 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
8 // RUN:   -mcpu=hexagonv60 \
9 // RUN:   -fuse-ld=lld \
10 // RUN:   --sysroot=%S/Inputs/basic_linux_libcxx_tree %s 2>&1 | FileCheck -check-prefix=CHECK000 %s
11 // CHECK000-NOT:  {{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crti.o
12 // CHECK000:      "-dynamic-linker={{/|\\\\}}lib{{/|\\\\}}ld-musl-hexagon.so.1"
13 // CHECK000:      "{{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crt1.o"
14 // CHECK000:      "-lc" "-lclang_rt.builtins-hexagon"
15 // -----------------------------------------------------------------------------
16 // Passing --musl --shared
17 // -----------------------------------------------------------------------------
18 // RUN: %clang -### --target=hexagon-unknown-linux-musl \
19 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
20 // RUN:   -mcpu=hexagonv60 \
21 // RUN:   --sysroot=%S/Inputs/basic_linux_libcxx_tree -shared %s 2>&1 | FileCheck -check-prefix=CHECK001 %s
22 // CHECK001-NOT:    -dynamic-linker={{/|\\\\}}lib{{/|\\\\}}ld-musl-hexagon.so.1
23 // CHECK001:        "{{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crti.o"
24 // CHECK001:        "-lc" "-lclang_rt.builtins-hexagon"
25 // CHECK001-NOT:    {{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crt1.o
26 // -----------------------------------------------------------------------------
27 // Passing --musl -nostdlib
28 // -----------------------------------------------------------------------------
29 // RUN: %clang -### --target=hexagon-unknown-linux-musl \
30 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
31 // RUN:   -mcpu=hexagonv60 \
32 // RUN:   --sysroot=%S/Inputs/basic_linux_libcxx_tree -nostdlib %s 2>&1 | FileCheck -check-prefix=CHECK002 %s
33 // CHECK002:       "-dynamic-linker={{/|\\\\}}lib{{/|\\\\}}ld-musl-hexagon.so.1"
34 // CHECK002-NOT:   {{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crti.o
35 // CHECK002-NOT:   {{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crt1.o
36 // CHECK002-NOT:   "-lc"
37 // CHECK002-NOT:   "-lclang_rt.builtins-hexagon"
38 // -----------------------------------------------------------------------------
39 // Passing --musl -nostartfiles
40 // -----------------------------------------------------------------------------
41 // RUN: %clang -### --target=hexagon-unknown-linux-musl \
42 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
43 // RUN:   -mcpu=hexagonv60 \
44 // RUN:   --sysroot=%S/Inputs/basic_linux_libcxx_tree -nostartfiles %s 2>&1 | FileCheck -check-prefix=CHECK003 %s
45 // CHECK003:       "-dynamic-linker={{/|\\\\}}lib{{/|\\\\}}ld-musl-hexagon.so.1"
46 // CHECK003-NOT:   {{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}Scrt1.o
47 // CHECK003-NOT:   {{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crt1.o
48 // CHECK003:       "-lc" "-lclang_rt.builtins-hexagon"
49 // -----------------------------------------------------------------------------
50 // Passing --musl -nodefaultlibs
51 // -----------------------------------------------------------------------------
52 // RUN: %clang -### --target=hexagon-unknown-linux-musl \
53 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
54 // RUN:   -mcpu=hexagonv60 \
55 // RUN:   --sysroot=%S/Inputs/basic_linux_libcxx_tree -nodefaultlibs %s 2>&1 | FileCheck -check-prefix=CHECK004 %s
56 // CHECK004:       "-dynamic-linker={{/|\\\\}}lib{{/|\\\\}}ld-musl-hexagon.so.1"
57 // CHECK004:       "{{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crt1.o"
58 // CHECK004-NOT:   "-lc"
59 // CHECK004-NOT:   "-lclang_rt.builtins-hexagon"
60 // -----------------------------------------------------------------------------
61 // Passing --musl -nolibc
62 // -----------------------------------------------------------------------------
63 // RUN: %clang -### --target=hexagon-unknown-linux-musl \
64 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
65 // RUN:   -mcpu=hexagonv60 --sysroot=%S/Inputs/basic_linux_libcxx_tree \
66 // RUN:   -nolibc %s 2>&1 | FileCheck -check-prefix=CHECK-NOLIBC %s
67 // CHECK-NOLIBC:       "-dynamic-linker={{/|\\\\}}lib{{/|\\\\}}ld-musl-hexagon.so.1"
68 // CHECK-NOLIBC-SAME:  "{{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}crt1.o"
69 // CHECK-NOLIBC-NOT:   "-lc"
70 // -----------------------------------------------------------------------------
71 // Not Passing -fno-use-init-array when musl is selected
72 // -----------------------------------------------------------------------------
73 // RUN: %clang -### --target=hexagon-unknown-linux-musl \
74 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
75 // RUN:   -mcpu=hexagonv60 %s 2>&1 | FileCheck -check-prefix=CHECK005 %s
76 // CHECK005-NOT:          -fno-use-init-array
77 // -----------------------------------------------------------------------------
78 // -----------------------------------------------------------------------------
79 // c++ when musl is selected
80 // -----------------------------------------------------------------------------
81 // RUN: %clangxx -### --target=hexagon-unknown-linux-musl \
82 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
83 // RUN:   --sysroot=%S/Inputs/basic_linux_libcxx_tree \
84 // RUN:   -mcpu=hexagonv60 %s 2>&1 | FileCheck -check-prefix=CHECK006 %s
85 // CHECK006:          "-internal-isystem" "{{.*}}basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
86 // -----------------------------------------------------------------------------
87 // c++ when musl is selected
88 // -----------------------------------------------------------------------------
89 // RUN: %clangxx -### --target=hexagon-unknown-elf \
90 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
91 // RUN:   -stdlib=libc++ \
92 // RUN:   -mcpu=hexagonv60 %s 2>&1 | FileCheck -check-prefix=CHECK007 %s
93 // CHECK007:   "-internal-isystem" "{{.*}}hexagon{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
94 // -----------------------------------------------------------------------------
95 // internal-isystem for linux with and without musl
96 // -----------------------------------------------------------------------------
97 // RUN: %clang -### --target=hexagon-unknown-linux-musl \
98 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
99 // RUN:   -resource-dir=%S/Inputs/resource_dir %s 2>&1 | FileCheck -check-prefix=CHECK008 %s
100 // CHECK008:   InstalledDir: [[INSTALLED_DIR:.+]]
101 // CHECK008:   "-resource-dir" "[[RESOURCE:[^"]+]]"
102 // CHECK008-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
103 // CHECK008-SAME: {{^}} "-internal-externc-isystem" "[[INSTALLED_DIR]]/../target/hexagon/include"
104 
105 // RUN: %clang -### --target=hexagon-unknown-linux \
106 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
107 // RUN:   -resource-dir=%S/Inputs/resource_dir %s 2>&1 | FileCheck -check-prefix=CHECK009 %s
108 // CHECK009:   InstalledDir: [[INSTALLED_DIR:.+]]
109 // CHECK009:   "-resource-dir" "[[RESOURCE:[^"]+]]"
110 // CHECK009-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
111 // CHECK009-SAME: {{^}} "-internal-externc-isystem" "[[INSTALLED_DIR]]/../target/hexagon/include"
112 
113 // RUN: %clang -Werror -L/tmp \
114 // RUN:    --target=hexagon-unknown-linux-musl %s -### 2>&1 \
115 // RUN:    | FileCheck -check-prefix=CHECK010 %s
116 // CHECK010:   InstalledDir: [[INSTALLED_DIR:.+]]
117 // CHECK010-NOT:  "-lstandalone"
118 // CHECK010-NOT:  crt0_standalone.o
119 // CHECK010:   crt1.o
120 // CHECK010:   "-L/tmp"
121 // CHECK010-NOT:  "-lstandalone"
122 
123 // -----------------------------------------------------------------------------
124 // unwindlib
125 // -----------------------------------------------------------------------------
126 // RUN: %clangxx --unwindlib=none \
127 // RUN:    --target=hexagon-unknown-linux-musl %s -### 2>&1 \
128 // RUN:    | FileCheck -check-prefix=CHECK011 %s
129 // CHECK011:   InstalledDir: [[INSTALLED_DIR:.+]]
130 // CHECK011:   crt1.o
131 // CHECK011-NOT:  "-lunwind"
132 // CHECK011-NOT:  "-lgcc_eh"
133 // CHECK012-NOT:  "-lgcc_s"
134 
135 
136 // RUN: %clangxx --rtlib=compiler-rt --unwindlib=libunwind \
137 // RUN:    --target=hexagon-unknown-linux-musl %s -### 2>&1 \
138 // RUN:    | FileCheck -check-prefix=CHECK012 %s
139 // RUN: %clangxx \
140 // RUN:    --target=hexagon-unknown-linux-musl %s -### 2>&1 \
141 // RUN:    | FileCheck -check-prefix=CHECK012 %s
142 // CHECK012:   InstalledDir: [[INSTALLED_DIR:.+]]
143 // CHECK012:   crt1.o
144 // CHECK012:  "-lunwind"
145 // CHECK012-NOT:  "-lgcc_eh"
146 // CHECK012-NOT:  "-lgcc_s"
147 
148 // RUN: not %clangxx --rtlib=compiler-rt --unwindlib=libgcc \
149 // RUN:    --target=hexagon-unknown-linux-musl %s -### 2>&1 \
150 // RUN:    | FileCheck -check-prefix=CHECK013 %s
151 // CHECK013:  error: unsupported unwind library 'libgcc' for platform 'hexagon-unknown-linux-musl'
152 // CHECK013-NOT:  "-lgcc_eh"
153 // CHECK013-NOT:  "-lgcc_s"
154 // CHECK013-NOT:  "-lunwind"
155