qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] configure: Fail when specified cross compiler cannot be found
@ 2020-12-16  1:36 Gustavo Romero
  2020-12-16 10:51 ` Alex Bennée
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Romero @ 2020-12-16  1:36 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc; +Cc: gustavo.romero, gromero, alex.bennee, david

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!

Signed-off-by: Gustavo Romero <gromero@linux.ibm.com>
---
 configure              | 2 +-
 tests/tcg/configure.sh | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index cb21108d34..c0389f5839 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh
index e1b70e25f2..6c89d75c38 100755
--- a/tests/tcg/configure.sh
+++ b/tests/tcg/configure.sh
@@ -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
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fail when specified cross compiler cannot be found
  2020-12-16  1:36 [PATCH] configure: Fail when specified cross compiler cannot be found Gustavo Romero
@ 2020-12-16 10:51 ` Alex Bennée
  2020-12-17 16:55   ` Gustavo Romero
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Bennée @ 2020-12-16 10:51 UTC (permalink / raw)
  To: Gustavo Romero; +Cc: gustavo.romero, qemu-ppc, qemu-devel, david


Gustavo Romero <gromero@linux.ibm.com> writes:

> 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?

>
> 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 <gromero@linux.ibm.com>
> ---
>  configure              | 2 +-
>  tests/tcg/configure.sh | 4 +++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/configure b/configure
> index cb21108d34..c0389f5839 100755
> --- a/configure
> +++ b/configure
> @@ -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
> diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh
> index e1b70e25f2..6c89d75c38 100755
> --- a/tests/tcg/configure.sh
> +++ b/tests/tcg/configure.sh
> @@ -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


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fail when specified cross compiler cannot be found
  2020-12-16 10:51 ` Alex Bennée
@ 2020-12-17 16:55   ` Gustavo Romero
  2020-12-17 17:56     ` Alex Bennée
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Romero @ 2020-12-17 16:55 UTC (permalink / raw)
  To: Alex Bennée; +Cc: gustavo.romero, qemu-ppc, qemu-devel, david

Hi Alex,

On 12/16/20 7:51 AM, Alex Bennée wrote:
> 
> Gustavo Romero <gromero@linux.ibm.com> writes:
> 
>> 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?

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fail when specified cross compiler cannot be found
  2020-12-17 16:55   ` Gustavo Romero
@ 2020-12-17 17:56     ` Alex Bennée
  2020-12-18 10:05       ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Bennée @ 2020-12-17 17:56 UTC (permalink / raw)
  To: Gustavo Romero; +Cc: Pbonzini, gustavo.romero, qemu-ppc, qemu-devel, david


Gustavo Romero <gromero@linux.ibm.com> writes:

> Hi Alex,
>
> On 12/16/20 7:51 AM, Alex Bennée wrote:
>> 
>> Gustavo Romero <gromero@linux.ibm.com> writes:
>> 
>>> 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?
>
> 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

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=

>
> hrm It seems PPC64 is even assuming some default gcc...
>
> I'm at commit af3f37319c from Dec 15.

Yep I'm based on that as well.

> 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?

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fail when specified cross compiler cannot be found
  2020-12-17 17:56     ` Alex Bennée
@ 2020-12-18 10:05       ` Paolo Bonzini
  2020-12-18 11:57         ` Alex Bennée
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2020-12-18 10:05 UTC (permalink / raw)
  To: Alex Bennée, Gustavo Romero
  Cc: gustavo.romero, qemu-ppc, qemu-devel, david

On 17/12/20 18:56, Alex Bennée wrote:
> 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)
endforeach
env.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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fail when specified cross compiler cannot be found
  2020-12-18 10:05       ` Paolo Bonzini
@ 2020-12-18 11:57         ` Alex Bennée
  2020-12-19 12:11           ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Bennée @ 2020-12-18 11:57 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gustavo.romero, david, qemu-ppc, qemu-devel, Gustavo Romero


Paolo Bonzini <pbonzini@redhat.com> writes:

> On 17/12/20 18:56, Alex Bennée wrote:
>> 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)
> endforeach
> env.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().

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?

>
> Paolo


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fail when specified cross compiler cannot be found
  2020-12-18 11:57         ` Alex Bennée
@ 2020-12-19 12:11           ` Paolo Bonzini
  0 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2020-12-19 12:11 UTC (permalink / raw)
  To: Alex Bennée
  Cc: gustavo.romero, david, qemu-ppc, qemu-devel, Gustavo Romero

On 18/12/20 12:57, Alex Bennée wrote:
> 
> Paolo Bonzini <pbonzini@redhat.com> writes:
> 
>> On 17/12/20 18:56, Alex Bennée wrote:
>>> 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)
>> endforeach
>> env.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().
> 
> 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?

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-19 12:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16  1:36 [PATCH] configure: Fail when specified cross compiler cannot be found Gustavo Romero
2020-12-16 10:51 ` Alex Bennée
2020-12-17 16:55   ` Gustavo Romero
2020-12-17 17:56     ` Alex Bennée
2020-12-18 10:05       ` Paolo Bonzini
2020-12-18 11:57         ` Alex Bennée
2020-12-19 12:11           ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).