xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0 of 2] Fixes for cross-compiling 32 bit tools on 64 bit host
@ 2011-11-14 21:53 Andres Lagar-Cavilla
  2011-11-14 21:53 ` [PATCH 1 of 2] Add linker flags to makefile rules to enable cross compiling Andres Lagar-Cavilla
  2011-11-14 21:53 ` [PATCH 2 of 2] Fixes for cross-compiling 32-bit tools on 64-bit host Andres Lagar-Cavilla
  0 siblings, 2 replies; 4+ messages in thread
From: Andres Lagar-Cavilla @ 2011-11-14 21:53 UTC (permalink / raw)
  To: xen-devel; +Cc: andres, adin

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.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Adin Scannell <adin@scannell.ca>

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

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

* [PATCH 1 of 2] Add linker flags to makefile rules to enable cross compiling
  2011-11-14 21:53 [PATCH 0 of 2] Fixes for cross-compiling 32 bit tools on 64 bit host Andres Lagar-Cavilla
@ 2011-11-14 21:53 ` Andres Lagar-Cavilla
  2011-11-15  8:55   ` Ian Campbell
  2011-11-14 21:53 ` [PATCH 2 of 2] Fixes for cross-compiling 32-bit tools on 64-bit host Andres Lagar-Cavilla
  1 sibling, 1 reply; 4+ messages in thread
From: Andres Lagar-Cavilla @ 2011-11-14 21:53 UTC (permalink / raw)
  To: xen-devel; +Cc: andres, adin

 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 <adin@scannell.ca>

diff -r 1f9e4cde0093 -r bf47f7aaf669 config/x86_32.mk
--- a/config/x86_32.mk
+++ b/config/x86_32.mk
@@ -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
diff -r 1f9e4cde0093 -r bf47f7aaf669 config/x86_64.mk
--- a/config/x86_64.mk
+++ b/config/x86_64.mk
@@ -9,6 +9,7 @@ CONFIG_XCUTILS := y
 CONFIG_IOEMU := y
 
 CFLAGS += -m64
+LDFLAGS += -m64
 
 LIBLEAFDIR = $(LIBLEAFDIR_x86_64)
 LIBDIR = $(LIBDIR_x86_64)

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

* [PATCH 2 of 2] Fixes for cross-compiling 32-bit tools on 64-bit host
  2011-11-14 21:53 [PATCH 0 of 2] Fixes for cross-compiling 32 bit tools on 64 bit host Andres Lagar-Cavilla
  2011-11-14 21:53 ` [PATCH 1 of 2] Add linker flags to makefile rules to enable cross compiling Andres Lagar-Cavilla
@ 2011-11-14 21:53 ` Andres Lagar-Cavilla
  1 sibling, 0 replies; 4+ messages in thread
From: Andres Lagar-Cavilla @ 2011-11-14 21:53 UTC (permalink / raw)
  To: xen-devel; +Cc: andres, adin

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

Signed-off-by: Adin Scannell <adin@scannell.ca>
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

diff -r bf47f7aaf669 -r 19a5a2cddad3 tools/Makefile
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -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
diff -r bf47f7aaf669 -r 19a5a2cddad3 tools/blktap/drivers/Makefile
--- a/tools/blktap/drivers/Makefile
+++ b/tools/blktap/drivers/Makefile
@@ -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
diff -r bf47f7aaf669 -r 19a5a2cddad3 tools/blktap2/vhd/lib/Makefile
--- a/tools/blktap2/vhd/lib/Makefile
+++ b/tools/blktap2/vhd/lib/Makefile
@@ -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
diff -r bf47f7aaf669 -r 19a5a2cddad3 tools/debugger/gdbsx/Makefile
--- a/tools/debugger/gdbsx/Makefile
+++ b/tools/debugger/gdbsx/Makefile
@@ -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
diff -r bf47f7aaf669 -r 19a5a2cddad3 tools/libaio/src/Makefile
--- a/tools/libaio/src/Makefile
+++ b/tools/libaio/src/Makefile
@@ -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=
diff -r bf47f7aaf669 -r 19a5a2cddad3 tools/libfsimage/common/Makefile
--- a/tools/libfsimage/common/Makefile
+++ b/tools/libfsimage/common/Makefile
@@ -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

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

* Re: [PATCH 1 of 2] Add linker flags to makefile rules to enable cross compiling
  2011-11-14 21:53 ` [PATCH 1 of 2] Add linker flags to makefile rules to enable cross compiling Andres Lagar-Cavilla
@ 2011-11-15  8:55   ` Ian Campbell
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2011-11-15  8:55 UTC (permalink / raw)
  To: Andres Lagar-Cavilla
  Cc: andres@gridcentric.ca, xen-devel@lists.xensource.com,
	adin@gridcentric.ca

On Mon, 2011-11-14 at 21:53 +0000, Andres Lagar-Cavilla wrote:
> 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 <adin@scannell.ca>
> 
> diff -r 1f9e4cde0093 -r bf47f7aaf669 config/x86_32.mk
> --- a/config/x86_32.mk
> +++ b/config/x86_32.mk
> @@ -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
<4E844703020000780005868E@nat28.tlf.novell.com>.

Ian.

>  
>  # Use only if calling $(LD) directly.
>  LDFLAGS_DIRECT_OpenBSD = _obsd
> diff -r 1f9e4cde0093 -r bf47f7aaf669 config/x86_64.mk
> --- a/config/x86_64.mk
> +++ b/config/x86_64.mk
> @@ -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
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

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

end of thread, other threads:[~2011-11-15  8:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14 21:53 [PATCH 0 of 2] Fixes for cross-compiling 32 bit tools on 64 bit host Andres Lagar-Cavilla
2011-11-14 21:53 ` [PATCH 1 of 2] Add linker flags to makefile rules to enable cross compiling Andres Lagar-Cavilla
2011-11-15  8:55   ` Ian Campbell
2011-11-14 21:53 ` [PATCH 2 of 2] Fixes for cross-compiling 32-bit tools on 64-bit host Andres Lagar-Cavilla

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