Skip to contentSkip to conversation

Allow compiling i386 with an x86-64 compiler

PATCH In review H. Peter Anvin 2 participants 3 messages Nov 24, 2004 – Nov 29, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow compiling i386 with an x86-64 compiler

This patch adds -m32 if gcc supports it, thus making it easier to compile the i386 architecture with an x86-64 compiler.

Note that it adds the option to CC, since it also affects assembly code and linking. The extra level of indirection is because $(call cc-option) itself uses $(CC), so just doing CC += ... would cause $(CC) to be recursively defined.

-hpa

Index: linux-2.5/arch/i386/Makefile
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/arch/i386/Makefile,v retrieving revision 1.72

arch/i386/Makefile +4 -0
diff -u -r1.72 Makefile
@@ -20,6 +20,10 @@
 LDFLAGS_vmlinux :=
 CHECKFLAGS	+= -D__i386__
 
+# This allows compilation with an x86-64 compiler
+CC_M32		:= $(call cc-option,-m32)
+CC 		+= $(CC_M32)
+
 CFLAGS += -pipe -msoft-float
 
 # prevent gcc from keeping the stack 16 byte aligned
#1 lore raw
Quoted 7 lines · H. Peter Anvin

This patch adds -m32 if gcc supports it, thus making it easier to compile the i386 architecture with an x86-64 compiler.

Note that it adds the option to CC, since it also affects assembly code and linking. The extra level of indirection is because $(call cc-option) itself uses $(CC), so just doing CC += ... would cause $(CC) to be recursively defined.

Just so 'bi-arch' arches look the same, I'd like to suggest (and stolen from ppc32) something like:
HAS_BIARCH := $(call cc-option-yn, -m32)
ifeq ($(HAS_BIARCH),y)
CC := $(CC) -m32
endif

Up near the top...

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#2 lore raw
Quoted 8 lines · Tom Rini
Quoted 3 lines · H. Peter Anvin

This patch adds -m32 if gcc supports it, thus making it easier to compile the i386 architecture with an x86-64 compiler.

Note that it adds the option to CC, since it also affects assembly code and linking. The extra level of indirection is because $(call cc-option) itself uses $(CC), so just doing CC += ... would cause $(CC) to be recursively defined.

Quoted 9 lines

Just so 'bi-arch' arches look the same, I'd like to suggest (and stolen from ppc32) something like:
HAS_BIARCH := $(call cc-option-yn, -m32)
ifeq ($(HAS_BIARCH),y)
CC := $(CC) -m32
endif

Up near the top...

I'm not really happy with it, because it's misleading; it implies it tests for a working x86-64 devel environment, which it doesn't. It's not a strong opinion, though.

-hpa