Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER
@ 2014-05-09 13:51 Chris Lesiak
  2015-04-22 21:45 ` Thomas Petazzoni
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Lesiak @ 2014-05-09 13:51 UTC (permalink / raw)
  To: buildroot

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.

Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>
---
 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(-)

diff --git a/boot/grub/Config.in b/boot/grub/Config.in
index 4db8642..86e1753 100644
--- a/boot/grub/Config.in
+++ b/boot/grub/Config.in
@@ -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.
 
diff --git a/boot/grub/grub.mk b/boot/grub/grub.mk
index dc11307..8c02fe3 100644
--- a/boot/grub/grub.mk
+++ b/boot/grub/grub.mk
@@ -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 \
diff --git a/boot/syslinux/Config.in b/boot/syslinux/Config.in
index f4b9870..8d32214 100644
--- a/boot/syslinux/Config.in
+++ b/boot/syslinux/Config.in
@@ -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.
diff --git a/boot/syslinux/syslinux.mk b/boot/syslinux/syslinux.mk
index 51b6417..c20a817 100644
--- a/boot/syslinux/syslinux.mk
+++ b/boot/syslinux/syslinux.mk
@@ -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
 
-- 
1.9.0

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

* [Buildroot] [PATCH] Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER
  2014-05-09 13:51 [Buildroot] [PATCH] Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER Chris Lesiak
@ 2015-04-22 21:45 ` Thomas Petazzoni
  2015-04-23 14:26   ` Chris Lesiak
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni @ 2015-04-22 21:45 UTC (permalink / raw)
  To: buildroot

Dear Chris Lesiak,

On Fri, 9 May 2014 08:51:55 -0500, Chris Lesiak wrote:
> 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.
> 
> Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>

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
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH] Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER
  2015-04-22 21:45 ` Thomas Petazzoni
@ 2015-04-23 14:26   ` Chris Lesiak
  2015-04-23 14:35     ` Thomas Petazzoni
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Lesiak @ 2015-04-23 14:26 UTC (permalink / raw)
  To: buildroot

Dear Thomas Petazzoni,

On 04/22/2015 04:45 PM, Thomas Petazzoni wrote:
> <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.

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

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

* [Buildroot] [PATCH] Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER
  2015-04-23 14:26   ` Chris Lesiak
@ 2015-04-23 14:35     ` Thomas Petazzoni
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2015-04-23 14:35 UTC (permalink / raw)
  To: buildroot

Chris,

On Thu, 23 Apr 2015 09:26:19 -0500, Chris Lesiak wrote:

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

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

Sure!

Thanks,

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

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

end of thread, other threads:[~2015-04-23 14:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-09 13:51 [Buildroot] [PATCH] Reduce need for BR2_HOSTARCH_NEEDS_IA32_COMPILER Chris Lesiak
2015-04-22 21:45 ` Thomas Petazzoni
2015-04-23 14:26   ` Chris Lesiak
2015-04-23 14:35     ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox