Message ID | 20220621075147.36297-3-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix support for biarch compilers and cross cflags | expand |
On 6/21/22 00:51, Paolo Bonzini wrote: > diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile > index ea89ce9d59..e90ca2e1c6 100644 > --- a/pc-bios/optionrom/Makefile > +++ b/pc-bios/optionrom/Makefile > @@ -11,7 +11,7 @@ CFLAGS = -O2 -g > quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) > cc-option = $(if $(shell $(CC) $1 -c -o /dev/null -xc /dev/null >/dev/null 2>&1 && echo OK), $1, $2) > > -override CFLAGS += -march=i486 -Wall -m16 > +override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16 Hmm. I'm not sure about this. Given that EXTRA_CFLAGS is going to be e.g. -m32 or empty, being immediately overwritten to -m16, I don't quite see the point. It seems like there should be a third cross-compiler "i386_m16" or something, with a different set of cflags at the configure level. Overkill? r~
On 6/21/22 16:55, Richard Henderson wrote: > On 6/21/22 00:51, Paolo Bonzini wrote: >> diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile >> index ea89ce9d59..e90ca2e1c6 100644 >> --- a/pc-bios/optionrom/Makefile >> +++ b/pc-bios/optionrom/Makefile >> @@ -11,7 +11,7 @@ CFLAGS = -O2 -g >> quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 >> && $1, @$1)) >> cc-option = $(if $(shell $(CC) $1 -c -o /dev/null -xc /dev/null >> >/dev/null 2>&1 && echo OK), $1, $2) >> -override CFLAGS += -march=i486 -Wall -m16 >> +override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16 > > Hmm. I'm not sure about this. Given that EXTRA_CFLAGS is going to be > e.g. -m32 or empty, being immediately overwritten to -m16, I don't quite > see the point. I added it mostly for consistency with the other pc-bios subdirectories, and because it can also be overridden with --cross-cflags-i386 though. Even for the default -m32, however, there would be a reason to have $(EXTRA_FLAGS) in there. I have played with removing the direct use of "ld -m" in the build of pc-bios/optionrom, and stumbled on a weird GCC configuration issue. The problem is that some hosts pick the right linker emulation when given -m16, but others don't: $ gcc -dumpspecs ... *link: ... %{m16|m32|mx32:;:-m elf_x86_64} %{m16|m32:-m elf_i386} # x86_64-w64-mingw32-gcc ... *link: %{!m32:-m i386pep} %{m32:-m i386pe} ... The error is in GCC's gcc/config/i386/mingw-w64.h, which provides a MULTILIB_DEFAULTS #define but does not rely on it: #undef SPEC_32 #undef SPEC_64 #if TARGET_64BIT_DEFAULT #define SPEC_32 "m32" // should be m16|m32 #define SPEC_64 "!m32" // should be m64 #else #define SPEC_32 "!m64" // should be m16|m32 #define SPEC_64 "m64" #endif So you need -m32 -m16 on 64-bit hosts! For the "working" specs the -m16 would override -m32, while on the broken ones -m32 is for the linker and -m16 is for the compiler. Paolo
diff --git a/configure b/configure index 76728b31f7..3d00b361d7 100755 --- a/configure +++ b/configure @@ -2057,19 +2057,22 @@ probe_target_compiler() { compute_target_variable $1 target_objcopy objcopy compute_target_variable $1 target_ranlib ranlib compute_target_variable $1 target_strip strip - if test "$1" = $cpu; then - : ${target_cc:=$cc} - : ${target_ccas:=$ccas} - : ${target_as:=$as} - : ${target_ld:=$ld} - : ${target_ar:=$ar} - : ${target_as:=$as} - : ${target_ld:=$ld} - : ${target_nm:=$nm} - : ${target_objcopy:=$objcopy} - : ${target_ranlib:=$ranlib} - : ${target_strip:=$strip} - fi + case "$1:$cpu" in + i386:x86_64 | \ + "$cpu:$cpu") + : ${target_cc:=$cc} + : ${target_ccas:=$ccas} + : ${target_as:=$as} + : ${target_ld:=$ld} + : ${target_ar:=$ar} + : ${target_as:=$as} + : ${target_ld:=$ld} + : ${target_nm:=$nm} + : ${target_objcopy:=$objcopy} + : ${target_ranlib:=$ranlib} + : ${target_strip:=$strip} + ;; + esac if test -n "$target_cc"; then case $1 in i386|x86_64) @@ -2238,7 +2241,7 @@ done # Mac OS X ships with a broken assembler roms= -probe_target_compilers i386 x86_64 +probe_target_compiler i386 if test -n "$target_cc" && test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ test "$targetos" != "haiku" && test "$softmmu" = yes ; then @@ -2257,6 +2260,7 @@ if test -n "$target_cc" && echo "# Automatically generated by configure - do not modify" > $config_mak echo "TOPSRC_DIR=$source_path" >> $config_mak echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_mak + echo "EXTRA_CFLAGS=$target_cflags" >> $config_mak write_target_makefile >> $config_mak fi fi diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index ea89ce9d59..e90ca2e1c6 100644 --- a/pc-bios/optionrom/Makefile +++ b/pc-bios/optionrom/Makefile @@ -11,7 +11,7 @@ CFLAGS = -O2 -g quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) cc-option = $(if $(shell $(CC) $1 -c -o /dev/null -xc /dev/null >/dev/null 2>&1 && echo OK), $1, $2) -override CFLAGS += -march=i486 -Wall -m16 +override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16 # If -fcf-protection is enabled in flags or compiler defaults that will # conflict with -march=i486
The optionrom build is disregarding the flags passed to the configure script via --cross-cflags-i386. Pass it down and add it to the Makefile. This also fixes compilation of TCG i386 tests using an x86_64 compiler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- configure | 32 ++++++++++++++++++-------------- pc-bios/optionrom/Makefile | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-)