diff mbox

[U-Boot] x86: Enable 32-bit build using x86_64 multilib toolchain

Message ID 1402406096-11744-1-git-send-email-vvv444@gmail.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Vasili Galka June 10, 2014, 1:14 p.m. UTC
Until now building the x86 arch boards required 32-bit toolchain. As
many x86_64 toolchains come with 32-bit support (multilib) that's a
good idea to enable build with such toolchains.

The change required was to specify the usage of 32-bit explicitly to
the compiler and the linker (-m32 and -m elf_i386 flags) and locate
the right libgcc path.

Signed-off-by: Vasili Galka <vvv444@gmail.com>
---

For example on x86_64 Ubuntu "sudo apt-get install gcc-multilib" is enough and no need to install additional 32-bit toolchain.

 arch/x86/config.mk     |    5 +++--
 arch/x86/cpu/config.mk |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

Comments

Simon Glass June 12, 2014, 4:37 a.m. UTC | #1
On 10 June 2014 09:14, Vasili Galka <vvv444@gmail.com> wrote:
> Until now building the x86 arch boards required 32-bit toolchain. As
> many x86_64 toolchains come with 32-bit support (multilib) that's a
> good idea to enable build with such toolchains.
>
> The change required was to specify the usage of 32-bit explicitly to
> the compiler and the linker (-m32 and -m elf_i386 flags) and locate
> the right libgcc path.
>
> Signed-off-by: Vasili Galka <vvv444@gmail.com>
> ---
>
> For example on x86_64 Ubuntu "sudo apt-get install gcc-multilib" is enough and no need to install additional 32-bit toolchain.

This seems reasonable to me.

Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass June 26, 2014, 2:19 a.m. UTC | #2
On 11 June 2014 22:37, Simon Glass <sjg@chromium.org> wrote:
> On 10 June 2014 09:14, Vasili Galka <vvv444@gmail.com> wrote:
>> Until now building the x86 arch boards required 32-bit toolchain. As
>> many x86_64 toolchains come with 32-bit support (multilib) that's a
>> good idea to enable build with such toolchains.
>>
>> The change required was to specify the usage of 32-bit explicitly to
>> the compiler and the linker (-m32 and -m elf_i386 flags) and locate
>> the right libgcc path.
>>
>> Signed-off-by: Vasili Galka <vvv444@gmail.com>
>> ---
>>
>> For example on x86_64 Ubuntu "sudo apt-get install gcc-multilib" is enough and no need to install additional 32-bit toolchain.
>
> This seems reasonable to me.
>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-x86/sandbox, thanks!
diff mbox

Patch

diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 38cb7c9..3106079 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -16,17 +16,18 @@  PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
 PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
 PLATFORM_CPPFLAGS += -DREALMODE_BASE=0x7c0
+PLATFORM_CPPFLAGS += -march=i386 -m32
 
 # Support generic board on x86
 __HAVE_ARCH_GENERIC_BOARD := y
 
 PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
 
-PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions
+PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions -m elf_i386
 
 LDFLAGS_FINAL += --gc-sections -pie
 LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
 LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
 
-export NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+export NORMAL_LIBGCC = $(shell $(CC) $(PLATFORM_CPPFLAGS) -print-libgcc-file-name)
 CONFIG_USE_PRIVATE_LIBGCC := arch/x86/lib
diff --git a/arch/x86/cpu/config.mk b/arch/x86/cpu/config.mk
index c1568cac..4b2c873 100644
--- a/arch/x86/cpu/config.mk
+++ b/arch/x86/cpu/config.mk
@@ -7,7 +7,7 @@ 
 
 CROSS_COMPILE ?= i386-linux-
 
-PLATFORM_CPPFLAGS += -DCONFIG_X86 -D__I386__ -march=i386 -Werror
+PLATFORM_CPPFLAGS += -DCONFIG_X86 -D__I386__ -Werror
 
 # DO NOT MODIFY THE FOLLOWING UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!
 LDPPFLAGS += -DRESET_SEG_START=0xffff0000