Fixes for cross-compiling 32 bit tools on 64 bit host
PATCH 1/1 Fixes for cross-compiling 32 bit tools on 64 bit host
Using this patch series, we routinely compile the entire toolstack in 32 bit mode on a 64 bit box, no erros or warnings (compilatio-/ linking-related). Please apply.
config/x86_32.mk | 1 + config/x86_64.mk | 1 + tools/Makefile | 8 +++++++- tools/blktap/drivers/Makefile | 1 + tools/blktap2/vhd/lib/Makefile | 1 + tools/debugger/gdbsx/Makefile | 2 +- tools/libaio/src/Makefile | 2 +- tools/libfsimage/common/Makefile | 4 ++-- 8 files changed, 15 insertions(+), 5 deletions(-)
PATCH 1/1 Add linker flags to makefile rules to enable cross compiling
config/x86_32.mk | 1 + config/x86_64.mk | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
For cross-compiling, the link step must also include necessary architecture flags (otherwise there's a mismatch between input objects and the output we're trying to produce).
config/x86_32.mk +1 -0
@@ -8,6 +8,7 @@ CONFIG_XCUTILS := y CONFIG_IOEMU := y CFLAGS += -m32 -march=i686 +LDFLAGS += -m32 -march=i686 # Use only if calling $(LD) directly. LDFLAGS_DIRECT_OpenBSD = _obsd
config/x86_64.mk +1 -0
@@ -9,6 +9,7 @@ CONFIG_XCUTILS := y CONFIG_IOEMU := y CFLAGS += -m64 +LDFLAGS += -m64 LIBLEAFDIR = $(LIBLEAFDIR_x86_64) LIBDIR = $(LIBDIR_x86_64)
PATCH 1/1 Fixes for cross-compiling 32-bit tools on 64-bit host
In reply to Andres Lagar-Cavillatools/Makefile | 8 +++++++- tools/blktap/drivers/Makefile | 1 + tools/blktap2/vhd/lib/Makefile | 1 + tools/debugger/gdbsx/Makefile | 2 +- tools/libaio/src/Makefile | 2 +- tools/libfsimage/common/Makefile | 4 ++-- 6 files changed, 13 insertions(+), 5 deletions(-)
With this patch a full 32 bit build of the tool set is possible on a 64 bit host. No errors or warnigns.
tools/Makefile +7 -1
@@ -74,7 +74,13 @@ distclean: subdirs-distclean rm -rf ioemu-dir ioemu-remote ifneq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) -IOEMU_CONFIGURE_CROSS ?= --cpu=$(XEN_TARGET_ARCH) \ +ifeq ($(XEN_TARGET_ARCH),x86_32) +# The qemu build uses i386 instead of x86_32. +IOEMU_CONFIGURE_CPU ?= --cpu=i386 +else +IOEMU_CONFIGURE_CPU ?= --cpu=$(XEN_TARGET_ARCH) +endif +IOEMU_CONFIGURE_CROSS ?= $(IOEMU_CONFIGURE_CPU) \ --cross-prefix=$(CROSS_COMPILE) \ --interp-prefix=$(CROSS_SYS_ROOT) endif
tools/blktap/drivers/Makefile +1 -0
@@ -14,6 +14,7 @@ CFLAGS += $(CFLAGS_libxenstore) CFLAGS += -I $(LIBAIO_DIR) CFLAGS += -I $(MEMSHR_DIR) CFLAGS += -D_GNU_SOURCE +CFLAGS += -D_FILE_OFFSET_BITS=64 ifeq ($(shell . ./check_gcrypt $(CC)),yes) CFLAGS += -DUSE_GCRYPT
tools/blktap2/vhd/lib/Makefile +1 -0
@@ -18,6 +18,7 @@ CFLAGS += -I../../include CFLAGS += -D_GNU_SOURCE CFLAGS += -fPIC CFLAGS += -g +CFLAGS += -D_FILE_OFFSET_BITS=64 ifeq ($(CONFIG_Linux),y) LIBS := -luuid
tools/debugger/gdbsx/Makefile +1 -1
@@ -18,7 +18,7 @@ install: all $(INSTALL_PROG) gdbsx $(DESTDIR)$(SBINDIR)/gdbsx gdbsx: gx/gx_all.a xg/xg_all.a - $(CC) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ xg/xg_all.a: $(MAKE) -C xg
tools/libaio/src/Makefile +1 -1
@@ -6,7 +6,7 @@ includedir=$(prefix)/include libdir=$(prefix)/lib ARCH := $(shell uname -m | sed -e s/i.86/i386/) -CFLAGS = -nostdlib -nostartfiles -Wall -I. -g -fomit-frame-pointer -O2 -fPIC +CFLAGS := $(CFLAGS) -nostdlib -nostartfiles -Wall -I. -g -fomit-frame-pointer -O2 -fPIC SO_CFLAGS=-shared $(CFLAGS) L_CFLAGS=$(CFLAGS) LINK_FLAGS=
tools/libfsimage/common/Makefile +2 -2
@@ -4,8 +4,8 @@ include $(XEN_ROOT)/tools/Rules.mk MAJOR = 1.0 MINOR = 0 -LDFLAGS-$(CONFIG_SunOS) = -Wl,-M -Wl,mapfile-SunOS -LDFLAGS-$(CONFIG_Linux) = -Wl,mapfile-GNU +LDFLAGS-$(CONFIG_SunOS) := $(LDFLAGS) -Wl,-M -Wl,mapfile-SunOS +LDFLAGS-$(CONFIG_Linux) := $(LDFLAGS) -Wl,mapfile-GNU LDFLAGS = $(LDFLAGS-y) LIB_SRCS-y = fsimage.c fsimage_plugin.c fsimage_grub.c
Re: [PATCH 1 of 2] Add linker flags to makefile rules to enable cross compiling
In reply to Andres Lagar-CavillaQuoted 15 lines · Andres Lagar-Cavilla
config/x86_32.mk| 1 +config/x86_64.mk | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)For cross-compiling, the link step must also include necessary architecture flags (otherwise there's a mismatch between input objects and the output we're trying to produce).
Signed-off-by Adin Scannell <[email protected]>diff -r
1f9e4cde0093-rbf47f7aaf669config/x86_32.mk
config/x86_32.mk CONFIG_XCUTILS := y · line 11
Quoted 4 lines
config/x86_32.mk +1
-0@@ -8,6 +8,7 @@ CONFIG_XCUTILS := y CONFIG_IOEMU := y CFLAGS += -m32 -march=i686 +LDFLAGS += -m32 -march=i686
I think when Adin posted this we determined that it only worked by coincidence, since when we invoke ld directly it is as
ld $(LDFLAGS) -melf_x86_64
so while -m32 -march= are unknown to ld the -nelf_xx (which is a valid ld option) takes precedence and things work ok.
The consensus then was that we need to split LDFLAGS-for-gcc-as-linker from LDFLAGS-for-ld-directly into two variables. See Jan's response in <[email protected]>.
Ian.
Quoted 19 lines
config/x86_32.mk +0
-0# Use only if calling $(LD) directly. LDFLAGS_DIRECT_OpenBSD = _obsddiff -r
1f9e4cde0093-rbf47f7aaf669config/x86_64.mkconfig/x86_64.mk +1
-0@@ -9,6 +9,7 @@ CONFIG_XCUTILS := y CONFIG_IOEMU := y CFLAGS += -m64 +LDFLAGS += -m64 LIBLEAFDIR = $(LIBLEAFDIR_x86_64) LIBDIR = $(LIBDIR_x86_64)_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel