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