]>
Commit | Line | Data |
---|---|---|
2038f8c8 PB |
1 | #! /bin/sh |
2 | ||
3 | if test -z "$source_path"; then | |
4 | echo Do not invoke this script directly. It is called | |
5 | echo automatically by configure. | |
6 | exit 1 | |
7 | fi | |
8 | ||
9 | write_c_skeleton() { | |
10 | cat > $TMPC <<EOF | |
11 | int main(void) { return 0; } | |
12 | EOF | |
13 | } | |
14 | ||
15 | has() { | |
16 | command -v "$1" >/dev/null 2>&1 | |
17 | } | |
18 | ||
19 | do_compiler() { | |
20 | # Run the compiler, capturing its output to the log. First argument | |
21 | # is compiler binary to execute. | |
22 | local compiler="$1" | |
23 | shift | |
24 | if test -n "$BASH_VERSION"; then eval ' | |
25 | echo >>config.log " | |
26 | funcs: ${FUNCNAME[*]} | |
27 | lines: ${BASH_LINENO[*]}" | |
28 | '; fi | |
29 | echo $compiler "$@" >> config.log | |
30 | $compiler "$@" >> config.log 2>&1 || return $? | |
31 | } | |
32 | ||
33 | ||
34 | TMPDIR1="config-temp" | |
35 | TMPC="${TMPDIR1}/qemu-conf.c" | |
36 | TMPE="${TMPDIR1}/qemu-conf.exe" | |
37 | ||
38 | container="no" | |
afc3a8f9 AB |
39 | if test $use_containers = "yes"; then |
40 | if has "docker" || has "podman"; then | |
41 | container=$($python $source_path/tests/docker/docker.py probe) | |
42 | fi | |
2038f8c8 PB |
43 | fi |
44 | ||
45 | # cross compilers defaults, can be overridden with --cross-cc-ARCH | |
46 | : ${cross_cc_aarch64="aarch64-linux-gnu-gcc"} | |
47 | : ${cross_cc_aarch64_be="$cross_cc_aarch64"} | |
48 | : ${cross_cc_cflags_aarch64_be="-mbig-endian"} | |
634ef789 | 49 | : $(cross_cc_alpha="alpha-linux-gnu-gcc") |
2038f8c8 PB |
50 | : ${cross_cc_arm="arm-linux-gnueabihf-gcc"} |
51 | : ${cross_cc_cflags_armeb="-mbig-endian"} | |
634ef789 | 52 | : ${cross_cc_hppa="hppa-linux-gnu-gcc"} |
2038f8c8 PB |
53 | : ${cross_cc_i386="i386-pc-linux-gnu-gcc"} |
54 | : ${cross_cc_cflags_i386="-m32"} | |
634ef789 AB |
55 | : ${cross_cc_m68k="m68k-linux-gnu-gcc"} |
56 | : $(cross_cc_mips64el="mips64el-linux-gnuabi64-gcc") | |
57 | : $(cross_cc_mips64="mips64-linux-gnuabi64-gcc") | |
58 | : $(cross_cc_mipsel="mipsel-linux-gnu-gcc") | |
59 | : $(cross_cc_mips="mips-linux-gnu-gcc") | |
2038f8c8 PB |
60 | : ${cross_cc_ppc="powerpc-linux-gnu-gcc"} |
61 | : ${cross_cc_cflags_ppc="-m32"} | |
634ef789 | 62 | : ${cross_cc_ppc64="powerpc64-linux-gnu-gcc"} |
2038f8c8 | 63 | : ${cross_cc_ppc64le="powerpc64le-linux-gnu-gcc"} |
634ef789 AB |
64 | : $(cross_cc_riscv64="riscv64-linux-gnu-gcc") |
65 | : ${cross_cc_s390x="s390x-linux-gnu-gcc"} | |
66 | : $(cross_cc_sh4="sh4-linux-gnu-gcc") | |
2038f8c8 | 67 | : ${cross_cc_cflags_sparc="-m32 -mv8plus -mcpu=ultrasparc"} |
634ef789 | 68 | : ${cross_cc_sparc64="sparc64-linux-gnu-gcc"} |
2038f8c8 | 69 | : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"} |
634ef789 AB |
70 | : ${cross_cc_x86_64="x86_64-pc-linux-gnu-gcc"} |
71 | : ${cross_cc_cflags_x86_64="-m64"} | |
2038f8c8 PB |
72 | |
73 | for target in $target_list; do | |
74 | arch=${target%%-*} | |
75 | case $arch in | |
76 | arm|armeb) | |
77 | arches=arm | |
78 | ;; | |
79 | aarch64|aarch64_be) | |
80 | arches="aarch64 arm" | |
81 | ;; | |
82 | mips*) | |
83 | arches=mips | |
84 | ;; | |
85 | ppc*) | |
86 | arches=ppc | |
87 | ;; | |
88 | sh4|sh4eb) | |
89 | arches=sh4 | |
90 | ;; | |
91 | x86_64) | |
92 | arches="x86_64 i386" | |
93 | ;; | |
94 | xtensa|xtensaeb) | |
95 | arches=xtensa | |
96 | ;; | |
cdc05fb4 | 97 | alpha|cris|hppa|i386|lm32|microblaze|microblazeel|m68k|openrisc|riscv64|s390x|sh4|sparc64) |
2038f8c8 PB |
98 | arches=$target |
99 | ;; | |
100 | *) | |
101 | continue | |
102 | ;; | |
103 | esac | |
104 | ||
105 | container_image= | |
106 | case $target in | |
107 | aarch64-*) | |
108 | # We don't have any bigendian build tools so we only use this for AArch64 | |
c729a99d AB |
109 | container_image=debian-arm64-test-cross |
110 | container_cross_cc=aarch64-linux-gnu-gcc-10 | |
2038f8c8 PB |
111 | ;; |
112 | alpha-*) | |
113 | container_image=debian-alpha-cross | |
114 | container_cross_cc=alpha-linux-gnu-gcc | |
115 | ;; | |
116 | arm-*) | |
117 | # We don't have any bigendian build tools so we only use this for ARM | |
118 | container_image=debian-armhf-cross | |
119 | container_cross_cc=arm-linux-gnueabihf-gcc | |
120 | ;; | |
121 | cris-*) | |
122 | container_image=fedora-cris-cross | |
123 | container_cross_cc=cris-linux-gnu-gcc | |
124 | ;; | |
125 | hppa-*) | |
126 | container_image=debian-hppa-cross | |
127 | container_cross_cc=hppa-linux-gnu-gcc | |
128 | ;; | |
129 | i386-*) | |
130 | container_image=fedora-i386-cross | |
131 | container_cross_cc=gcc | |
132 | ;; | |
133 | m68k-*) | |
134 | container_image=debian-m68k-cross | |
135 | container_cross_cc=m68k-linux-gnu-gcc | |
136 | ;; | |
137 | mips64el-*) | |
138 | container_image=debian-mips64el-cross | |
139 | container_cross_cc=mips64el-linux-gnuabi64-gcc | |
140 | ;; | |
141 | mips64-*) | |
142 | container_image=debian-mips64-cross | |
143 | container_cross_cc=mips64-linux-gnuabi64-gcc | |
144 | ;; | |
145 | mipsel-*) | |
146 | container_image=debian-mipsel-cross | |
147 | container_cross_cc=mipsel-linux-gnu-gcc | |
148 | ;; | |
149 | mips-*) | |
150 | container_image=debian-mips-cross | |
151 | container_cross_cc=mips-linux-gnu-gcc | |
152 | ;; | |
153 | ppc-*|ppc64abi32-*) | |
154 | container_image=debian-powerpc-cross | |
155 | container_cross_cc=powerpc-linux-gnu-gcc | |
156 | ;; | |
157 | ppc64-*) | |
158 | container_image=debian-ppc64-cross | |
159 | container_cross_cc=powerpc64-linux-gnu-gcc | |
160 | ;; | |
161 | ppc64le-*) | |
162 | container_image=debian-ppc64el-cross | |
163 | container_cross_cc=powerpc64le-linux-gnu-gcc | |
164 | ;; | |
165 | riscv64-*) | |
166 | container_image=debian-riscv64-cross | |
167 | container_cross_cc=riscv64-linux-gnu-gcc | |
168 | ;; | |
169 | s390x-*) | |
170 | container_image=debian-s390x-cross | |
171 | container_cross_cc=s390x-linux-gnu-gcc | |
172 | ;; | |
173 | sh4-*) | |
174 | container_image=debian-sh4-cross | |
175 | container_cross_cc=sh4-linux-gnu-gcc | |
176 | ;; | |
177 | sparc64-*) | |
178 | container_image=debian-sparc64-cross | |
179 | container_cross_cc=sparc64-linux-gnu-gcc | |
180 | ;; | |
181 | xtensa*-softmmu) | |
182 | container_image=debian-xtensa-cross | |
183 | ||
184 | # default to the dc232b cpu | |
bf7801df | 185 | container_cross_cc=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-gcc |
2038f8c8 PB |
186 | ;; |
187 | esac | |
188 | ||
189 | config_target_mak=tests/tcg/config-$target.mak | |
190 | ||
191 | echo "# Automatically generated by configure - do not modify" > $config_target_mak | |
192 | echo "TARGET_NAME=$arch" >> $config_target_mak | |
193 | case $target in | |
194 | *-linux-user | *-bsd-user) | |
195 | echo "CONFIG_USER_ONLY=y" >> $config_target_mak | |
64ed6f92 | 196 | echo "QEMU=\$(BUILD_DIR)/qemu-$arch" >> $config_target_mak |
2038f8c8 PB |
197 | ;; |
198 | *-softmmu) | |
199 | echo "CONFIG_SOFTMMU=y" >> $config_target_mak | |
64ed6f92 | 200 | echo "QEMU=\$(BUILD_DIR)/qemu-system-$arch" >> $config_target_mak |
2038f8c8 PB |
201 | ;; |
202 | esac | |
203 | ||
204 | eval "target_compiler_cflags=\${cross_cc_cflags_$arch}" | |
205 | echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak | |
206 | ||
207 | got_cross_cc=no | |
208 | for i in $arch $arches; do | |
209 | if eval test "x\${cross_cc_$i+yes}" != xyes; then | |
210 | continue | |
211 | fi | |
212 | ||
213 | eval "target_compiler=\${cross_cc_$i}" | |
214 | if ! has $target_compiler; then | |
215 | continue | |
216 | fi | |
217 | write_c_skeleton | |
218 | if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then | |
219 | # For host systems we might get away with building without -static | |
220 | if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then | |
221 | continue | |
222 | fi | |
223 | echo "CROSS_CC_GUEST_STATIC=y" >> $config_target_mak | |
224 | else | |
225 | echo "CROSS_CC_GUEST_STATIC=y" >> $config_target_mak | |
226 | fi | |
227 | echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak | |
ded663a2 AB |
228 | |
229 | # Test for compiler features for optional tests. We only do this | |
230 | # for cross compilers because ensuring the docker containers based | |
231 | # compilers is a requirememt for adding a new test that needs a | |
232 | # compiler feature. | |
233 | case $target in | |
234 | aarch64-*) | |
235 | if do_compiler "$target_compiler" $target_compiler_cflags \ | |
236 | -march=armv8.1-a+sve -o $TMPE $TMPC; then | |
237 | echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak | |
238 | fi | |
bb516dfc | 239 | if do_compiler "$target_compiler" $target_compiler_cflags \ |
a62f849d | 240 | -march=armv8.3-a -o $TMPE $TMPC; then |
bb516dfc AB |
241 | echo "CROSS_CC_HAS_ARMV8_3=y" >> $config_target_mak |
242 | fi | |
ded663a2 AB |
243 | ;; |
244 | esac | |
245 | ||
2038f8c8 PB |
246 | enabled_cross_compilers="$enabled_cross_compilers $target_compiler" |
247 | got_cross_cc=yes | |
248 | break | |
249 | done | |
250 | ||
251 | if test $got_cross_cc = no && test "$container" != no && test -n "$container_image"; then | |
252 | echo "DOCKER_IMAGE=$container_image" >> $config_target_mak | |
253 | echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak | |
254 | fi | |
255 | done | |
256 | ||
257 | # report container support state | |
258 | echo "cross containers $container" | |
259 | ||
260 | if test -n "$enabled_cross_compilers"; then | |
261 | echo | |
262 | echo "NOTE: guest cross-compilers enabled:$enabled_cross_compilers" | |
263 | fi |