1 // A basic clang -cc1 command-line, and simple environment check.
2 
3 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
4 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
5 // RUN:   | FileCheck -check-prefix=CC1 %s
6 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
7 
8 // Test interaction with -fuse-ld=lld, if lld is available.
9 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
10 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fuse-ld=lld 2>&1 \
11 // RUN:   | FileCheck -check-prefix=LLD %s
12 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
13 
14 // In the below tests, --rtlib=platform is used so that the driver ignores
15 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
16 
17 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
18 // RUN:   -target riscv32-unknown-elf --rtlib=platform \
19 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree \
20 // RUN:   --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf 2>&1 \
21 // RUN:   | FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32 %s
22 
23 // C-RV32-BAREMETAL-ILP32: "{{.*}}Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}riscv32-unknown-elf-ld"
24 // C-RV32-BAREMETAL-ILP32: "--sysroot={{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf"
25 // C-RV32-BAREMETAL-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf/lib{{/|\\\\}}crt0.o"
26 // C-RV32-BAREMETAL-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtbegin.o"
27 // C-RV32-BAREMETAL-ILP32: "-L{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1"
28 // C-RV32-BAREMETAL-ILP32: "-L{{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf/lib"
29 // C-RV32-BAREMETAL-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
30 // C-RV32-BAREMETAL-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtend.o"
31 
32 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
33 // RUN:   -target riscv32-unknown-elf --rtlib=platform \
34 // RUN:   --sysroot= \
35 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
36 // RUN:   | FileCheck -check-prefix=C-RV32-BAREMETAL-NOSYSROOT-ILP32 %s
37 
38 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}riscv32-unknown-elf-ld"
39 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}riscv32-unknown-elf/lib{{/|\\\\}}crt0.o"
40 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtbegin.o"
41 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: "-L{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1"
42 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: "-L{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}riscv32-unknown-elf{{/|\\\\}}lib"
43 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
44 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtend.o"
45 
46 // RUN: %clangxx %s -### -no-canonical-prefixes -fuse-ld= \
47 // RUN:   -target riscv32-unknown-elf -stdlib=libstdc++ --rtlib=platform \
48 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree \
49 // RUN:   --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf 2>&1 \
50 // RUN:   | FileCheck -check-prefix=CXX-RV32-BAREMETAL-ILP32 %s
51 
52 // CXX-RV32-BAREMETAL-ILP32: "-internal-isystem" "{{.*}}Inputs/basic_riscv32_tree/riscv32-unknown-elf/include/c++{{/|\\\\}}8.0.1"
53 // CXX-RV32-BAREMETAL-ILP32: "{{.*}}Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}riscv32-unknown-elf-ld"
54 // CXX-RV32-BAREMETAL-ILP32: "--sysroot={{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf"
55 // CXX-RV32-BAREMETAL-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf/lib{{/|\\\\}}crt0.o"
56 // CXX-RV32-BAREMETAL-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtbegin.o"
57 // CXX-RV32-BAREMETAL-ILP32: "-L{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1"
58 // CXX-RV32-BAREMETAL-ILP32: "-L{{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf/lib"
59 // CXX-RV32-BAREMETAL-ILP32: "-lstdc++" "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
60 // CXX-RV32-BAREMETAL-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtend.o"
61 
62 // RUN: %clangxx %s -### -no-canonical-prefixes -fuse-ld= \
63 // RUN:   -target riscv32-unknown-elf -stdlib=libstdc++ --rtlib=platform \
64 // RUN:   --sysroot= \
65 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
66 // RUN:   | FileCheck -check-prefix=CXX-RV32-BAREMETAL-NOSYSROOT-ILP32 %s
67 
68 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "-internal-isystem" "{{.*}}Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}riscv32-unknown-elf/include/c++{{/|\\\\}}8.0.1"
69 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}riscv32-unknown-elf-ld"
70 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}riscv32-unknown-elf/lib{{/|\\\\}}crt0.o"
71 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtbegin.o"
72 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "-L{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1"
73 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "-L{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../..{{/|\\\\}}..{{/|\\\\}}riscv32-unknown-elf/lib"
74 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "-lstdc++" "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
75 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtend.o"
76 
77 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
78 // RUN:   -target riscv32-unknown-linux-gnu --rtlib=platform -mabi=ilp32 \
79 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
80 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
81 // RUN:   | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32 %s
82 
83 // C-RV32-LINUX-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-linux-gnu/bin{{/|\\\\}}ld"
84 // C-RV32-LINUX-MULTI-ILP32: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
85 // C-RV32-LINUX-MULTI-ILP32: "-m" "elf32lriscv"
86 // C-RV32-LINUX-MULTI-ILP32: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32.so.1"
87 // C-RV32-LINUX-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32{{/|\\\\}}crtbegin.o"
88 // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32"
89 // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32"
90 // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32"
91 
92 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
93 // RUN:   -target riscv32-unknown-linux-gnu --rtlib=platform -march=rv32imafd \
94 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
95 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
96 // RUN:   | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32D %s
97 
98 // C-RV32-LINUX-MULTI-ILP32D: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-linux-gnu/bin{{/|\\\\}}ld"
99 // C-RV32-LINUX-MULTI-ILP32D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
100 // C-RV32-LINUX-MULTI-ILP32D: "-m" "elf32lriscv"
101 // C-RV32-LINUX-MULTI-ILP32D: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32d.so.1"
102 // C-RV32-LINUX-MULTI-ILP32D: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32d{{/|\\\\}}crtbegin.o"
103 // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32d"
104 // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32d"
105 // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32d"
106 
107 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
108 // RUN:   -target riscv32-unknown-elf --rtlib=platform --sysroot= \
109 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
110 // RUN:   | FileCheck -check-prefix=C-RV32I-BAREMETAL-MULTI-ILP32 %s
111 
112 // C-RV32I-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/bin{{/|\\\\}}ld"
113 // C-RV32I-BAREMETAL-MULTI-ILP32: "-m" "elf32lriscv"
114 // C-RV32I-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib/rv32imac/ilp32{{/|\\\\}}crt0.o"
115 // C-RV32I-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imac/ilp32{{/|\\\\}}crtbegin.o"
116 // C-RV32I-BAREMETAL-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0"
117 // C-RV32I-BAREMETAL-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib"
118 // C-RV32I-BAREMETAL-MULTI-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
119 // C-RV32I-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imac/ilp32{{/|\\\\}}crtend.o"
120 
121 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
122 // RUN:   -target riscv32-unknown-elf --rtlib=platform --sysroot= \
123 // RUN:   -march=rv32im -mabi=ilp32\
124 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
125 // RUN:   | FileCheck -check-prefix=C-RV32IM-BAREMETAL-MULTI-ILP32 %s
126 
127 // C-RV32IM-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/bin{{/|\\\\}}ld"
128 // C-RV32IM-BAREMETAL-MULTI-ILP32: "-m" "elf32lriscv"
129 // C-RV32IM-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib/rv32im/ilp32{{/|\\\\}}crt0.o"
130 // C-RV32IM-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32im/ilp32{{/|\\\\}}crtbegin.o"
131 // C-RV32IM-BAREMETAL-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0"
132 // C-RV32IM-BAREMETAL-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib"
133 // C-RV32IM-BAREMETAL-MULTI-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
134 // C-RV32IM-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32im/ilp32{{/|\\\\}}crtend.o"
135 
136 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
137 // RUN:   -target riscv32-unknown-elf --rtlib=platform --sysroot= \
138 // RUN:   -march=rv32iac -mabi=ilp32\
139 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
140 // RUN:   | FileCheck -check-prefix=C-RV32IAC-BAREMETAL-MULTI-ILP32 %s
141 
142 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/bin{{/|\\\\}}ld"
143 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "-m" "elf32lriscv"
144 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib/rv32iac/ilp32{{/|\\\\}}crt0.o"
145 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32iac/ilp32{{/|\\\\}}crtbegin.o"
146 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0"
147 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib"
148 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
149 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32iac/ilp32{{/|\\\\}}crtend.o"
150 
151 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
152 // RUN:   -target riscv32-unknown-elf --rtlib=platform --sysroot= \
153 // RUN:   -march=rv32imac -mabi=ilp32\
154 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
155 // RUN:   | FileCheck -check-prefix=C-RV32IMAC-BAREMETAL-MULTI-ILP32 %s
156 
157 // C-RV32IMAC-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/bin{{/|\\\\}}ld"
158 // C-RV32IMAC-BAREMETAL-MULTI-ILP32: "-m" "elf32lriscv"
159 // C-RV32IMAC-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib/rv32imac/ilp32{{/|\\\\}}crt0.o"
160 // C-RV32IMAC-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imac/ilp32{{/|\\\\}}crtbegin.o"
161 // C-RV32IMAC-BAREMETAL-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0"
162 // C-RV32IMAC-BAREMETAL-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib"
163 // C-RV32IMAC-BAREMETAL-MULTI-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
164 // C-RV32IMAC-BAREMETAL-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imac/ilp32{{/|\\\\}}crtend.o"
165 
166 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
167 // RUN:   -target riscv32-unknown-elf --rtlib=platform --sysroot= \
168 // RUN:   -march=rv32imafc -mabi=ilp32f \
169 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
170 // RUN:   | FileCheck -check-prefix=C-RV32IMAFC-BAREMETAL-MULTI-ILP32F %s
171 
172 // C-RV32IMAFC-BAREMETAL-MULTI-ILP32F: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/bin{{/|\\\\}}ld"
173 // C-RV32IMAFC-BAREMETAL-MULTI-ILP32F: "-m" "elf32lriscv"
174 // C-RV32IMAFC-BAREMETAL-MULTI-ILP32F: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib/rv32imafc/ilp32f{{/|\\\\}}crt0.o"
175 // C-RV32IMAFC-BAREMETAL-MULTI-ILP32F: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imafc/ilp32f{{/|\\\\}}crtbegin.o"
176 // C-RV32IMAFC-BAREMETAL-MULTI-ILP32F: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0"
177 // C-RV32IMAFC-BAREMETAL-MULTI-ILP32F: "-L{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/../../..{{/|\\\\}}..{{/|\\\\}}riscv64-unknown-elf/lib"
178 // C-RV32IMAFC-BAREMETAL-MULTI-ILP32F: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
179 // C-RV32IMAFC-BAREMETAL-MULTI-ILP32F: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imafc/ilp32f{{/|\\\\}}crtend.o"
180 
181 // Check that --rtlib can be used to override the used runtime library
182 // RUN: %clang %s -### -no-canonical-prefixes \
183 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
184 // RUN:   -target riscv32-unknown-elf --rtlib=libgcc 2>&1 \
185 // RUN:   | FileCheck -check-prefix=C-RV32-RTLIB-LIBGCC-ILP32 %s
186 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crt0.o"
187 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crtbegin.o"
188 // C-RV32-RTLIB-LIBGCC-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
189 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crtend.o"
190 
191 // RUN: %clang %s -### -no-canonical-prefixes \
192 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
193 // RUN:   -target riscv32-unknown-elf --rtlib=compiler-rt 2>&1 \
194 // RUN:   | FileCheck -check-prefix=C-RV32-RTLIB-COMPILERRT-ILP32 %s
195 // C-RV32-RTLIB-COMPILERRT-ILP32: "{{.*}}crt0.o"
196 // C-RV32-RTLIB-COMPILERRT-ILP32: "{{.*}}clang_rt.crtbegin-riscv32.o"
197 // C-RV32-RTLIB-COMPILERRT-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" "{{.*}}libclang_rt.builtins-riscv32.a"
198 // C-RV32-RTLIB-COMPILERRT-ILP32: "{{.*}}clang_rt.crtend-riscv32.o"
199 
200 // RUN: %clang -target riscv32 %s -emit-llvm -S -o - | FileCheck %s
201 
202 typedef __builtin_va_list va_list;
203 typedef __SIZE_TYPE__ size_t;
204 typedef __PTRDIFF_TYPE__ ptrdiff_t;
205 typedef __WCHAR_TYPE__ wchar_t;
206 typedef __WINT_TYPE__ wint_t;
207 
208 
209 // Check Alignments
210 
211 // CHECK: @align_c = dso_local global i32 1
212 int align_c = __alignof(char);
213 
214 // CHECK: @align_s = dso_local global i32 2
215 int align_s = __alignof(short);
216 
217 // CHECK: @align_i = dso_local global i32 4
218 int align_i = __alignof(int);
219 
220 // CHECK: @align_wc = dso_local global i32 4
221 int align_wc = __alignof(wchar_t);
222 
223 // CHECK: @align_wi = dso_local global i32 4
224 int align_wi = __alignof(wint_t);
225 
226 // CHECK: @align_l = dso_local global i32 4
227 int align_l = __alignof(long);
228 
229 // CHECK: @align_ll = dso_local global i32 8
230 int align_ll = __alignof(long long);
231 
232 // CHECK: @align_p = dso_local global i32 4
233 int align_p = __alignof(void*);
234 
235 // CHECK: @align_f = dso_local global i32 4
236 int align_f = __alignof(float);
237 
238 // CHECK: @align_d = dso_local global i32 8
239 int align_d = __alignof(double);
240 
241 // CHECK: @align_ld = dso_local global i32 16
242 int align_ld = __alignof(long double);
243 
244 // CHECK: @align_vl = dso_local global i32 4
245 int align_vl = __alignof(va_list);
246 
247 // CHECK: @align_a_c = dso_local global i32 1
248 int align_a_c = __alignof(_Atomic(char));
249 
250 // CHECK: @align_a_s = dso_local global i32 2
251 int align_a_s = __alignof(_Atomic(short));
252 
253 // CHECK: @align_a_i = dso_local global i32 4
254 int align_a_i = __alignof(_Atomic(int));
255 
256 // CHECK: @align_a_wc = dso_local global i32 4
257 int align_a_wc = __alignof(_Atomic(wchar_t));
258 
259 // CHECK: @align_a_wi = dso_local global i32 4
260 int align_a_wi = __alignof(_Atomic(wint_t));
261 
262 // CHECK: @align_a_l = dso_local global i32 4
263 int align_a_l = __alignof(_Atomic(long));
264 
265 // CHECK: @align_a_ll = dso_local global i32 8
266 int align_a_ll = __alignof(_Atomic(long long));
267 
268 // CHECK: @align_a_p = dso_local global i32 4
269 int align_a_p = __alignof(_Atomic(void*));
270 
271 // CHECK: @align_a_f = dso_local global i32 4
272 int align_a_f = __alignof(_Atomic(float));
273 
274 // CHECK: @align_a_d = dso_local global i32 8
275 int align_a_d = __alignof(_Atomic(double));
276 
277 // CHECK: @align_a_ld = dso_local global i32 16
278 int align_a_ld = __alignof(_Atomic(long double));
279 
280 // CHECK: @align_a_s4 = dso_local global i32 4
281 int align_a_s4 = __alignof(_Atomic(struct { char s[4]; }));
282 
283 // CHECK: @align_a_s8 = dso_local global i32 8
284 int align_a_s8 = __alignof(_Atomic(struct { char s[8]; }));
285 
286 // CHECK: @align_a_s16 = dso_local global i32 16
287 int align_a_s16 = __alignof(_Atomic(struct { char s[16]; }));
288 
289 // CHECK: @align_a_s32 = dso_local global i32 1
290 int align_a_s32 = __alignof(_Atomic(struct { char s[32]; }));
291 
292 
293 // Check Sizes
294 
295 // CHECK: @size_a_c = dso_local global i32 1
296 int size_a_c = sizeof(_Atomic(char));
297 
298 // CHECK: @size_a_s = dso_local global i32 2
299 int size_a_s = sizeof(_Atomic(short));
300 
301 // CHECK: @size_a_i = dso_local global i32 4
302 int size_a_i = sizeof(_Atomic(int));
303 
304 // CHECK: @size_a_wc = dso_local global i32 4
305 int size_a_wc = sizeof(_Atomic(wchar_t));
306 
307 // CHECK: @size_a_wi = dso_local global i32 4
308 int size_a_wi = sizeof(_Atomic(wint_t));
309 
310 // CHECK: @size_a_l = dso_local global i32 4
311 int size_a_l = sizeof(_Atomic(long));
312 
313 // CHECK: @size_a_ll = dso_local global i32 8
314 int size_a_ll = sizeof(_Atomic(long long));
315 
316 // CHECK: @size_a_p = dso_local global i32 4
317 int size_a_p = sizeof(_Atomic(void*));
318 
319 // CHECK: @size_a_f = dso_local global i32 4
320 int size_a_f = sizeof(_Atomic(float));
321 
322 // CHECK: @size_a_d = dso_local global i32 8
323 int size_a_d = sizeof(_Atomic(double));
324 
325 // CHECK: @size_a_ld = dso_local global i32 16
326 int size_a_ld = sizeof(_Atomic(long double));
327 
328 
329 // Check types
330 
331 // CHECK: zeroext i8 @check_char()
check_char()332 char check_char() { return 0; }
333 
334 // CHECK: define dso_local signext i16 @check_short()
check_short()335 short check_short() { return 0; }
336 
337 // CHECK: define dso_local i32 @check_int()
check_int()338 int check_int() { return 0; }
339 
340 // CHECK: define dso_local i32 @check_wchar_t()
check_wchar_t()341 int check_wchar_t() { return 0; }
342 
343 // CHECK: define dso_local i32 @check_long()
check_long()344 long check_long() { return 0; }
345 
346 // CHECK: define dso_local i64 @check_longlong()
check_longlong()347 long long check_longlong() { return 0; }
348 
349 // CHECK: define dso_local zeroext i8 @check_uchar()
check_uchar()350 unsigned char check_uchar() { return 0; }
351 
352 // CHECK: define dso_local zeroext i16 @check_ushort()
check_ushort()353 unsigned short check_ushort() { return 0; }
354 
355 // CHECK: define dso_local i32 @check_uint()
check_uint()356 unsigned int check_uint() { return 0; }
357 
358 // CHECK: define dso_local i32 @check_ulong()
check_ulong()359 unsigned long check_ulong() { return 0; }
360 
361 // CHECK: define dso_local i64 @check_ulonglong()
check_ulonglong()362 unsigned long long check_ulonglong() { return 0; }
363 
364 // CHECK: define dso_local i32 @check_size_t()
check_size_t()365 size_t check_size_t() { return 0; }
366 
367 // CHECK: define dso_local float @check_float()
check_float()368 float check_float() { return 0; }
369 
370 // CHECK: define dso_local double @check_double()
check_double()371 double check_double() { return 0; }
372 
373 // CHECK: define dso_local fp128 @check_longdouble()
check_longdouble()374 long double check_longdouble() { return 0; }
375