Supporting building on x86-64 host as 32-bit UML
It is really difficult for the end-user (and tricky for a developer) to build a 32-bit UML on a 64-bit host box...
I would like to address this, but I've not definite ideas.
The problems are:
1) how the user must choose what he wants (SUBARCH=i386 can be useful, maybe a Kconfig option would be nice - we need to choose the default depending on the host arch).
2) using the proper options for the tools (addressed partially by the patch below)
3) using the proper headers (asm-i386 instead of asm-x86_64)... Fedora (I don't know about SuSE and my Gentoo is 32-bit still) uses some smart headers that select the correct version, basing on some macros defined by GCC:
#ifndef __ASM_STUB_SYSTEM_H__
# define __ASM_STUB_SYSTEM_H__ # if defined __x86_64__ # include <asm-x86_64/system.h> # endif # if defined __i386__ # include <asm-i386/system.h> # endif #endif
The problem is that we explicitly refuse to define these macros, like this:
CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH)
(from arch/um/Makefile-i386) for which I don't find a valid reason... I first thought this was
diff -puN arch/um/Makefile~uml-build-on-x86_64_as_i386 arch/um/Makefile --- linux-2.6.9-current/arch/um/Makefile~uml-build-on-x86_64_as_i386
2004-09-26 19:51:43.000000000 +0200
+++ linux-2.6.9-current-paolo/arch/um/Makefile 2004-09-26 19:59:17.000000000 +0200
@@ -34,6 +34,13 @@ endif
ARCH_INCLUDE := -I$(ARCH_DIR)/include
SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
+AFLAGS += -m32
+CFLAGS += -m32
+LDFLAGS += -melf_i386
+HOSTCFLAGS += -m32
+HOSTLDFLAGS += -m32
+export HOSTLDFLAGS
+
include $(ARCH_DIR)/Makefile-$(SUBARCH)
include $(ARCH_DIR)/Makefile-os-$(OS)
Signature · 3 lines
Paolo Giarrusso, aka Blaisorblade Linux registered user n. 292729 http://www.user-mode-linux.org/~blaisorblade
---
linux-2.6.9-current-paolo/arch/um/Makefile | 7 +++++++ 1 files changed, 7 insertions(+)
arch/um/Makefile renamed from arch/um/Makefile~uml-build-on-x86_64_as_i386 +7 -0
@@ -34,6 +34,13 @@ endif ARCH_INCLUDE := -I$(ARCH_DIR)/include SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) +AFLAGS += -m32 +CFLAGS += -m32 +LDFLAGS += -melf_i386 +HOSTCFLAGS += -m32 +HOSTLDFLAGS += -m32 +export HOSTLDFLAGS + include $(ARCH_DIR)/Makefile-$(SUBARCH) include $(ARCH_DIR)/Makefile-os-$(OS)
_
Quoted 3 lines
1) how the user must choose what he wants (SUBARCH=i386 can be useful, maybe a
Kconfigoption would be nice - we need to choose the default depending on the host arch).
That one is easy -- just use "linux32 make ...". That will switch the personality and "uname" will return "i686" instead of "x86_64" then ;)
Quoted 2 lines
2) using the proper options for the tools (addressed partially by the patch below)
Probably still needed. Maybe not any more with gcc4, I remember there was some discussion among the gcc folks to make gcc default to -m64 / -m32 depending on the current personalily. In that case the linux32 thingy mentioned above should catch that one as well. Not sure that actually happened.
Quoted 1 line
3) using the proper headers (asm-i386 instead of asm-x86_64)... Fedora
linux32 should fix that one as well.
arch/um/Makefile endif · line 38
Quoted 2 lines
arch/um/Makefile renamed from arch/um/Makefile~uml-build-on-x86_64_as_i386 +2
-0+AFLAGS += -m32 +CFLAGS += -m32
I think that can also be fixed on the make command line, with a small wrapper script -- named make32 for example -- doing something like this:
#!/bin/sh
exec linux32 make CC="gcc -m32" AS="as -m32" ... "$@"
Last time I tried I ran into the problem that the glibc headers of the x86_64 biarch compiler slightly different from the ones on a real i386 machine, thus some #ifdefs in uml userspace code didn't work as expected and broke the build.
arch/um/Makefile endif · line 41
Quoted 2 lines
arch/um/Makefile renamed from arch/um/Makefile~uml-build-on-x86_64_as_i386 +2
-0+HOSTCFLAGS += -m32 +HOSTLDFLAGS += -m32
Not needed I think. Thats used for kconfig and other stuff which runs on the _host_ machine (for cross compiles), thus it doesn't hurt if it is 64 bit.
Gerd
Signature · 12 lines
#define printk(args...) fprintf(stderr, ## args) ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 6 lines · Gerd Knorr
Quoted 3 lines
1) how the user must choose what he wants (SUBARCH=i386 can be useful, maybe a
Kconfigoption would be nice - we need to choose the default depending on the host arch).That one is easy -- just use "linux32 make ...". That will switch the personality and "uname" will return "i686" instead of "
x86_64" then ;)
linux32 is a SuSE specific alias like the "i386" for Fedora, right (they both alias setarch, IIRC)?
Quoted 8 lines
Quoted 2 lines
2) using the proper options for the tools (addressed partially by the patch below)
Probably still needed. Maybe not any more with gcc4, I remember there was some discussion among the gcc folks to make gcc default to -m64 / -m32 depending on the current personalily. In that case the linux32 thingy mentioned above should catch that one as well. Not sure that actually happened.
We're not going to wait gcc4, especially if it is still so memory hungry...
Quoted 18 lines
Quoted 1 line
3) using the proper headers (asm-i386 instead of asm-x86_64)... Fedora
linux32 should fix that one as well.
arch/um/Makefile endif · line 38
Quoted 2 lines
arch/um/Makefile renamed from arch/um/Makefile~uml-build-on-x86_64_as_i386 +2
-0+AFLAGS += -m32 +CFLAGS += -m32I think that can also be fixed on the make command line, with a small wrapper script -- named make32 for example -- doing something like this:
#!/bin/sh
exec linux32 make CC="gcc -m32" AS="as -m32" ... "$@"Last time I tried I ran into the problem that the glibc headers of the
x86_64biarch compiler slightly different from the ones on a real i386 machine, thus some #ifdefs in uml userspace code didn't work as expected and broke the build.
Quoted 6 lines
arch/um/Makefile endif · line 41
Quoted 2 lines
arch/um/Makefile renamed from arch/um/Makefile~uml-build-on-x86_64_as_i386 +2
-0+HOSTCFLAGS += -m32 +HOSTLDFLAGS += -m32Not needed I think. Thats used for kconfig and other stuff which runs on the _host_ machine (for cross compiles), thus it doesn't hurt if it is 64 bit.
I'm not sure, but that's probably needed for the userspace utilities that print out some headers (with offsets inside host proc. specific structs).
Signature · 17 lines
Paolo Giarrusso, aka Blaisorblade Linux registered user n. 292729 http://www.user-mode-linux.org/~blaisorblade ------------------------------------------------------- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 9 lines · Blaisorblade
Quoted 6 lines · Gerd Knorr
Quoted 3 lines
1) how the user must choose what he wants (SUBARCH=i386 can be useful, maybe a
Kconfigoption would be nice - we need to choose the default depending on the host arch).That one is easy -- just use "linux32 make ...". That will switch the personality and "uname" will return "i686" instead of "
x86_64" then ;)linux32 is a SuSE specific alias like the "i386" for Fedora, right (they both alias setarch, IIRC)?
Don't have a "setarch" binary here. But most likely they do almost the same, yes.
Quoted 5 lines
Quoted 3 lines
Not needed I think. Thats used for kconfig and other stuff which runs on the _host_ machine (for cross compiles), thus it doesn't hurt if it is 64 bit.
I'm not sure, but that's probably needed for the userspace utilities that print out some headers (with offsets inside host proc. specific structs).
Uhm, ok, then it probably is needed. This also means that you can't cross-compile uml kernels, right?
Gerd
Signature · 12 lines
#define printk(args...) fprintf(stderr, ## args) ------------------------------------------------------- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 19 lines · Gerd Knorr
Quoted 10 lines · Blaisorblade
Quoted 6 lines · Gerd Knorr
Quoted 3 lines
1) how the user must choose what he wants (SUBARCH=i386 can be useful, maybe a
Kconfigoption would be nice - we need to choose the default depending on the host arch).That one is easy -- just use "linux32 make ...". That will switch the personality and "uname" will return "i686" instead of "
x86_64" then ;)linux32 is a SuSE specific alias like the "i386" for Fedora, right (they both alias setarch, IIRC)?
Don't have a "setarch" binary here. But most likely they do almost the same, yes.
Quoted 4 lines
Quoted 3 lines
Not needed I think. Thats used for kconfig and other stuff which runs on the _host_ machine (for cross compiles), thus it doesn't hurt if it is 64 bit.
Quoted 5 lines
Quoted 2 lines
I'm not sure, but that's probably needed for the userspace utilities that print out some headers (with offsets inside host proc. specific structs).
Uhm, ok, then it probably is needed. This also means that you can't cross-compile uml kernels, right?
Eh? Those utilities must run on the compile host, and they are compiled with HOSTCC, but use the targets header. So on x86-64 / x86 it works, but probably in general you are right (I don't have the whole picture right now, but this makes sense).
That said, Al Viro changed this significantly when working on making UML cross-compile well, so you again are probably right. I'm currently merging his work in little pieces.
Signature · 16 lines
Paolo Giarrusso, aka Blaisorblade Linux registered user n. 292729 http://www.user-mode-linux.org/~blaisorblade ------------------------------------------------------- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel