Message ID | 20180228180215.25470-2-wei@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 28/02/2018 19:02, Wei Huang wrote: > This patch moves the auto detection functions for cross compilation from > roms/Makefile to rules.mak. So the functions can be shared among Makefiles > in QEMU. > > Signed-off-by: Wei Huang <wei@redhat.com> > Reviewed-by: Andrew Jones <drjones@redhat.com> > --- > roms/Makefile | 24 +++++++----------------- > rules.mak | 15 +++++++++++++++ > 2 files changed, 22 insertions(+), 17 deletions(-) > > diff --git a/roms/Makefile b/roms/Makefile > index b5e5a69e91..e972c65333 100644 > --- a/roms/Makefile > +++ b/roms/Makefile > @@ -21,23 +21,6 @@ pxe-rom-virtio efi-rom-virtio : DID := 1000 > pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID := 15ad > pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID := 07b0 > > -# > -# cross compiler auto detection > -# > -path := $(subst :, ,$(PATH)) > -system := $(shell uname -s | tr "A-Z" "a-z") > - > -# first find cross binutils in path > -find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path)))) > -# then check we have cross gcc too > -find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > -# finally strip off path + toolname so we get the prefix > -find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > - > -powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > -powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > -x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > - > # tag our seabios builds > SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org" > > @@ -66,6 +49,13 @@ default: > @echo " skiboot -- update skiboot.lid" > @echo " u-boot.e500 -- update u-boot.e500" > > +SRC_PATH=.. > +include $(SRC_PATH)/rules.mak Did you check it works for not in-tree build? Something like: cd qemu mkdir build cd build ../configure make ... for instance in po/Makefile, we have: # Set SRC_PATH for in-tree builds without configuration. SRC_PATH=.. ... -include ../config-host.mak include $(SRC_PATH)/rules.mak and config-host.mak defines the absolute path of SRC_PATH Thanks, Laurent
On 28/02/2018 19:02, Wei Huang wrote: > This patch moves the auto detection functions for cross compilation from > roms/Makefile to rules.mak. So the functions can be shared among Makefiles > in QEMU. > > Signed-off-by: Wei Huang <wei@redhat.com> > Reviewed-by: Andrew Jones <drjones@redhat.com> > --- > roms/Makefile | 24 +++++++----------------- > rules.mak | 15 +++++++++++++++ > 2 files changed, 22 insertions(+), 17 deletions(-) > > diff --git a/roms/Makefile b/roms/Makefile > index b5e5a69e91..e972c65333 100644 > --- a/roms/Makefile > +++ b/roms/Makefile > @@ -21,23 +21,6 @@ pxe-rom-virtio efi-rom-virtio : DID := 1000 > pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID := 15ad > pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID := 07b0 > > -# > -# cross compiler auto detection > -# > -path := $(subst :, ,$(PATH)) > -system := $(shell uname -s | tr "A-Z" "a-z") > - > -# first find cross binutils in path > -find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path)))) > -# then check we have cross gcc too > -find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > -# finally strip off path + toolname so we get the prefix > -find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > - > -powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > -powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > -x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > - > # tag our seabios builds > SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org" > > @@ -66,6 +49,13 @@ default: > @echo " skiboot -- update skiboot.lid" > @echo " u-boot.e500 -- update u-boot.e500" > > +SRC_PATH=.. > +include $(SRC_PATH)/rules.mak > + > +powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > +powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > +x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > + > bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k > cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin > cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin > diff --git a/rules.mak b/rules.mak > index 6e943335f3..ef8adee3f8 100644 > --- a/rules.mak > +++ b/rules.mak > @@ -62,6 +62,21 @@ expand-objs = $(strip $(sort $(filter %.o,$1)) \ > $(foreach o,$(filter %.mo,$1),$($o-objs)) \ > $(filter-out %.o %.mo,$1)) > > +# Cross compilation auto detection. Use find-cross-prefix to detect the > +# target archtecture's prefix, and then append it to the build tool or pass > +# it to CROSS_COMPILE directly. Here is one example: > +# x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > +# $(x86_64_cross_prefix)gcc -c test.c -o test.o > +# make -C testdir CROSS_COMPILE=$(x86_64_cross_prefix) > +cross-search-path := $(subst :, ,$(PATH)) > +cross-host-system := $(shell uname -s | tr "A-Z" "a-z") > + > +find-cross-ld = $(firstword $(wildcard $(patsubst \ > + %,%/$(1)-*$(cross-host-system)*-ld,$(cross-search-path)))) > +find-cross-gcc = $(firstword $(wildcard \ > + $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > +find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > + > %.o: %.c > $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \ > $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \ > With this patch, "make slof" fails: git submodule init roms/SLOF git submodule update roms/SLOF cd roms make slof ... make[4]: Entering directory '/home/lvivier/Projects/qemu-upstream/roms/SLOF/lib/libnvram' [CC] Makefile.dep powerpc64-linux-gnu-ar: nvram.o: No such file or directory make[4]: *** [Makefile:31: ../libnvram.a] Error 1 Perhaps rules.mak defines values inherited by SLOF makefiles that are incompatible? Thanks, Laurent
* Laurent Vivier (lvivier@redhat.com) wrote: > On 28/02/2018 19:02, Wei Huang wrote: > > This patch moves the auto detection functions for cross compilation from > > roms/Makefile to rules.mak. So the functions can be shared among Makefiles > > in QEMU. > > > > Signed-off-by: Wei Huang <wei@redhat.com> > > Reviewed-by: Andrew Jones <drjones@redhat.com> > > --- > > roms/Makefile | 24 +++++++----------------- > > rules.mak | 15 +++++++++++++++ > > 2 files changed, 22 insertions(+), 17 deletions(-) > > > > diff --git a/roms/Makefile b/roms/Makefile > > index b5e5a69e91..e972c65333 100644 > > --- a/roms/Makefile > > +++ b/roms/Makefile > > @@ -21,23 +21,6 @@ pxe-rom-virtio efi-rom-virtio : DID := 1000 > > pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID := 15ad > > pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID := 07b0 > > > > -# > > -# cross compiler auto detection > > -# > > -path := $(subst :, ,$(PATH)) > > -system := $(shell uname -s | tr "A-Z" "a-z") > > - > > -# first find cross binutils in path > > -find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path)))) > > -# then check we have cross gcc too > > -find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > > -# finally strip off path + toolname so we get the prefix > > -find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > > - > > -powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > > -powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > > -x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > - > > # tag our seabios builds > > SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org" > > > > @@ -66,6 +49,13 @@ default: > > @echo " skiboot -- update skiboot.lid" > > @echo " u-boot.e500 -- update u-boot.e500" > > > > +SRC_PATH=.. > > +include $(SRC_PATH)/rules.mak > > + > > +powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > > +powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > > +x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > + > > bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k > > cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin > > cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin > > diff --git a/rules.mak b/rules.mak > > index 6e943335f3..ef8adee3f8 100644 > > --- a/rules.mak > > +++ b/rules.mak > > @@ -62,6 +62,21 @@ expand-objs = $(strip $(sort $(filter %.o,$1)) \ > > $(foreach o,$(filter %.mo,$1),$($o-objs)) \ > > $(filter-out %.o %.mo,$1)) > > > > +# Cross compilation auto detection. Use find-cross-prefix to detect the > > +# target archtecture's prefix, and then append it to the build tool or pass > > +# it to CROSS_COMPILE directly. Here is one example: > > +# x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > +# $(x86_64_cross_prefix)gcc -c test.c -o test.o > > +# make -C testdir CROSS_COMPILE=$(x86_64_cross_prefix) > > +cross-search-path := $(subst :, ,$(PATH)) > > +cross-host-system := $(shell uname -s | tr "A-Z" "a-z") > > + > > +find-cross-ld = $(firstword $(wildcard $(patsubst \ > > + %,%/$(1)-*$(cross-host-system)*-ld,$(cross-search-path)))) > > +find-cross-gcc = $(firstword $(wildcard \ > > + $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > > +find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > > + > > %.o: %.c > > $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \ > > $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \ > > > > With this patch, "make slof" fails: > > git submodule init roms/SLOF > git submodule update roms/SLOF > cd roms > make slof > ... > make[4]: Entering directory > '/home/lvivier/Projects/qemu-upstream/roms/SLOF/lib/libnvram' > [CC] Makefile.dep > powerpc64-linux-gnu-ar: nvram.o: No such file or directory > make[4]: *** [Makefile:31: ../libnvram.a] Error 1 > > Perhaps rules.mak defines values inherited by SLOF makefiles that are > incompatible? OK, can we go back a step here; and split this series; it's trying to do two entirely different things: a) Add an aarch64 migration test b) Refactor some of the build stuff I'd like to see (a) posted separately, doing things approximately the same way that the x86 ROM is doing it. Dave > Thanks, > Laurent > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
On Mon, Mar 05, 2018 at 11:01:23AM +0000, Dr. David Alan Gilbert wrote: > * Laurent Vivier (lvivier@redhat.com) wrote: > > On 28/02/2018 19:02, Wei Huang wrote: > > > This patch moves the auto detection functions for cross compilation from > > > roms/Makefile to rules.mak. So the functions can be shared among Makefiles > > > in QEMU. > > > > > > Signed-off-by: Wei Huang <wei@redhat.com> > > > Reviewed-by: Andrew Jones <drjones@redhat.com> > > > --- > > > roms/Makefile | 24 +++++++----------------- > > > rules.mak | 15 +++++++++++++++ > > > 2 files changed, 22 insertions(+), 17 deletions(-) > > > > > > diff --git a/roms/Makefile b/roms/Makefile > > > index b5e5a69e91..e972c65333 100644 > > > --- a/roms/Makefile > > > +++ b/roms/Makefile > > > @@ -21,23 +21,6 @@ pxe-rom-virtio efi-rom-virtio : DID := 1000 > > > pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID := 15ad > > > pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID := 07b0 > > > > > > -# > > > -# cross compiler auto detection > > > -# > > > -path := $(subst :, ,$(PATH)) > > > -system := $(shell uname -s | tr "A-Z" "a-z") > > > - > > > -# first find cross binutils in path > > > -find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path)))) > > > -# then check we have cross gcc too > > > -find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > > > -# finally strip off path + toolname so we get the prefix > > > -find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > > > - > > > -powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > > > -powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > > > -x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > > - > > > # tag our seabios builds > > > SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org" > > > > > > @@ -66,6 +49,13 @@ default: > > > @echo " skiboot -- update skiboot.lid" > > > @echo " u-boot.e500 -- update u-boot.e500" > > > > > > +SRC_PATH=.. > > > +include $(SRC_PATH)/rules.mak > > > + > > > +powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > > > +powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > > > +x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > > + > > > bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k > > > cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin > > > cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin > > > diff --git a/rules.mak b/rules.mak > > > index 6e943335f3..ef8adee3f8 100644 > > > --- a/rules.mak > > > +++ b/rules.mak > > > @@ -62,6 +62,21 @@ expand-objs = $(strip $(sort $(filter %.o,$1)) \ > > > $(foreach o,$(filter %.mo,$1),$($o-objs)) \ > > > $(filter-out %.o %.mo,$1)) > > > > > > +# Cross compilation auto detection. Use find-cross-prefix to detect the > > > +# target archtecture's prefix, and then append it to the build tool or pass > > > +# it to CROSS_COMPILE directly. Here is one example: > > > +# x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > > +# $(x86_64_cross_prefix)gcc -c test.c -o test.o > > > +# make -C testdir CROSS_COMPILE=$(x86_64_cross_prefix) > > > +cross-search-path := $(subst :, ,$(PATH)) > > > +cross-host-system := $(shell uname -s | tr "A-Z" "a-z") > > > + > > > +find-cross-ld = $(firstword $(wildcard $(patsubst \ > > > + %,%/$(1)-*$(cross-host-system)*-ld,$(cross-search-path)))) > > > +find-cross-gcc = $(firstword $(wildcard \ > > > + $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > > > +find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > > > + > > > %.o: %.c > > > $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \ > > > $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \ > > > > > > > With this patch, "make slof" fails: > > > > git submodule init roms/SLOF > > git submodule update roms/SLOF > > cd roms > > make slof > > ... > > make[4]: Entering directory > > '/home/lvivier/Projects/qemu-upstream/roms/SLOF/lib/libnvram' > > [CC] Makefile.dep > > powerpc64-linux-gnu-ar: nvram.o: No such file or directory > > make[4]: *** [Makefile:31: ../libnvram.a] Error 1 > > > > Perhaps rules.mak defines values inherited by SLOF makefiles that are > > incompatible? > > OK, can we go back a step here; and split this series; it's trying to do > two entirely different things: > > a) Add an aarch64 migration test > b) Refactor some of the build stuff > > I'd like to see (a) posted separately, doing things approximately the same way that > the x86 ROM is doing it. IMO, the makefile is the right approach. I wouldn't like to see AArch64 added with a script and then converted, along with x86, to a makefile at some later time (probably never). We can drop the build refactoring, at the expense of adding redundant cross-compile support, but still introduce a makefile. Likely nobody will ever get around to the refactoring needed to remove that redundancy, but oh well... I think we try to fix the SLOF build issue first, though. Thanks, drew
On 5 March 2018 at 13:36, Andrew Jones <drjones@redhat.com> wrote: > IMO, the makefile is the right approach. I wouldn't like to see AArch64 > added with a script and then converted, along with x86, to a makefile at > some later time (probably never). I'm not really enthusiastic about this approach of picking a cross compiler in the makefile rather than configure, though. The stuff we have at the moment that tries to build the x86 ROMs with whatever random host compiler we happen to be using is already a source of occasional brokenness. If we're going to try to build target code on a wider basis than just the x86 roms I'd like to see it done in a cleaner manner... thanks -- PMM
On Mon, Mar 05, 2018 at 01:40:06PM +0000, Peter Maydell wrote: > On 5 March 2018 at 13:36, Andrew Jones <drjones@redhat.com> wrote: > > IMO, the makefile is the right approach. I wouldn't like to see AArch64 > > added with a script and then converted, along with x86, to a makefile at > > some later time (probably never). > > I'm not really enthusiastic about this approach of picking a cross > compiler in the makefile rather than configure, though. The stuff > we have at the moment that tries to build the x86 ROMs with whatever > random host compiler we happen to be using is already a source > of occasional brokenness. If we're going to try to build target > code on a wider basis than just the x86 roms I'd like to see it > done in a cleaner manner... Seems like for each arch that we need a cross compiler for, we ought to have configure args & a corresponding config.mak variable eg configure \ --cross-cc-aarch64=aarch64-redhat-linux-gcc \ --cross-cc-x86_64=x86_64-redhat-linux-gcc \ If the --cross-cc-$ARCH arg isn't given we can just autodetect one, if present. This would end up setting in config.mak CROSS_CC_X86_64=x86_64-redhat-linux-c++ CROSS_CC_AARCH64=aarch64-redhat-linux-c++ If the --cross-cc-$ARCH arg is not given, and we can't automatically find a suitable compiler for that arch, then CC_$ARCH make variable should be left undefined. Any rules using these cross-compilers should automatically disable themselves, to ensure we don't suddenly force all people building QEMU to install many cross compilers. Regards, Daniel
* Andrew Jones (drjones@redhat.com) wrote: > On Mon, Mar 05, 2018 at 11:01:23AM +0000, Dr. David Alan Gilbert wrote: > > * Laurent Vivier (lvivier@redhat.com) wrote: > > > On 28/02/2018 19:02, Wei Huang wrote: > > > > This patch moves the auto detection functions for cross compilation from > > > > roms/Makefile to rules.mak. So the functions can be shared among Makefiles > > > > in QEMU. > > > > > > > > Signed-off-by: Wei Huang <wei@redhat.com> > > > > Reviewed-by: Andrew Jones <drjones@redhat.com> > > > > --- > > > > roms/Makefile | 24 +++++++----------------- > > > > rules.mak | 15 +++++++++++++++ > > > > 2 files changed, 22 insertions(+), 17 deletions(-) > > > > > > > > diff --git a/roms/Makefile b/roms/Makefile > > > > index b5e5a69e91..e972c65333 100644 > > > > --- a/roms/Makefile > > > > +++ b/roms/Makefile > > > > @@ -21,23 +21,6 @@ pxe-rom-virtio efi-rom-virtio : DID := 1000 > > > > pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID := 15ad > > > > pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID := 07b0 > > > > > > > > -# > > > > -# cross compiler auto detection > > > > -# > > > > -path := $(subst :, ,$(PATH)) > > > > -system := $(shell uname -s | tr "A-Z" "a-z") > > > > - > > > > -# first find cross binutils in path > > > > -find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path)))) > > > > -# then check we have cross gcc too > > > > -find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > > > > -# finally strip off path + toolname so we get the prefix > > > > -find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > > > > - > > > > -powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > > > > -powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > > > > -x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > > > - > > > > # tag our seabios builds > > > > SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org" > > > > > > > > @@ -66,6 +49,13 @@ default: > > > > @echo " skiboot -- update skiboot.lid" > > > > @echo " u-boot.e500 -- update u-boot.e500" > > > > > > > > +SRC_PATH=.. > > > > +include $(SRC_PATH)/rules.mak > > > > + > > > > +powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) > > > > +powerpc_cross_prefix := $(call find-cross-prefix,powerpc) > > > > +x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > > > + > > > > bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k > > > > cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin > > > > cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin > > > > diff --git a/rules.mak b/rules.mak > > > > index 6e943335f3..ef8adee3f8 100644 > > > > --- a/rules.mak > > > > +++ b/rules.mak > > > > @@ -62,6 +62,21 @@ expand-objs = $(strip $(sort $(filter %.o,$1)) \ > > > > $(foreach o,$(filter %.mo,$1),$($o-objs)) \ > > > > $(filter-out %.o %.mo,$1)) > > > > > > > > +# Cross compilation auto detection. Use find-cross-prefix to detect the > > > > +# target archtecture's prefix, and then append it to the build tool or pass > > > > +# it to CROSS_COMPILE directly. Here is one example: > > > > +# x86_64_cross_prefix := $(call find-cross-prefix,x86_64) > > > > +# $(x86_64_cross_prefix)gcc -c test.c -o test.o > > > > +# make -C testdir CROSS_COMPILE=$(x86_64_cross_prefix) > > > > +cross-search-path := $(subst :, ,$(PATH)) > > > > +cross-host-system := $(shell uname -s | tr "A-Z" "a-z") > > > > + > > > > +find-cross-ld = $(firstword $(wildcard $(patsubst \ > > > > + %,%/$(1)-*$(cross-host-system)*-ld,$(cross-search-path)))) > > > > +find-cross-gcc = $(firstword $(wildcard \ > > > > + $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) > > > > +find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) > > > > + > > > > %.o: %.c > > > > $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \ > > > > $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \ > > > > > > > > > > With this patch, "make slof" fails: > > > > > > git submodule init roms/SLOF > > > git submodule update roms/SLOF > > > cd roms > > > make slof > > > ... > > > make[4]: Entering directory > > > '/home/lvivier/Projects/qemu-upstream/roms/SLOF/lib/libnvram' > > > [CC] Makefile.dep > > > powerpc64-linux-gnu-ar: nvram.o: No such file or directory > > > make[4]: *** [Makefile:31: ../libnvram.a] Error 1 > > > > > > Perhaps rules.mak defines values inherited by SLOF makefiles that are > > > incompatible? > > > > OK, can we go back a step here; and split this series; it's trying to do > > two entirely different things: > > > > a) Add an aarch64 migration test > > b) Refactor some of the build stuff > > > > I'd like to see (a) posted separately, doing things approximately the same way that > > the x86 ROM is doing it. > > IMO, the makefile is the right approach. It may be; however, for what benefit? How many iterations have we gone through here for something that (in the x86 case) was shipped as a hex blob and never regenerated. IMHO even the script is overkill, comments in the .s file would be enough given just how often this stuff gets changed. Simplicity seems a better aim. > I wouldn't like to see AArch64 > added with a script and then converted, along with x86, to a makefile at > some later time (probably never). > > We can drop the build refactoring, at the expense of adding redundant > cross-compile support, but still introduce a makefile. Likely nobody will > ever get around to the refactoring needed to remove that redundancy, but > oh well... > > I think we try to fix the SLOF build issue first, though. OK. Dave > Thanks, > drew -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
On 03/05/2018 07:52 AM, Dr. David Alan Gilbert wrote: > * Andrew Jones (drjones@redhat.com) wrote: >> On Mon, Mar 05, 2018 at 11:01:23AM +0000, Dr. David Alan Gilbert wrote: >>> * Laurent Vivier (lvivier@redhat.com) wrote: >>>> On 28/02/2018 19:02, Wei Huang wrote: >>>>> This patch moves the auto detection functions for cross compilation from >>>>> roms/Makefile to rules.mak. So the functions can be shared among Makefiles >>>>> in QEMU. >>>>> >>>>> Signed-off-by: Wei Huang <wei@redhat.com> >>>>> Reviewed-by: Andrew Jones <drjones@redhat.com> >>>>> --- >>>>> roms/Makefile | 24 +++++++----------------- >>>>> rules.mak | 15 +++++++++++++++ >>>>> 2 files changed, 22 insertions(+), 17 deletions(-) >>>>> >>>>> diff --git a/roms/Makefile b/roms/Makefile >>>>> index b5e5a69e91..e972c65333 100644 >>>>> --- a/roms/Makefile >>>>> +++ b/roms/Makefile >>>>> @@ -21,23 +21,6 @@ pxe-rom-virtio efi-rom-virtio : DID := 1000 >>>>> pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID := 15ad >>>>> pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID := 07b0 >>>>> >>>>> -# >>>>> -# cross compiler auto detection >>>>> -# >>>>> -path := $(subst :, ,$(PATH)) >>>>> -system := $(shell uname -s | tr "A-Z" "a-z") >>>>> - >>>>> -# first find cross binutils in path >>>>> -find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path)))) >>>>> -# then check we have cross gcc too >>>>> -find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) >>>>> -# finally strip off path + toolname so we get the prefix >>>>> -find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) >>>>> - >>>>> -powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) >>>>> -powerpc_cross_prefix := $(call find-cross-prefix,powerpc) >>>>> -x86_64_cross_prefix := $(call find-cross-prefix,x86_64) >>>>> - >>>>> # tag our seabios builds >>>>> SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org" >>>>> >>>>> @@ -66,6 +49,13 @@ default: >>>>> @echo " skiboot -- update skiboot.lid" >>>>> @echo " u-boot.e500 -- update u-boot.e500" >>>>> >>>>> +SRC_PATH=.. >>>>> +include $(SRC_PATH)/rules.mak >>>>> + >>>>> +powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) >>>>> +powerpc_cross_prefix := $(call find-cross-prefix,powerpc) >>>>> +x86_64_cross_prefix := $(call find-cross-prefix,x86_64) >>>>> + >>>>> bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k >>>>> cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin >>>>> cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin >>>>> diff --git a/rules.mak b/rules.mak >>>>> index 6e943335f3..ef8adee3f8 100644 >>>>> --- a/rules.mak >>>>> +++ b/rules.mak >>>>> @@ -62,6 +62,21 @@ expand-objs = $(strip $(sort $(filter %.o,$1)) \ >>>>> $(foreach o,$(filter %.mo,$1),$($o-objs)) \ >>>>> $(filter-out %.o %.mo,$1)) >>>>> >>>>> +# Cross compilation auto detection. Use find-cross-prefix to detect the >>>>> +# target archtecture's prefix, and then append it to the build tool or pass >>>>> +# it to CROSS_COMPILE directly. Here is one example: >>>>> +# x86_64_cross_prefix := $(call find-cross-prefix,x86_64) >>>>> +# $(x86_64_cross_prefix)gcc -c test.c -o test.o >>>>> +# make -C testdir CROSS_COMPILE=$(x86_64_cross_prefix) >>>>> +cross-search-path := $(subst :, ,$(PATH)) >>>>> +cross-host-system := $(shell uname -s | tr "A-Z" "a-z") >>>>> + >>>>> +find-cross-ld = $(firstword $(wildcard $(patsubst \ >>>>> + %,%/$(1)-*$(cross-host-system)*-ld,$(cross-search-path)))) >>>>> +find-cross-gcc = $(firstword $(wildcard \ >>>>> + $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) >>>>> +find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) >>>>> + >>>>> %.o: %.c >>>>> $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \ >>>>> $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \ >>>>> >>>> >>>> With this patch, "make slof" fails: >>>> >>>> git submodule init roms/SLOF >>>> git submodule update roms/SLOF >>>> cd roms >>>> make slof >>>> ... >>>> make[4]: Entering directory >>>> '/home/lvivier/Projects/qemu-upstream/roms/SLOF/lib/libnvram' >>>> [CC] Makefile.dep >>>> powerpc64-linux-gnu-ar: nvram.o: No such file or directory >>>> make[4]: *** [Makefile:31: ../libnvram.a] Error 1 >>>> >>>> Perhaps rules.mak defines values inherited by SLOF makefiles that are >>>> incompatible? >>> >>> OK, can we go back a step here; and split this series; it's trying to do >>> two entirely different things: >>> >>> a) Add an aarch64 migration test >>> b) Refactor some of the build stuff >>> >>> I'd like to see (a) posted separately, doing things approximately the same way that >>> the x86 ROM is doing it. >> >> IMO, the makefile is the right approach. > > It may be; however, for what benefit? How many iterations have we gone > through here for something that (in the x86 case) was shipped as a hex > blob and never regenerated. IMHO even the script is overkill, comments > in the .s file would be enough given just how often this stuff gets > changed. Simplicity seems a better aim. > >> I wouldn't like to see AArch64 >> added with a script and then converted, along with x86, to a makefile at >> some later time (probably never). >> >> We can drop the build refactoring, at the expense of adding redundant >> cross-compile support, but still introduce a makefile. Likely nobody will >> ever get around to the refactoring needed to remove that redundancy, but >> oh well... >> >> I think we try to fix the SLOF build issue first, though. > > OK. SLO build actually is OK if we don't move the cross-compile stuff to the generic rules.mak. So this cross-compile approach has lots of objection (unclean, broken rom build etc.). A complete solution will make this patchset bloated, which is diverted away from original purpose of migration-test. Dave & Drew: will the following be acceptable? 1. Still use Makefile for .s->.h compilation 2. In Makefile, we don't support cross-compilation. This avoids duplicating the cross-compile detection code at all. Whoever really wants to re-generate .h file must be avid programmers. They can either find a native machine or fix Makefile themselves. 3. The cross-compile re-factoring will become a separate patchset. In that patchset, both ROM and migration-test Makefiles will be changed to support cross compilation. Thoughts? > > Dave > >> Thanks, >> drew > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK >
On 05/03/2018 18:59, Wei Huang wrote: ... > > SLO build actually is OK if we don't move the cross-compile stuff to the > generic rules.mak. > > So this cross-compile approach has lots of objection (unclean, broken > rom build etc.). A complete solution will make this patchset bloated, > which is diverted away from original purpose of migration-test. > > Dave & Drew: will the following be acceptable? > > 1. Still use Makefile for .s->.h compilation > 2. In Makefile, we don't support cross-compilation. This avoids > duplicating the cross-compile detection code at all. Whoever really > wants to re-generate .h file must be avid programmers. They can either > find a native machine or fix Makefile themselves. > 3. The cross-compile re-factoring will become a separate patchset. In > that patchset, both ROM and migration-test Makefiles will be changed to > support cross compilation. > > Thoughts? I agree with Peter: I think an improvement would be to detect/configure cross-compilers at the configure level, not in the Makefile. thanks, Laurent
Laurent Vivier <lvivier@redhat.com> writes: > On 05/03/2018 18:59, Wei Huang wrote: > ... >> >> SLO build actually is OK if we don't move the cross-compile stuff to the >> generic rules.mak. >> >> So this cross-compile approach has lots of objection (unclean, broken >> rom build etc.). A complete solution will make this patchset bloated, >> which is diverted away from original purpose of migration-test. >> >> Dave & Drew: will the following be acceptable? >> >> 1. Still use Makefile for .s->.h compilation >> 2. In Makefile, we don't support cross-compilation. This avoids >> duplicating the cross-compile detection code at all. Whoever really >> wants to re-generate .h file must be avid programmers. They can either >> find a native machine or fix Makefile themselves. >> 3. The cross-compile re-factoring will become a separate patchset. In >> that patchset, both ROM and migration-test Makefiles will be changed to >> support cross compilation. >> >> Thoughts? > > I agree with Peter: I think an improvement would be to detect/configure > cross-compilers at the configure level, not in the Makefile. I'm going to have a go at this now for docker and host installed cross-compilers. > > thanks, > Laurent -- Alex Bennée
diff --git a/roms/Makefile b/roms/Makefile index b5e5a69e91..e972c65333 100644 --- a/roms/Makefile +++ b/roms/Makefile @@ -21,23 +21,6 @@ pxe-rom-virtio efi-rom-virtio : DID := 1000 pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID := 15ad pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID := 07b0 -# -# cross compiler auto detection -# -path := $(subst :, ,$(PATH)) -system := $(shell uname -s | tr "A-Z" "a-z") - -# first find cross binutils in path -find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path)))) -# then check we have cross gcc too -find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) -# finally strip off path + toolname so we get the prefix -find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) - -powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) -powerpc_cross_prefix := $(call find-cross-prefix,powerpc) -x86_64_cross_prefix := $(call find-cross-prefix,x86_64) - # tag our seabios builds SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org" @@ -66,6 +49,13 @@ default: @echo " skiboot -- update skiboot.lid" @echo " u-boot.e500 -- update u-boot.e500" +SRC_PATH=.. +include $(SRC_PATH)/rules.mak + +powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) +powerpc_cross_prefix := $(call find-cross-prefix,powerpc) +x86_64_cross_prefix := $(call find-cross-prefix,x86_64) + bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin diff --git a/rules.mak b/rules.mak index 6e943335f3..ef8adee3f8 100644 --- a/rules.mak +++ b/rules.mak @@ -62,6 +62,21 @@ expand-objs = $(strip $(sort $(filter %.o,$1)) \ $(foreach o,$(filter %.mo,$1),$($o-objs)) \ $(filter-out %.o %.mo,$1)) +# Cross compilation auto detection. Use find-cross-prefix to detect the +# target archtecture's prefix, and then append it to the build tool or pass +# it to CROSS_COMPILE directly. Here is one example: +# x86_64_cross_prefix := $(call find-cross-prefix,x86_64) +# $(x86_64_cross_prefix)gcc -c test.c -o test.o +# make -C testdir CROSS_COMPILE=$(x86_64_cross_prefix) +cross-search-path := $(subst :, ,$(PATH)) +cross-host-system := $(shell uname -s | tr "A-Z" "a-z") + +find-cross-ld = $(firstword $(wildcard $(patsubst \ + %,%/$(1)-*$(cross-host-system)*-ld,$(cross-search-path)))) +find-cross-gcc = $(firstword $(wildcard \ + $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) +find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) + %.o: %.c $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \ $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \