qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Fix support for biarch compilers and cross cflags
@ 2022-06-21  7:51 Paolo Bonzini
  2022-06-21  7:51 ` [PATCH 1/6] pc-bios/optionrom: use -m16 unconditionally Paolo Bonzini
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Paolo Bonzini @ 2022-06-21  7:51 UTC (permalink / raw)
  To: qemu-devel

This series fixes two bugs with configure's cross compilation detection:

- first, --cross-cflags is not obeyed by pc-bios/ compilation

- second, on a ppc64le machine, the host compiler can be used for ppc64
  tests/tcg; however, this is not being done because $cpu does not
  match the target.  Likewise, on an x86_64 machine the host compiler
  can be used to build both i386 tests/tcg and pc-bios/optionrom, but
  the special casing done by the configure script only covers the latter.

The two are related because, if only the first was fixed, pc-bios/optionrom
would use either the i386 or the x86_64 cflags depending on which cross
compiler was found.  So patches 2-4 tackle not just the cross CFLAGS
problem with pc-bios, but also the biarch compiler problem with i386
and ppc.  Patch 5 then covers the other biarch compilers.

The other two patches are just cleanups.

Supersedes: <20220607094031.1227714-1-pbonzini@redhat.com>

Paolo Bonzini (6):
  pc-bios/optionrom: use -m16 unconditionally
  configure, pc-bios/optionrom: pass cross CFLAGS correctly
  configure, pc-bios/s390-ccw: pass cross CFLAGS correctly
  configure, pc-bios/vof: pass cross CFLAGS correctly
  configure: allow more host/target combos to use the host compiler
  configure: write EXTRA_CFLAGS for all sub-Makefiles

 configure                     | 50 ++++++++++++++++++-----------------
 pc-bios/optionrom/Makefile    | 15 +----------
 pc-bios/optionrom/code16gcc.h |  3 ---
 pc-bios/s390-ccw/Makefile     | 20 +++++++-------
 pc-bios/s390-ccw/netboot.mak  |  6 ++---
 pc-bios/vof/Makefile          |  8 +++---
 6 files changed, 43 insertions(+), 59 deletions(-)
 delete mode 100644 pc-bios/optionrom/code16gcc.h

-- 
2.36.1



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

* [PATCH 1/6] pc-bios/optionrom: use -m16 unconditionally
  2022-06-21  7:51 [PATCH 0/6] Fix support for biarch compilers and cross cflags Paolo Bonzini
@ 2022-06-21  7:51 ` Paolo Bonzini
  2022-06-21 14:48   ` Richard Henderson
  2022-06-21  7:51 ` [PATCH 2/6] configure, pc-bios/optionrom: pass cross CFLAGS correctly Paolo Bonzini
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2022-06-21  7:51 UTC (permalink / raw)
  To: qemu-devel

Remove support for .code16gcc, all supported platforms have -m16.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 pc-bios/optionrom/Makefile    | 15 +--------------
 pc-bios/optionrom/code16gcc.h |  3 ---
 2 files changed, 1 insertion(+), 17 deletions(-)
 delete mode 100644 pc-bios/optionrom/code16gcc.h

diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
index f639915b4f..ea89ce9d59 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
+override CFLAGS += -march=i486 -Wall -m16
 
 # If -fcf-protection is enabled in flags or compiler defaults that will
 # conflict with -march=i486
@@ -24,21 +24,8 @@ override CFLAGS += $(filter -W%, $(QEMU_CFLAGS))
 override CFLAGS += $(call cc-option, -fno-pie)
 override CFLAGS += -ffreestanding -I$(TOPSRC_DIR)/include
 override CFLAGS += $(call cc-option, -fno-stack-protector)
-override CFLAGS += $(call cc-option, -m16)
 override CFLAGS += $(call cc-option, -Wno-array-bounds)
 
-ifeq ($(filter -m16, $(CFLAGS)),)
-# Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??)
-# On GCC we add -fno-toplevel-reorder to keep the order of asm blocks with
-# respect to the rest of the code.  clang does not have -fno-toplevel-reorder,
-# but it places all asm blocks at the beginning and we're relying on it for
-# the option ROM header.  So just force clang not to use the integrated
-# assembler, which doesn't support .code16gcc.
-override CFLAGS += $(call cc-option, -fno-toplevel-reorder)
-override CFLAGS += $(call cc-option, -no-integrated-as)
-override CFLAGS += -m32 -include $(SRC_DIR)/code16gcc.h
-endif
-
 Wa = -Wa,
 override ASFLAGS += -32
 override CFLAGS += $(call cc-option, $(Wa)-32)
diff --git a/pc-bios/optionrom/code16gcc.h b/pc-bios/optionrom/code16gcc.h
deleted file mode 100644
index 9c8d25d508..0000000000
--- a/pc-bios/optionrom/code16gcc.h
+++ /dev/null
@@ -1,3 +0,0 @@
-asm(
-".code16gcc\n"
-);
-- 
2.36.1




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

* [PATCH 2/6] configure, pc-bios/optionrom: pass cross CFLAGS correctly
  2022-06-21  7:51 [PATCH 0/6] Fix support for biarch compilers and cross cflags Paolo Bonzini
  2022-06-21  7:51 ` [PATCH 1/6] pc-bios/optionrom: use -m16 unconditionally Paolo Bonzini
@ 2022-06-21  7:51 ` Paolo Bonzini
  2022-06-21 14:55   ` Richard Henderson
  2022-06-21  7:51 ` [PATCH 3/6] configure, pc-bios/s390-ccw: " Paolo Bonzini
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2022-06-21  7:51 UTC (permalink / raw)
  To: qemu-devel

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(-)

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




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

* [PATCH 3/6] configure, pc-bios/s390-ccw: pass cross CFLAGS correctly
  2022-06-21  7:51 [PATCH 0/6] Fix support for biarch compilers and cross cflags Paolo Bonzini
  2022-06-21  7:51 ` [PATCH 1/6] pc-bios/optionrom: use -m16 unconditionally Paolo Bonzini
  2022-06-21  7:51 ` [PATCH 2/6] configure, pc-bios/optionrom: pass cross CFLAGS correctly Paolo Bonzini
@ 2022-06-21  7:51 ` Paolo Bonzini
  2022-06-21  8:26   ` Thomas Huth
  2022-06-21  7:51 ` [PATCH 4/6] configure, pc-bios/vof: " Paolo Bonzini
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2022-06-21  7:51 UTC (permalink / raw)
  To: qemu-devel

QEMU_CFLAGS is not available in pc-bios/s390-ccw/netboot.mak, but the Makefile
needs to access the flags passed to the configure script for the s390x
cross compiler.  Fix everything and rename QEMU_CFLAGS to EXTRA_CFLAGS for
consistency with tests/tcg.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure                    |  1 +
 pc-bios/s390-ccw/Makefile    | 20 ++++++++++----------
 pc-bios/s390-ccw/netboot.mak |  6 +++---
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index 3d00b361d7..bf9282e2a1 100755
--- a/configure
+++ b/configure
@@ -2290,6 +2290,7 @@ if test -n "$target_cc" && test "$softmmu" = yes; then
     config_mak=pc-bios/s390-ccw/config-host.mak
     echo "# Automatically generated by configure - do not modify" > $config_mak
     echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
+    echo "EXTRA_CFLAGS=$target_cflags" >> $config_mak
     write_target_makefile >> $config_mak
     # SLOF is required for building the s390-ccw firmware on s390x,
     # since it is using the libnet code from SLOF for network booting.
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index 6eb713bf37..26ad40f94e 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -18,11 +18,11 @@ $(call set-vpath, $(SRC_PATH))
 QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d
 
 %.o: %.c
-	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
+	$(call quiet-command,$(CC) $(EXTRA_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
 	       -c -o $@ $<,"CC","$(TARGET_DIR)$@")
 
 %.o: %.S
-	$(call quiet-command,$(CCAS) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
+	$(call quiet-command,$(CCAS) $(EXTRA_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
 	       -c -o $@ $<,"CCAS","$(TARGET_DIR)$@")
 
 .PHONY : all clean build-all
@@ -30,14 +30,14 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d
 OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
 	  virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o
 
-QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS))
-QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-stringop-overflow)
-QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
-QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
-QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
-QEMU_CFLAGS += -msoft-float
-QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS),-march=z900,-march=z10)
-QEMU_CFLAGS += -std=gnu99
+EXTRA_CFLAGS := $(EXTRA_CFLAGS) -Wall
+EXTRA_CFLAGS += $(call cc-option,-Werror $(EXTRA_CFLAGS),-Wno-stringop-overflow)
+EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
+EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
+EXTRA_CFLAGS += $(call cc-option, $(EXTRA_CFLAGS), -fno-stack-protector)
+EXTRA_CFLAGS += -msoft-float
+EXTRA_CFLAGS += $(call cc-option, $(EXTRA_CFLAGS),-march=z900,-march=z10)
+EXTRA_CFLAGS += -std=gnu99
 LDFLAGS += -Wl,-pie -nostdlib
 
 build-all: s390-ccw.img s390-netboot.img
diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak
index 1a06befa4b..ee59a5f4de 100644
--- a/pc-bios/s390-ccw/netboot.mak
+++ b/pc-bios/s390-ccw/netboot.mak
@@ -8,7 +8,7 @@ LIBNET_INC := -I$(SLOF_DIR)/lib/libnet
 
 NETLDFLAGS := $(LDFLAGS) -Wl,-Ttext=0x7800000
 
-$(NETOBJS): QEMU_CFLAGS += $(LIBC_INC) $(LIBNET_INC)
+$(NETOBJS): EXTRA_CFLAGS += $(LIBC_INC) $(LIBNET_INC)
 
 s390-netboot.elf: $(NETOBJS) libnet.a libc.a
 	$(call quiet-command,$(CC) $(NETLDFLAGS) -o $@ $^,"BUILD","$(TARGET_DIR)$@")
@@ -18,7 +18,7 @@ s390-netboot.img: s390-netboot.elf
 
 # libc files:
 
-LIBC_CFLAGS = $(QEMU_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
+LIBC_CFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
 	      -MMD -MP -MT $@ -MF $(@:%.o=%.d)
 
 CTYPE_OBJS = isdigit.o isxdigit.o toupper.o
@@ -52,7 +52,7 @@ libc.a: $(LIBCOBJS)
 
 LIBNETOBJS := args.o dhcp.o dns.o icmpv6.o ipv6.o tcp.o udp.o bootp.o \
 	      dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o pxelinux.o
-LIBNETCFLAGS = $(QEMU_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
+LIBNETCFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
 	       -DDHCPARCH=0x1F -MMD -MP -MT $@ -MF $(@:%.o=%.d)
 
 %.o : $(SLOF_DIR)/lib/libnet/%.c
-- 
2.36.1




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

* [PATCH 4/6] configure, pc-bios/vof: pass cross CFLAGS correctly
  2022-06-21  7:51 [PATCH 0/6] Fix support for biarch compilers and cross cflags Paolo Bonzini
                   ` (2 preceding siblings ...)
  2022-06-21  7:51 ` [PATCH 3/6] configure, pc-bios/s390-ccw: " Paolo Bonzini
@ 2022-06-21  7:51 ` Paolo Bonzini
  2022-06-21 15:14   ` Richard Henderson
  2022-06-21  7:51 ` [PATCH 5/6] configure: allow more host/target combos to use the host compiler Paolo Bonzini
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2022-06-21  7:51 UTC (permalink / raw)
  To: qemu-devel

Use the flags passed to the configure script for the ppc cross compiler,
which in fact default to those that are needed to get the 32-bit ISA.
Add the endianness flag so that it remains possible to use a ppc64le
compiler to compile VOF.

This also fixes compilation of TCG tests using a biarch compiler,
for example ppc64 tests on ppc64le.

Reported-by: Matheus Ferst <matheus.ferst@eldorado.org.br
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure            | 13 ++++---------
 pc-bios/vof/Makefile |  8 +++-----
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/configure b/configure
index bf9282e2a1..8f3401a23e 100755
--- a/configure
+++ b/configure
@@ -1858,7 +1858,7 @@ fi
 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
 : ${cross_cc_cflags_hexagon="-mv67 -O2 -static"}
 : ${cross_cc_cflags_i386="-m32"}
-: ${cross_cc_cflags_ppc="-m32"}
+: ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
 : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
 : ${cross_cc_ppc64le="$cross_cc_ppc64"}
 : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
@@ -2059,6 +2059,7 @@ probe_target_compiler() {
   compute_target_variable $1 target_strip strip
   case "$1:$cpu" in
     i386:x86_64 | \
+    ppc*:ppc64 | \
     "$cpu:$cpu")
       : ${target_cc:=$cc}
       : ${target_ccas:=$ccas}
@@ -2084,13 +2085,6 @@ probe_target_compiler() {
   fi
 }
 
-probe_target_compilers() {
-  for i; do
-    probe_target_compiler $i
-    test -n "$target_cc" && return 0
-  done
-}
-
 write_target_makefile() {
   if test -n "$target_cc"; then
     echo "CC=$target_cc"
@@ -2265,12 +2259,13 @@ if test -n "$target_cc" &&
     fi
 fi
 
-probe_target_compilers ppc ppc64
+probe_target_compiler ppc
 if test -n "$target_cc" && test "$softmmu" = yes; then
     roms="$roms pc-bios/vof"
     config_mak=pc-bios/vof/config.mak
     echo "# Automatically generated by configure - do not modify" > $config_mak
     echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
+    echo "EXTRA_CFLAGS=$target_cflags" >> $config_mak
     write_target_makefile >> $config_mak
 fi
 
diff --git a/pc-bios/vof/Makefile b/pc-bios/vof/Makefile
index 391ac0d600..8809c82768 100644
--- a/pc-bios/vof/Makefile
+++ b/pc-bios/vof/Makefile
@@ -2,15 +2,13 @@ include config.mak
 VPATH=$(SRC_DIR)
 all: vof.bin
 
-CC ?= $(CROSS)gcc
-LD ?= $(CROSS)ld
-OBJCOPY ?= $(CROSS)objcopy
+EXTRA_CFLAGS += -mcpu=power4
 
 %.o: %.S
-	$(CC) -m32 -mbig-endian -mcpu=power4 -c -o $@ $<
+	$(CC) $(EXTRA_CFLAGS) -c -o $@ $<
 
 %.o: %.c
-	$(CC) -m32 -mbig-endian -mcpu=power4 -c -fno-stack-protector -o $@ $<
+	$(CC) $(EXTRA_CFLAGS) -c -fno-stack-protector -o $@ $<
 
 vof.elf: entry.o main.o ci.o bootmem.o libc.o
 	$(LD) -nostdlib -e_start -T$(SRC_DIR)/vof.lds -EB -o $@ $^
-- 
2.36.1




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

* [PATCH 5/6] configure: allow more host/target combos to use the host compiler
  2022-06-21  7:51 [PATCH 0/6] Fix support for biarch compilers and cross cflags Paolo Bonzini
                   ` (3 preceding siblings ...)
  2022-06-21  7:51 ` [PATCH 4/6] configure, pc-bios/vof: " Paolo Bonzini
@ 2022-06-21  7:51 ` Paolo Bonzini
  2022-06-21  7:51 ` [PATCH 6/6] configure: write EXTRA_CFLAGS for all sub-Makefiles Paolo Bonzini
  2022-06-21 16:38 ` [PATCH 0/6] Fix support for biarch compilers and cross cflags Matheus Kowalczuk Ferst
  6 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2022-06-21  7:51 UTC (permalink / raw)
  To: qemu-devel

Add more pairs of bi-arch compilers, so that it is not necessary to have
e.g. both little-endian and big-endian ARM compilers.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/configure b/configure
index 8f3401a23e..c9feb1a924 100755
--- a/configure
+++ b/configure
@@ -2058,8 +2058,12 @@ probe_target_compiler() {
   compute_target_variable $1 target_ranlib ranlib
   compute_target_variable $1 target_strip strip
   case "$1:$cpu" in
+    aarch64_be:aarch64 | \
+    armeb:arm | \
     i386:x86_64 | \
+    mips*:mips64 | \
     ppc*:ppc64 | \
+    sparc:sparc64 | \
     "$cpu:$cpu")
       : ${target_cc:=$cc}
       : ${target_ccas:=$ccas}
-- 
2.36.1




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

* [PATCH 6/6] configure: write EXTRA_CFLAGS for all sub-Makefiles
  2022-06-21  7:51 [PATCH 0/6] Fix support for biarch compilers and cross cflags Paolo Bonzini
                   ` (4 preceding siblings ...)
  2022-06-21  7:51 ` [PATCH 5/6] configure: allow more host/target combos to use the host compiler Paolo Bonzini
@ 2022-06-21  7:51 ` Paolo Bonzini
  2022-06-21 16:38 ` [PATCH 0/6] Fix support for biarch compilers and cross cflags Matheus Kowalczuk Ferst
  6 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2022-06-21  7:51 UTC (permalink / raw)
  To: qemu-devel

Move the EXTRA_CFLAGS line from the individual subdirectory blocks to
the common write_target_makefile and write_container_target_makefile
shell functions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index c9feb1a924..0fd2838e82 100755
--- a/configure
+++ b/configure
@@ -2090,6 +2090,7 @@ probe_target_compiler() {
 }
 
 write_target_makefile() {
+  echo "EXTRA_CFLAGS=$target_cflags"
   if test -n "$target_cc"; then
     echo "CC=$target_cc"
     echo "CCAS=$target_ccas"
@@ -2118,6 +2119,7 @@ write_target_makefile() {
 }
 
 write_container_target_makefile() {
+  echo "EXTRA_CFLAGS=$target_cflags"
   if test -n "$container_cross_cc"; then
     echo "CC=\$(DOCKER_SCRIPT) cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
     echo "CCAS=\$(DOCKER_SCRIPT) cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
@@ -2258,7 +2260,6 @@ 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
@@ -2269,7 +2270,6 @@ if test -n "$target_cc" && test "$softmmu" = yes; then
     config_mak=pc-bios/vof/config.mak
     echo "# Automatically generated by configure - do not modify" > $config_mak
     echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
-    echo "EXTRA_CFLAGS=$target_cflags" >> $config_mak
     write_target_makefile >> $config_mak
 fi
 
@@ -2289,7 +2289,6 @@ if test -n "$target_cc" && test "$softmmu" = yes; then
     config_mak=pc-bios/s390-ccw/config-host.mak
     echo "# Automatically generated by configure - do not modify" > $config_mak
     echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
-    echo "EXTRA_CFLAGS=$target_cflags" >> $config_mak
     write_target_makefile >> $config_mak
     # SLOF is required for building the s390-ccw firmware on s390x,
     # since it is using the libnet code from SLOF for network booting.
@@ -2604,7 +2603,6 @@ for target in $target_list; do
   if test $got_cross_cc = yes; then
       mkdir -p tests/tcg/$target
       echo "QEMU=$PWD/$qemu" >> $config_target_mak
-      echo "EXTRA_CFLAGS=$target_cflags" >> $config_target_mak
       echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> $makefile
       tcg_tests_targets="$tcg_tests_targets $target"
   fi
-- 
2.36.1



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

* Re: [PATCH 3/6] configure, pc-bios/s390-ccw: pass cross CFLAGS correctly
  2022-06-21  7:51 ` [PATCH 3/6] configure, pc-bios/s390-ccw: " Paolo Bonzini
@ 2022-06-21  8:26   ` Thomas Huth
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Huth @ 2022-06-21  8:26 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 21/06/2022 09.51, Paolo Bonzini wrote:
> QEMU_CFLAGS is not available in pc-bios/s390-ccw/netboot.mak, but the Makefile
> needs to access the flags passed to the configure script for the s390x
> cross compiler.  Fix everything and rename QEMU_CFLAGS to EXTRA_CFLAGS for
> consistency with tests/tcg.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   configure                    |  1 +
>   pc-bios/s390-ccw/Makefile    | 20 ++++++++++----------
>   pc-bios/s390-ccw/netboot.mak |  6 +++---
>   3 files changed, 14 insertions(+), 13 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH 1/6] pc-bios/optionrom: use -m16 unconditionally
  2022-06-21  7:51 ` [PATCH 1/6] pc-bios/optionrom: use -m16 unconditionally Paolo Bonzini
@ 2022-06-21 14:48   ` Richard Henderson
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2022-06-21 14:48 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 6/21/22 00:51, Paolo Bonzini wrote:
> Remove support for .code16gcc, all supported platforms have -m16.
> 
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   pc-bios/optionrom/Makefile    | 15 +--------------
>   pc-bios/optionrom/code16gcc.h |  3 ---
>   2 files changed, 1 insertion(+), 17 deletions(-)
>   delete mode 100644 pc-bios/optionrom/code16gcc.h

It was a bit dicey using .code16gcc behind the compiler's back anyway.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH 2/6] configure, pc-bios/optionrom: pass cross CFLAGS correctly
  2022-06-21  7:51 ` [PATCH 2/6] configure, pc-bios/optionrom: pass cross CFLAGS correctly Paolo Bonzini
@ 2022-06-21 14:55   ` Richard Henderson
  2022-06-22  9:31     ` Paolo Bonzini
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Henderson @ 2022-06-21 14:55 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

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~


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

* Re: [PATCH 4/6] configure, pc-bios/vof: pass cross CFLAGS correctly
  2022-06-21  7:51 ` [PATCH 4/6] configure, pc-bios/vof: " Paolo Bonzini
@ 2022-06-21 15:14   ` Richard Henderson
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2022-06-21 15:14 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 6/21/22 00:51, Paolo Bonzini wrote:
> Use the flags passed to the configure script for the ppc cross compiler,
> which in fact default to those that are needed to get the 32-bit ISA.
> Add the endianness flag so that it remains possible to use a ppc64le
> compiler to compile VOF.
> 
> This also fixes compilation of TCG tests using a biarch compiler,
> for example ppc64 tests on ppc64le.
> 
> Reported-by: Matheus Ferst <matheus.ferst@eldorado.org.br
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Probably you missed this, but last night (gmt-7) I sent:

make[1]: Entering directory `/home/rth/qemu/bld/pc-bios/vof'

cc -m32 -mbig-endian -mcpu=power4 -c -o entry.o /home/rth/qemu/src/pc-bios/vof/entry.S

cc1: error: ‘-m32’ not supported in this configuration

make[1]: *** [entry.o] Error 1


This with a compiler I built myself,

$ cc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/home/rth/gcc/run/libexec/gcc/powerpc64le-unknown-linux-gnu/11.0.1/lto-wrapper

Target: powerpc64le-unknown-linux-gnu

Configured with: ../git-gcc/configure --prefix=/home/rth/gcc/run

Thread model: posix

Supported LTO compression algorithms: zlib

gcc version 11.0.1 20210321 (experimental) [master revision 
19ff0b0:fca73fc:6af7b307f659a4f1845a9efd36ca37899515e234] (GCC)


With default configure options, gcc is not biarch.
It would be good to probe whether EXTRA_CFLAGS is actually usable.


r~


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

* Re: [PATCH 0/6] Fix support for biarch compilers and cross cflags
  2022-06-21  7:51 [PATCH 0/6] Fix support for biarch compilers and cross cflags Paolo Bonzini
                   ` (5 preceding siblings ...)
  2022-06-21  7:51 ` [PATCH 6/6] configure: write EXTRA_CFLAGS for all sub-Makefiles Paolo Bonzini
@ 2022-06-21 16:38 ` Matheus Kowalczuk Ferst
  6 siblings, 0 replies; 13+ messages in thread
From: Matheus Kowalczuk Ferst @ 2022-06-21 16:38 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel@nongnu.org

On 21/06/2022 04:51, Paolo Bonzini wrote:
> This series fixes two bugs with configure's cross compilation detection:
> 
> - first, --cross-cflags is not obeyed by pc-bios/ compilation
> 
> - second, on a ppc64le machine, the host compiler can be used for ppc64
>    tests/tcg;

That may be true for the compiler, but the complete toolchain is usually 
single endian. For instance, Debian/Ubuntu, Fedora, and FreeBSD lack 
libc and crt*.o for the foreign endianness. So we'd be able to build 
ppc64-softmmu tests (which are not upstream yet) but not 
ppc64-linux-user in ppc64le hosts.

> however, this is not being done because $cpu does not
>    match the target.  Likewise, on an x86_64 machine the host compiler
>    can be used to build both i386 tests/tcg and pc-bios/optionrom, but
>    the special casing done by the configure script only covers the latter.
> 
> The two are related because, if only the first was fixed, pc-bios/optionrom
> would use either the i386 or the x86_64 cflags depending on which cross
> compiler was found.  So patches 2-4 tackle not just the cross CFLAGS
> problem with pc-bios, but also the biarch compiler problem with i386
> and ppc.  Patch 5 then covers the other biarch compilers.
> 
> The other two patches are just cleanups.
> 
> Supersedes: <20220607094031.1227714-1-pbonzini@redhat.com>
> 
> Paolo Bonzini (6):
>    pc-bios/optionrom: use -m16 unconditionally
>    configure, pc-bios/optionrom: pass cross CFLAGS correctly
>    configure, pc-bios/s390-ccw: pass cross CFLAGS correctly
>    configure, pc-bios/vof: pass cross CFLAGS correctly
>    configure: allow more host/target combos to use the host compiler
>    configure: write EXTRA_CFLAGS for all sub-Makefiles
> 
>   configure                     | 50 ++++++++++++++++++-----------------
>   pc-bios/optionrom/Makefile    | 15 +----------
>   pc-bios/optionrom/code16gcc.h |  3 ---
>   pc-bios/s390-ccw/Makefile     | 20 +++++++-------
>   pc-bios/s390-ccw/netboot.mak  |  6 ++---
>   pc-bios/vof/Makefile          |  8 +++---
>   6 files changed, 43 insertions(+), 59 deletions(-)
>   delete mode 100644 pc-bios/optionrom/code16gcc.h
> 
> --
> 2.36.1
> 
> 


Thanks,
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>

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

* Re: [PATCH 2/6] configure, pc-bios/optionrom: pass cross CFLAGS correctly
  2022-06-21 14:55   ` Richard Henderson
@ 2022-06-22  9:31     ` Paolo Bonzini
  0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2022-06-22  9:31 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

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


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

end of thread, other threads:[~2022-06-22  9:33 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-21  7:51 [PATCH 0/6] Fix support for biarch compilers and cross cflags Paolo Bonzini
2022-06-21  7:51 ` [PATCH 1/6] pc-bios/optionrom: use -m16 unconditionally Paolo Bonzini
2022-06-21 14:48   ` Richard Henderson
2022-06-21  7:51 ` [PATCH 2/6] configure, pc-bios/optionrom: pass cross CFLAGS correctly Paolo Bonzini
2022-06-21 14:55   ` Richard Henderson
2022-06-22  9:31     ` Paolo Bonzini
2022-06-21  7:51 ` [PATCH 3/6] configure, pc-bios/s390-ccw: " Paolo Bonzini
2022-06-21  8:26   ` Thomas Huth
2022-06-21  7:51 ` [PATCH 4/6] configure, pc-bios/vof: " Paolo Bonzini
2022-06-21 15:14   ` Richard Henderson
2022-06-21  7:51 ` [PATCH 5/6] configure: allow more host/target combos to use the host compiler Paolo Bonzini
2022-06-21  7:51 ` [PATCH 6/6] configure: write EXTRA_CFLAGS for all sub-Makefiles Paolo Bonzini
2022-06-21 16:38 ` [PATCH 0/6] Fix support for biarch compilers and cross cflags Matheus Kowalczuk Ferst

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).