Skip to contentSkip to conversation

Fix 32bit xen-tools build.

PATCH In review [email protected] 3 participants 5 messages Oct 5, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix 32bit xen-tools build.

This fixes building 32bit xen-tools on a amd64 machine, i.e. "XEN_TARGET_ARCH=x86_32 make".

For ioemu I've taken the lazy path and just disabled them for cross-builds, I'll leave that to fix to someone who knows the qemu makefiles better than I do ;)

---
 config/x86_32.mk              |    6 ++++--
 tools/Makefile                |    2 +-
 tools/misc/mbootpack/Makefile |    4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)
config/x86_32.mk +4 -2
Index: build-32-unstable-11624/config/x86_32.mk
===================================================================
@@ -5,5 +5,7 @@ CONFIG_XCUTILS := y
 CONFIG_IOEMU := y
 CONFIG_MBOOTPACK := y
 
-CFLAGS += -m32 -march=i686
-LIBDIR := lib
+CFLAGS  += -m32 -march=i686
+LDFLAGS += -m32
+ASFLAGS += -m32
+LIBDIR  := lib
tools/misc/mbootpack/Makefile +2 -2
Index: build-32-unstable-11624/tools/misc/mbootpack/Makefile
===================================================================
@@ -35,7 +35,7 @@ DEPFLAGS = -Wp,-MD,.$(@F).d
 DEPS     = .*.d
 
 mbootpack: $(OBJS)
-	$(HOSTCC) -o $@ $(filter-out %.a, $^)
+	$(HOSTCC) $(CFLAGS) -o $@ $(filter-out %.a, $^)
 
 .PHONY: clean
 clean:
@@ -50,7 +50,7 @@ setup: setup.S
 	$(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary setup.o -o $@
 
 bin2c: bin2c.o 
-	$(HOSTCC) -o $@ $^ 
+	$(HOSTCC) $(CFLAGS) -o $@ $^
 
 bzimage_header.c: bootsect setup bin2c
 	./bin2c -n 8 -b1 -a bzimage_bootsect bootsect > bzimage_header.c
tools/Makefile +1 -1
Index: build-32-unstable-11624/tools/Makefile
===================================================================
@@ -60,7 +60,7 @@ check_clean:
 	$(MAKE) -C check clean
 
 .PHONY: ioemu ioemuinstall ioemuclean
-ifdef CONFIG_IOEMU
+ifeq ($(XEN_COMPILE_ARCH)$(CONFIG_IOEMU),$(XEN_TARGET_ARCH)y)
 export IOEMU_DIR ?= ioemu
 ioemu ioemuinstall:
 	[ -f $(IOEMU_DIR)/config-host.mak ] || \

--

#1 lore raw
Quoted 6 lines · On 5/10/06 9:48 am, "[email protected]" <[email protected]> wrote:

This fixes building 32bit xen-tools on a amd64 machine, i.e. "XEN_TARGET_ARCH=x86_32 make".

For ioemu I've taken the lazy path and just disabled them for cross-builds, I'll leave that to fix to someone who knows the qemu makefiles better than I do ;)

The mbootpack change seems wrong. It's not installed on the target machine (it's a build-system tool) so it should actually be built with HOSTCFLAGS, not CFLAGS. Is that reasonable?

Presumably the most important part of this patch is the change to LDFLAGS and ASFLAGS? I suppose any halfway modern version of binutils must support those flags (otherwise gcc -m32 wouldn't work)?

-- Keir

#2 lore raw
Quoted 3 lines · Keir Fraser

The mbootpack change seems wrong. It's not installed on the target machine (it's a build-system tool) so it should actually be built with HOSTCFLAGS, not CFLAGS. Is that reasonable?

For the x86_32 on x86_64 it works as-is, because the 32bit binaries work on 64bit too. Looking at it strictly it is indeed not fully correct though, HOSTCCFLAGS should be used instead. But some more tweaks are needed then, you'll have to take care that the object files are compiled with HOSTCC (and HOSTCFLAGS) too (they are not at the moment).

Quoted 2 lines

Presumably the most important part of this patch is the change to LDFLAGS and ASFLAGS?

Yes, that makes most bits compile fine, except qemu-dm.

Quoted 2 lines

I suppose any halfway modern version of binutils must support those flags (otherwise gcc -m32 wouldn't work)?

Yes, gcc passes -m32 through to the linker.

cheers,

Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#3 lore raw
Quoted 5 lines · Gerd Hoffmann

For the x86_32 on x86_64 it works as-is, because the 32bit binaries work on 64bit too. Looking at it strictly it is indeed not fully correct though, HOSTCCFLAGS should be used instead. But some more tweaks are needed then, you'll have to take care that the object files are compiled with HOSTCC (and HOSTCFLAGS) too (they are not at the moment).

While playing with that: mbootpack.c doesn't even build with -m64, so its probably best to simply stick with compiling 32bit binaries ...

cheers,
Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#4 lore raw
In reply to Gerd Hoffmann
Quoted 4 lines · Gerd Hoffmann
Quoted 2 lines

I suppose any halfway modern version of binutils must support those flags (otherwise gcc -m32 wouldn't work)?

Yes, gcc passes -m32 through to the linker.

This happens to work out OK on Solaris too: although the linker doesn't understand -m32/-m64 (Solaris ld knows about "-64" only), our gcc /does/, and we've explicitly set $(LD) to GNU ld.

regards
john