configure: Fail when specified cross compiler cannot be found
PATCH 1/1 configure: Fail when specified cross compiler cannot be found
Currently if the cross compiler passed to 'configure' (--cross-cc-<arch>) does not exist no error happens and only later when the TCG tests are run they fail because the cross compiler is not set correctly.
This commit changes that behavior and make 'configure' fail if the specified cross compiler cannot be found, displaying an error similar to the following:
$ ../configure --target-list=ppc64-softmmu --cross-cc-ppc64=nonexisting_gcc Specified cross-compiler 'nonexisting_gcc' not found!
--- configure | 2 +- tests/tcg/configure.sh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
configure +1 -1
@@ -6854,7 +6854,7 @@ done export $i done export target_list source_path use_containers -$source_path/tests/tcg/configure.sh) +$source_path/tests/tcg/configure.sh) || exit 1 # temporary config to build submodules for rom in seabios; do
tests/tcg/configure.sh +3 -1
@@ -212,8 +212,10 @@ for target in $target_list; do eval "target_compiler=\${cross_cc_$i}" if ! has $target_compiler; then - continue + echo "Specified cross-compiler '$target_compiler' not found!" + exit 1 fi + write_c_skeleton if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then # For host systems we might get away with building without -static
Signature · 1 line
2.17.1
Quoted 3 lines · Gustavo Romero
Currently if the cross compiler passed to 'configure' (--cross-cc-<arch>) does not exist no error happens and only later when the TCG tests are run they fail because the cross compiler is not set correctly.
Do they? They should just skip because of a non-existing compiler and a failed fallback to using docker:
../../configure --disable-docs --target-list=aarch64-softmmu --cross-cc-aarch64=nonexisting_gcc
and then cat ./tests/tcg/config-aarch64-softmmu.mak
# Automatically generated by configure - do not modify TARGET_NAME=aarch64
CONFIG_SOFTMMU=y QEMU=/home/alex/lsrc/qemu.git/builds/bisect/qemu-system-aarch64 CROSS_CC_GUEST_CFLAGS= DOCKER_IMAGE=debian-arm64-test-cross DOCKER_CROSS_CC_GUEST=aarch64-linux-gnu-gcc-10
So what do you see in your failing case?
Quoted 42 lines
This commit changes that behavior and make 'configure' fail if the specified cross compiler cannot be found, displaying an error similar to the following:
$ ../configure --target-list=ppc64-softmmu --cross-cc-ppc64=nonexisting_gcc Specified cross-compiler 'nonexisting_gcc' not found!Signed-off-by Gustavo Romero <[email protected]>--- configure | 2 +- tests/tcg/configure.sh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)configure +1
-1@@ -6854,7 +6854,7 @@ done export $i done export target_list source_path use_containers -$source_path/tests/tcg/configure.sh) +$source_path/tests/tcg/configure.sh) || exit 1 # temporary config to build submodules for rom in seabios; dotests/tcg/configure.sh +3
-1@@ -212,8 +212,10 @@ for target in $target_list; do eval "target_compiler=\${cross_cc_$i}" if ! has $target_compiler; then - continue + echo "Specified cross-compiler '$target_compiler' not found!" + exit 1 fi + write_c_skeleton if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then # For host systems we might get away with building without -static
Signature · 1 line
Alex Bennée
Hi Alex,
Quoted 22 lines · Alex Bennée
Quoted 3 lines · Gustavo Romero
Currently if the cross compiler passed to 'configure' (--cross-cc-<arch>) does not exist no error happens and only later when the TCG tests are run they fail because the cross compiler is not set correctly.
Do they? They should just skip because of a non-existing compiler and a failed fallback to using docker:
../../configure --disable-docs --target-list=aarch64-softmmu --cross-cc-aarch64=nonexisting_gccand then cat ./tests/tcg/config-aarch64-softmmu.mak
# Automatically generated by configure - do not modify TARGET_NAME=aarch64
CONFIG_SOFTMMU=yQEMU=/home/alex/lsrc/qemu.git/builds/bisect/qemu-system-aarch64 CROSS_CC_GUEST_CFLAGS= DOCKER_IMAGE=debian-arm64-test-cross DOCKER_CROSS_CC_GUEST=aarch64-linux-gnu-gcc-10
Quoted 1 line
So what do you see in your failing case?
I get the following (I don't have docker installed):
$ ../configure --disable-docs --target-list=aarch64-softmmu --cross-cc-aarch64=nonexisting_gcc gromero@pub:~/git/qemu/build$ cat ./tests/tcg/config-aarch64-softmmu.mak # Automatically generated by configure - do not modify TARGET_NAME=aarch64 CONFIG_SOFTMMU=y QEMU=/home/gromero/git/qemu/build/qemu-system-aarch64 CROSS_CC_GUEST_CFLAGS=
$ ../configure --disable-docs --target-list=ppc64-softmmu --cross-cc-ppc64=nonexisting_gcc gromero@pub:~/git/qemu/build$ cat ./tests/tcg/config-ppc64-softmmu.mak # Automatically generated by configure - do not modify TARGET_NAME=ppc64 CONFIG_SOFTMMU=y QEMU=/home/gromero/git/qemu/build/qemu-system-ppc64 CROSS_CC_GUEST_CFLAGS= CROSS_CC_GUEST_STATIC=y CROSS_CC_GUEST=powerpc-linux-gnu-gcc
hrm It seems PPC64 is even assuming some default gcc...
I'm at commit af3f37319c from Dec 15.
I'm wondering if tha happens because I don't have docker package installed.
Anyway, should we at least say we're using Docker as fallback?
Cheers,
Gustavo
Quoted 37 lines · Gustavo Romero
Hi Alex,
Quoted 22 lines · Alex Bennée
Quoted 3 lines · Gustavo Romero
Currently if the cross compiler passed to 'configure' (--cross-cc-<arch>) does not exist no error happens and only later when the TCG tests are run they fail because the cross compiler is not set correctly.
Do they? They should just skip because of a non-existing compiler and a failed fallback to using docker:
../../configure --disable-docs --target-list=aarch64-softmmu --cross-cc-aarch64=nonexisting_gccand then cat ./tests/tcg/config-aarch64-softmmu.mak
# Automatically generated by configure - do not modify TARGET_NAME=aarch64
CONFIG_SOFTMMU=yQEMU=/home/alex/lsrc/qemu.git/builds/bisect/qemu-system-aarch64 CROSS_CC_GUEST_CFLAGS= DOCKER_IMAGE=debian-arm64-test-cross DOCKER_CROSS_CC_GUEST=aarch64-linux-gnu-gcc-10Quoted 1 line
So what do you see in your failing case?
I get the following (I don't have docker installed):
$ ../configure --disable-docs --target-list=aarch64-softmmu --cross-cc-aarch64=nonexisting_gcc gromero@pub:~/git/qemu/build$ cat ./tests/tcg/config-aarch64-softmmu.mak # Automatically generated by configure - do not modify TARGET_NAME=aarch64 CONFIG_SOFTMMU=y QEMU=/home/gromero/git/qemu/build/qemu-system-aarch64 CROSS_CC_GUEST_CFLAGS=
Quoted 9 lines
$ ../configure --disable-docs --target-list=ppc64-softmmu --cross-cc-ppc64=nonexisting_gcc gromero@pub:~/git/qemu/build$ cat ./tests/tcg/config-ppc64-softmmu.mak # Automatically generated by configure - do not modify TARGET_NAME=ppc64 CONFIG_SOFTMMU=y QEMU=/home/gromero/git/qemu/build/qemu-system-ppc64 CROSS_CC_GUEST_CFLAGS= CROSS_CC_GUEST_STATIC=y CROSS_CC_GUEST=powerpc-linux-gnu-gcc
Hmm that is impressively wrong to somehow get the 32 bit compiler. But I'm still failing to replicate the problem. Could you try the following configure for a like-for-like comparison:
../../configure --disable-containers --target-list=ppc64-softmmu --cross-cc-ppc64=nonexisting_gcc
which gives me:
$ cat tests/tcg/config-ppc64-softmmu.mak # Automatically generated by configure - do not modify TARGET_NAME=ppc64 CONFIG_SOFTMMU=y QEMU=/home/alex/lsrc/qemu.git/builds/ppc-linux.all/qemu-system-ppc64 CROSS_CC_GUEST_CFLAGS=
Quoted 4 lines
hrm It seems PPC64 is even assuming some default gcc...
I'm at commit
af3f37319cfrom Dec 15.
Yep I'm based on that as well.
Quoted 3 lines
I'm wondering if tha happens because I don't have docker package installed.
Anyway, should we at least say we're using Docker as fallback?
Something like:
modified tests/tcg/configure.sh
@@ -255,6 +255,7 @@ for target in $target_list; do
if test $got_cross_cc = no && test "$container" != no && test -n "$container_image"; then
echo "DOCKER_IMAGE=$container_image" >> $config_target_mak
echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak
+ enabled_container_compilers="$enabled_container_compilers $container_cross_cc"
fi
done
@@ -265,3 +266,6 @@ if test -n "$enabled_cross_compilers"; then
echo
echo "NOTE: guest cross-compilers enabled:$enabled_cross_compilers"
fi
+if test -n "$enabled_container_compilers"; then
+ echo "NOTE: container cross-compilers enabled:$enabled_container_compilers"
+fi
To be honest at the moment the information is a little hidden at the top of the output. It would be nice if we could teach meson to echo it in it's nice coloured output.
Paolo,
Any ideas for the cleanest way to do that?
Signature · 1 line
Alex Bennée
Quoted 7 lines · Alex Bennée
To be honest at the moment the information is a little hidden at the top of the output. It would be nice if we could teach meson to echo it in it's nice coloured output.
Paolo,
Any ideas for the cleanest way to do that?
The code in configure is pretty small:
(for i in $cross_cc_vars; do
export $i
done
export target_list source_path use_containers$source_path/tests/tcg/configure.sh)
configure would place the cross-cc variables (which are really just command line options) in a file, something like config-cross-cc.mak, and the Meson translation of the above would be
env = environment()
foreach k, v : keyval.load(meson.current_build_dir() / 'config-cross-cc.mak')
env.set(k, v)
endforeachenv.set('target_list', ','.join(target_dirs)) env.set('source_path', meson.source_root()) env.set('use_containers',
'CROSS_CC_CONTAINERS' in config_host ? 'yes' : 'no')message(run_command(files('tests/tcg/configure.sh'), env: env).stdout())
For a bit more polish, one could make tests/tcg/configure.sh print the result in keyval format, parse it back from meson as a dictionary with keyval.load(), and pass the result to summary().
Paolo
Quoted 32 lines · Paolo Bonzini
Quoted 7 lines · Alex Bennée
To be honest at the moment the information is a little hidden at the top of the output. It would be nice if we could teach meson to echo it in it's nice coloured output.
Paolo,
Any ideas for the cleanest way to do that?
The code in configure is pretty small:
(for i in $cross_cc_vars; do
export $i
done
exporttarget_listsource_pathuse_containers$source_path/tests/tcg/configure.sh)configure would place the cross-cc variables (which are really just command line options) in a file, something like config-cross-cc.mak, and the Meson translation of the above would be
env =
environment()
foreach k, v :keyval.load(meson.current_build_dir() / 'config-cross-cc.mak')
env.set(k, v)
endforeachenv.set('target_list', ','.join(target_dirs))env.set('source_path', meson.source_root())env.set('use_containers',
'CROSS_CC_CONTAINERS' inconfig_host? 'yes' : 'no')message(run_command(files('tests/tcg/configure.sh'), env: env).stdout())
Quoted 3 lines
For a bit more polish, one could make
tests/tcg/configure.shprint the result in keyval format, parse it back from meson as a dictionary withkeyval.load(), and pass the result tosummary().
Don't we already have this in the form of tests/tcg/config-$TARGET.mak? Shouldn't we just injest that into meson after configure.sh has run?
Quoted 2 lines
Paolo
Signature · 1 line
Alex Bennée
Quoted 35 lines · Alex Bennée
Quoted 32 lines · Paolo Bonzini
Quoted 7 lines · Alex Bennée
To be honest at the moment the information is a little hidden at the top of the output. It would be nice if we could teach meson to echo it in it's nice coloured output.
Paolo,
Any ideas for the cleanest way to do that?
The code in configure is pretty small:
(for i in $cross_cc_vars; do
export $i
done
exporttarget_listsource_pathuse_containers$source_path/tests/tcg/configure.sh)configure would place the cross-cc variables (which are really just command line options) in a file, something like config-cross-cc.mak, and the Meson translation of the above would be
env =
environment()
foreach k, v :keyval.load(meson.current_build_dir() / 'config-cross-cc.mak')env.set(k, v)endforeach
env.set('target_list', ','.join(target_dirs))env.set('source_path', meson.source_root())env.set('use_containers',
'CROSS_CC_CONTAINERS' inconfig_host? 'yes' : 'no')message(run_command(files('tests/tcg/configure.sh'), env: env).stdout())
Quoted 6 lines
Quoted 3 lines
For a bit more polish, one could make
tests/tcg/configure.shprint the result in keyval format, parse it back from meson as a dictionary withkeyval.load(), and pass the result tosummary().Don't we already have this in the form of tests/tcg/config-$TARGET.mak? Shouldn't we just injest that into meson after
configure.shhas run?
Yes, that's also a possibility I guess! We can also do both (use run_command, and then reread tests/tcg/config-$TARGET.mak). Long term, I'd like to run tests/tcg/configure.sh separately for each target so that we can reuse it for pc-bios.
Paolo