Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Driver / ohos.c
blob9b98c709815c5e279cb83914e7c0b0582c22e195
1 // RUN: %clang %s -### -no-canonical-prefixes --target=arm-liteos \
2 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
3 // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot -fuse-ld=ld -march=armv7-a 2>&1 \
4 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-ARM %s
5 // RUN: %clang %s -### -no-canonical-prefixes --target=arm-liteos \
6 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
7 // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot -fuse-ld=ld -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=soft 2>&1 \
8 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-ARM-A7-SOFT %s
9 // CHECK: {{.*}}clang{{.*}}" "-cc1"
10 // CHECK-NOT: "--mrelax-relocations"
11 // CHECK-NOT: "-munwind-tables"
12 // CHECK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
13 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
14 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|\\\\}}include"
15 // CHECK-NOT: "-fsanitize=safe-stack"
16 // CHECK-NOT: "-stack-protector" "2"
17 // CHECK-NOT: "-fno-common"
18 // CHECK: {{.*}}ld.lld{{.*}}" "--sysroot=[[SYSROOT]]"
19 // CHECK-NOT: "--sysroot=[[SYSROOT]]"
20 // CHECK: "-pie"
21 // CHECK-NOT: "--build-id"
22 // CHECK: "--hash-style=both"
23 // CHECK: "-dynamic-linker" "/lib/ld-musl-arm.so.1"
24 // CHECK: Scrt1.o
25 // CHECK: crti.o
26 // CHECK: clang_rt.crtbegin.o
27 // CHECK-ARM: "-L[[SYSROOT]]{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}"
28 // CHECK-ARM-A7-SOFT: "-L[[SYSROOT]]{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}a7_soft"
29 // CHECK-ARM: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.builtins.a"
30 // CHECK-ARM-A7-SOFT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos/a7_soft{{/|\\\\}}libclang_rt.builtins.a"
31 // CHECK: "-lc"
32 // CHECK: clang_rt.crtend.o
33 // CHECK: crtn.o
35 // RUN: not %clang %s -### --target=arm-liteos -rtlib=libgcc 2>&1 \
36 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
37 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
39 // RUN: %clang %s -### --target=arm-liteos -static -fuse-ld=ld 2>&1 \
40 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
41 // CHECK-STATIC: "-static"
42 // CHECK-STATIC-NOT: "-Bdynamic"
43 // CHECK-STATIC: "-l:libunwind.a"
44 // CHECK-STATIC: "-lc"
46 // RUN: %clang %s -### --target=arm-liteos -shared -fuse-ld=ld 2>&1 \
47 // RUN: | FileCheck %s -check-prefix=CHECK-SHARED
48 // CHECK-SHARED-NOT: "-pie"
49 // CHECK-SHARED: "-shared"
50 // CHECK-SHARED: "-lc"
51 // CHECK-SHARED: "-l:libunwind.a"
53 // RUN: %clang %s -### --target=arm-linux-ohos -fuse-ld=ld 2>&1 \
54 // RUN: | FileCheck %s -check-prefix=CHECK-RUNTIME
55 // RUN: %clang %s -### --target=aarch64-linux-ohos -fuse-ld=ld 2>&1 \
56 // RUN: | FileCheck %s -check-prefix=CHECK-RUNTIME
57 // RUN: %clang %s -### --target=mipsel-linux-ohos -fuse-ld=ld 2>&1 \
58 // RUN: | FileCheck %s -check-prefix=CHECK-RUNTIME
59 // RUN: %clang %s -### --target=x86_64-linux-ohos -fuse-ld=ld 2>&1 \
60 // RUN: | FileCheck %s -check-prefix=CHECK-RUNTIME
61 // CHECK-RUNTIME: "{{.*}}libclang_rt.builtins.a"
62 // CHECK-RUNTIME: "-l:libunwind.a"
63 // CHECK-LIBM: "-lm"
65 // RUN: %clang %s -### --target=arm-liteos -r -fuse-ld=ld 2>&1 \
66 // RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE
67 // CHECK-RELOCATABLE-NOT: "-pie"
68 // CHECK-RELOCATABLE: "-r"
70 // RUN: %clang %s -### --target=arm-liteos -nodefaultlibs -fuse-ld=ld 2>&1 \
71 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
72 // RUN: | FileCheck %s -check-prefix=CHECK-NODEFAULTLIBS
73 // CHECK-NODEFAULTLIBS: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
74 // CHECK-NODEFAULTLIBS-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.builtins.a"
75 // CHECK-NODEFAULTLIBS-NOT: "-lc"
77 // RUN: %clang %s -### --target=arm-liteos -nostdlib -fuse-ld=ld 2>&1 \
78 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
79 // RUN: | FileCheck %s -check-prefix=CHECK-NOSTDLIB
80 // CHECK-NOSTDLIB: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
81 // CHECK-NOSTDLIB-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.builtins.a"
82 // CHECK-NOSTDLIB-NOT: "-lc"
84 // RUN: %clang %s -### --target=arm-liteos -nolibc -fuse-ld=ld 2>&1 \
85 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
86 // RUN: | FileCheck %s -check-prefix=CHECK-NOLIBC
87 // CHECK-NOLIBC: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
88 // CHECK-NOLIBC: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.builtins.a"
89 // CHECK-NOLIBC-NOT: "-lc"
91 // RUN: %clang %s -### --target=arm-liteos \
92 // RUN: -fsanitize=safe-stack 2>&1 \
93 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
94 // RUN: -fuse-ld=ld \
95 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
96 // CHECK-SAFESTACK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
97 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
98 // CHECK-SAFESTACK: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.safestack.a"
99 // CHECK-SAFESTACK: "__safestack_init"
101 // RUN: %clang %s -### --target=arm-liteos \
102 // RUN: -fsanitize=address 2>&1 \
103 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
104 // RUN: -fuse-ld=ld \
105 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-ARM
106 // CHECK-ASAN-ARM: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
107 // CHECK-ASAN-ARM: "-fsanitize=address"
108 // CHECK-ASAN-ARM: "-fsanitize-address-use-after-scope"
109 // CHECK-ASAN-ARM: "-dynamic-linker" "/lib/ld-musl-arm.so.1"
110 // CHECK-ASAN-ARM: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.asan.a"
111 // CHECK-ASAN-ARM-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.asan-preinit.a"
113 // RUN: %clang %s -### --target=arm-liteos \
114 // RUN: -fsanitize=address -fPIC -shared 2>&1 \
115 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
116 // RUN: -shared-libsan \
117 // RUN: -fuse-ld=ld \
118 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-SHARED
119 // CHECK-ASAN-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
120 // CHECK-ASAN-SHARED: "-fsanitize=address"
121 // CHECK-ASAN-SHARED: "-fsanitize-address-use-after-scope"
122 // CHECK-ASAN-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.asan.so"
123 // CHECK-ASAN-SHARED-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.asan-preinit.a"
125 // RUN: %clang %s -### --target=arm-liteos \
126 // RUN: -fsanitize=fuzzer 2>&1 \
127 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
128 // RUN: -fuse-ld=ld \
129 // RUN: | FileCheck %s -check-prefix=CHECK-FUZZER-ARM
130 // CHECK-FUZZER-ARM: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
131 // CHECK-FUZZER-ARM: "-fsanitize=fuzzer,fuzzer-no-link"
132 // CHECK-FUZZER-ARM: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.fuzzer.a"
134 // RUN: %clang %s -### --target=arm-liteos \
135 // RUN: -fsanitize=scudo 2>&1 \
136 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
137 // RUN: -fuse-ld=ld \
138 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-ARM
139 // CHECK-SCUDO-ARM: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
140 // CHECK-SCUDO-ARM: "-fsanitize=scudo"
141 // CHECK-SCUDO-ARM: "-pie"
142 // CHECK-SCUDO-ARM: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.scudo_standalone.a"
144 // RUN: %clang %s -### --target=arm-liteos \
145 // RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
146 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
147 // RUN: -shared-libsan \
148 // RUN: -fuse-ld=ld \
149 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
150 // CHECK-SCUDO-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
151 // CHECK-SCUDO-SHARED: "-fsanitize=scudo"
152 // CHECK-SCUDO-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.scudo_standalone.so"
154 // RUN: %clang %s -### --target=arm-liteos \
155 // RUN: -fxray-instrument -fxray-modes=xray-basic \
156 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
157 // RUN: -fuse-ld=ld 2>&1 \
158 // RUN: | FileCheck %s -check-prefix=CHECK-XRAY-ARM
159 // CHECK-XRAY-ARM: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
160 // CHECK-XRAY-ARM: "-fxray-instrument"
161 // CHECK-XRAY-ARM: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.xray.a"
162 // CHECK-XRAY-ARM: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.xray-basic.a"
164 // RUN: %clang %s -### --target=arm-liteos \
165 // RUN: -O3 -flto -mcpu=cortex-a53 2>&1 \
166 // RUN: -fuse-ld=ld \
167 // RUN: | FileCheck %s -check-prefix=CHECK-LTO
168 // CHECK-LTO: "-plugin-opt=mcpu=cortex-a53"
169 // CHECK-LTO: "-plugin-opt=O3"
171 // RUN: %clang %s -### --target=arm-liteos \
172 // RUN: -flto=thin -flto-jobs=8 -mcpu=cortex-a7 2>&1 \
173 // RUN: -fuse-ld=ld \
174 // RUN: | FileCheck %s -check-prefix=CHECK-THINLTO
175 // CHECK-THINLTO: "-plugin-opt=mcpu=cortex-a7"
176 // CHECK-THINLTO: "-plugin-opt=thinlto"
177 // CHECK-THINLTO: "-plugin-opt=jobs=8"
179 // RUN: %clang %s -### --target=arm-liteos \
180 // RUN: -ccc-install-dir %S/Inputs/ohos_native_tree/llvm/bin \
181 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
182 // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot \
183 // RUN: -march=armv7-a -mfloat-abi=soft 2>&1\
184 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB,CHECK-MULTILIB-SF,CHECK-MULTILIB-ARM
185 // RUN: %clang %s -### --target=arm-liteos \
186 // RUN: -ccc-install-dir %S/Inputs/ohos_native_tree/llvm/bin \
187 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
188 // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot \
189 // RUN: -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=soft 2>&1\
190 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB,CHECK-MULTILIB-SF,CHECK-MULTILIB-ARM-A7-SOFT
191 // RUN: %clang %s -### --target=arm-liteos \
192 // RUN: -ccc-install-dir %S/Inputs/ohos_native_tree/llvm/bin \
193 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
194 // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot \
195 // RUN: -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 2>&1\
196 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB,CHECK-MULTILIB-SF,CHECK-MULTILIB-ARM-A7-SOFTFP
197 // RUN: %clang %s -### --target=arm-liteos \
198 // RUN: -ccc-install-dir %S/Inputs/ohos_native_tree/llvm/bin \
199 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
200 // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot \
201 // RUN: -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4 2>&1\
202 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB,CHECK-MULTILIB-HF,CHECK-MULTILIB-ARM-A7-HARD
203 // CHECK-MULTILIB: {{.*}}clang{{.*}}" "-cc1"
204 // CHECK-MULTILIB: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
205 // CHECK-MULTILIB: "-isysroot" "[[SYSROOT:[^"]+]]"
206 // CHECK-MULTILIB: {{.*}}ld.lld{{.*}}" "--sysroot=[[SYSROOT]]"
207 // CHECK-MULTILIB-SF: "-dynamic-linker" "/lib/ld-musl-arm.so.1"
208 // CHECK-MULTILIB-HF: "-dynamic-linker" "/lib/ld-musl-armhf.so.1"
210 // CHECK-MULTILIB-ARM: "-L[[SYSROOT]]{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}"
212 // CHECK-MULTILIB-ARM-A7-SOFT: "-L[[SYSROOT]]{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}a7_soft"
214 // CHECK-MULTILIB-ARM-A7-SOFTFP: "-L[[SYSROOT]]{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}a7_softfp_neon-vfpv4"
216 // CHECK-MULTILIB-ARM-A7-HARD: "-L[[SYSROOT]]{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}a7_hard_neon-vfpv4"
218 // CHECK-MULTILIB-ARM: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}libclang_rt.builtins.a"
219 // CHECK-MULTILIB-ARM-A7-SOFT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}a7_soft{{/|\\\\}}libclang_rt.builtins.a"
220 // CHECK-MULTILIB-ARM-A7-SOFTFP: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}a7_softfp_neon-vfpv4{{/|\\\\}}libclang_rt.builtins.a"
221 // CHECK-MULTILIB-ARM-A7-HARD: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}arm-liteos-ohos{{/|\\\\}}a7_hard_neon-vfpv4{{/|\\\\}}libclang_rt.builtins.a"
223 // RUN: %clang %s -### -no-canonical-prefixes --target=arm-linux-ohos -fprofile-instr-generate -v \
224 // RUN: -resource-dir=%S/Inputs/ohos_native_tree/llvm/lib/clang/x.y.z \
225 // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot -fuse-ld=ld -march=armv7-a 2>&1 \
226 // RUN: | FileCheck -check-prefixes=CHECK-PROFILE-RTLIB %s
228 // CHECK-PROFILE-RTLIB: -u__llvm_profile_runtime
229 // CHECK-PROFILE-RTLIB: libclang_rt.profile
231 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
232 // RUN: --target=arm64-linux-ohos -pthread \
233 // RUN: --gcc-toolchain="" \
234 // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot \
235 // RUN: -shared \
236 // RUN: | FileCheck --check-prefix=CHECK-OHOS-PTHREAD %s
238 // CHECK-OHOS-PTHREAD-NOT: -lpthread