Skip to contentSkip to conversation

Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER

PATCH New Chris Lesiak 2 participants 4 messages May 9, 2014 – Apr 23, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER

Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER

When building grub and syslinux, the 32-bit host compiler is only needed when building for 64-bit target. For 32-bit targets, the target compiler will work.

This change makes it less likely that a mulilib host is needed.

---
 boot/grub/Config.in       |  2 +-
 boot/grub/grub.mk         |  6 ++++++
 boot/syslinux/Config.in   |  2 +-
 boot/syslinux/syslinux.mk | 18 ++++++++++++++----
 4 files changed, 22 insertions(+), 6 deletions(-)
boot/grub/Config.in +1 -1
index 4db8642..86e1753 100644
@@ -1,7 +1,7 @@
 config BR2_TARGET_GRUB
 	bool "grub"
 	depends on BR2_i386 || BR2_x86_64
-	select BR2_HOSTARCH_NEEDS_IA32_COMPILER
+	select BR2_HOSTARCH_NEEDS_IA32_COMPILER if BR2_ARCH_IS_64
 	help
 	  The GRand Unified Bootloader for x86 systems.
 
boot/grub/grub.mk +6 -0
index dc11307..8c02fe3 100644
@@ -71,9 +71,15 @@ endef
 
 GRUB_POST_PATCH_HOOKS += GRUB_DEBIAN_PATCHES
 
+ifeq ($(BR2_HOSTARCH_NEEDS_IA32_COMPILER),y)
 GRUB_CONF_ENV = \
 	$(HOST_CONFIGURE_OPTS) \
 	CFLAGS="$(HOST_CFLAGS) $(GRUB_CFLAGS) -m32"
+else
+GRUB_CONF_ENV = \
+	$(TARGET_CONFIGURE_OPTS) \
+	CFLAGS="$(TARGET_CFLAGS) $(GRUB_CFLAGS)"
+endif
 
 GRUB_CONF_OPT = \
 	--disable-auto-linux-mem-opt \
boot/syslinux/Config.in +1 -1
index f4b9870..8d32214 100644
@@ -1,7 +1,7 @@
 config BR2_TARGET_SYSLINUX
 	bool "syslinux"
 	depends on BR2_i386 || BR2_x86_64
-	select BR2_HOSTARCH_NEEDS_IA32_COMPILER
+	select BR2_HOSTARCH_NEEDS_IA32_COMPILER if BR2_ARCH_IS_64
 	help
 	  The syslinux bootloader for x86 systems.
 	  This includes: syslinux, pxelinux, extlinux.
boot/syslinux/syslinux.mk +14 -4
index 51b6417..c20a817 100644
@@ -39,12 +39,22 @@ define SYSLINUX_CLEANUP
 endef
 SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
 
+ifeq ($(BR2_HOSTARCH_NEEDS_IA32_COMPILER),y)
+	SYSLINUX_CC = $(HOSTCC)
+	SYSLINUX_LDFLAGS = $(HOST_LDFLAGS)
+	SYSLINUX_AR = $(HOSTAR)
+else
+	SYSLINUX_CC = $(TARGET_CC)
+	SYSLINUX_LDFLAGS = $(TARGET_LDFLAGS)
+	SYSLINUX_AR = $(TARGET_AR)
+endif
+
 # syslinux build system has no convenient way to pass CFLAGS,
 # and the internal zlib should take precedence so -I shouldn't
 # be used.
 define SYSLINUX_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) CC="$(HOSTCC) -idirafter $(HOST_DIR)/usr/include $(HOST_LDFLAGS)" \
-	    AR="$(HOSTAR)" SYSROOT=$(STAGING_DIR) -C $(@D) $(SYSLINUX_TARGET)
+	$(TARGET_MAKE_ENV) $(MAKE1) CC="$(SYSLINUX_CC) -idirafter $(HOST_DIR)/usr/include $(SYSLINUX_LDFLAGS)" \
+	    AR="$(SYSLINUX_AR)" SYSROOT=$(STAGING_DIR) -C $(@D) $(SYSLINUX_TARGET)
 endef
 
 # While the actual bootloader is compiled for the target, several
@@ -53,8 +63,8 @@ endef
 # Repeat CC and AR, since syslinux really wants to check them at
 # install time
 define SYSLINUX_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) CC="$(HOSTCC) -idirafter $(HOST_DIR)/usr/include $(HOST_LDFLAGS)" \
-	    AR="$(HOSTAR)" SYSROOT=$(STAGING_DIR) INSTALLROOT=$(HOST_DIR) \
+	$(TARGET_MAKE_ENV) $(MAKE1) CC="$(SYSLINUX_CC) -idirafter $(HOST_DIR)/usr/include $(SYSLINUX_LDFLAGS)" \
+	    AR="$(SYSLINUX_AR)" SYSROOT=$(STAGING_DIR) INSTALLROOT=$(HOST_DIR) \
 	    -C $(@D) $(SYSLINUX_TARGET) install
 endef
 
Signature · 1 line
1.9.0
#1 lore raw

PATCH 1/1 Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER

Dear Chris Lesiak,

Quoted 9 lines · Chris Lesiak

Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER

When building grub and syslinux, the 32-bit host compiler is only needed when building for 64-bit target. For 32-bit targets, the target compiler will work.

This change makes it less likely that a mulilib host is needed.

Sorry for the very late answer. Unfortunately, your patch doesn't work properly with the following defconfig:

BR2_x86_pentium4=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-i386-pentium4-full-2015.02.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_2=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_GRUB=y
BR2_TARGET_SYSLINUX=y

It fails during the syslinux build with:

/home/thomas/projets/buildroot/output/build/syslinux-6.03/bios/core/../lzo/prepcore ldlinux.raw ldlinux.bin make[4]: /home/thomas/projets/buildroot/output/build/syslinux-6.03/bios/core/../lzo/prepcore: Command not found /home/thomas/projets/buildroot/output/build/syslinux-6.03/core/Makefile:153: recipe for target 'ldlinux.bin' failed

This is because, using your patch, syslinux gets built with the target compiler instead of the host compiler. While this generally works, it doesn't work in the specific case of the prepcore program, which gets built with the target compiler, but executed on the host. And since I'm using a uClibc toolchain for the target, the resulting program cannot run on my glibc based machine.

There is probably a way to adjust the syslinux build process to avoid this, but I don't know if it's really worth the effort.

I've marked your patch as "Changes Requested". Do not hesitate to repost an updated version that fixes this problem.

Thanks for your contribution,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER

Dear Thomas Petazzoni,

Quoted 11 lines · Thomas Petazzoni

<Thomas explains why the patch fails for syslinux>

There is probably a way to adjust the syslinux build process to avoid this, but I don't know if it's really worth the effort.

I've marked your patch as "Changes Requested". Do not hesitate to repost an updated version that fixes this problem.

Thanks for your contribution,

Thomas

Thank you for reviewing this patch. I'm sorry for having missed the problem with syslinux. I do agree that adjusting the syslinux build process is not worth the effort because installing the 32-bit libraries on the host is easy.

However, if you want, I can repost with only the changes for grub.

Signature · 7 lines
Chris Lesiak
Principal Design Engineer, Software
LI-COR, Inc.
chris.lesiak at licor.com

Any opinions expressed are those of the author and
do not necessarily represent those of his employer.
#3 lore raw

PATCH 1/1 Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER

Chris,

Quoted 4 lines · Chris Lesiak

Thank you for reviewing this patch. I'm sorry for having missed the problem with syslinux. I do agree that adjusting the syslinux build process is not worth the effort because installing the 32-bit libraries on the host is easy.

Yes indeed.

Quoted 1 line

However, if you want, I can repost with only the changes for grub.

Sure!

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com