Skip to contentSkip to conversation

grub2: pass target NM, OBJCOPY and STRIP

PATCH New Arnout Vandecappelle (Essensium/Mind) 2 participants 2 messages Sep 8, 2015 – Sep 20, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 grub2: pass target NM, OBJCOPY and STRIP

Fixes https://bugs.busybox.net/show_bug.cgi?id=8256

grub2's build system interprets CC, CFLAGS and CPPFLAGS as for the host and uses TARGET_CC etc. for the target. However, NM, OBJCOPY and STRIP are used for the target. We currently pass the host-versions of these tools as part of $(HOST_CONFIGURE_OPTS).

While we're at it, also pass TARGET_LDFLAGS.

This problem had not been noticed up to now because usually we build on an x86 machine for the x86 architecture, so the binutils are compatible. However, this is not true on an i386 when building for x86_64.

---
I only did a build test, with an i386 host, so I haven't even verified that the bug is really solved. Christophe, can you do that and add your Tested-by tag if it works for you?

---
 boot/grub2/grub2.mk | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
boot/grub2/grub2.mk +10 -3
index 1fc910e..88a46f4 100644
@@ -40,15 +40,22 @@ endif
 
 # Grub2 is kind of special: it considers CC, LD and so on to be the
 # tools to build the native tools (i.e to be executed on the build
-# machine), and uses TARGET_CC, TARGET_CFLAGS, TARGET_CPPFLAGS to
-# build the bootloader itself.
+# machine), and uses TARGET_CC, TARGET_CFLAGS, TARGET_CPPFLAGS,
+# TARGET_LDFLAGS to build the bootloader itself. However, to add to
+# the confusion, it also uses NM, OBJCOPY and STRIP to build the
+# bootloader itself; none of these are used to build the native
+# tools.
 
 GRUB2_CONF_ENV = \
 	$(HOST_CONFIGURE_OPTS) \
 	CPP="$(HOSTCC) -E" \
 	TARGET_CC="$(TARGET_CC)" \
 	TARGET_CFLAGS="$(TARGET_CFLAGS)" \
-	TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)"
+	TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" \
+	TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
+	NM="$(TARGET_NM)" \
+	OBJCOPY="$(TARGET_OBJCOPY)" \
+	STRIP="$(TARGET_STRIP)"
 
 GRUB2_CONF_OPTS = \
 	--target=$(GRUB2_TARGET) \
Signature · 1 line
2.5.1
#1 lore raw

PATCH 1/1 grub2: pass target NM, OBJCOPY and STRIP

Dear Arnout Vandecappelle (Essensium/Mind),

Quoted 15 lines · Arnout Vandecappelle (Essensium/Mind)

Fixes https://bugs.busybox.net/show_bug.cgi?id=8256

grub2's build system interprets CC, CFLAGS and CPPFLAGS as for the host and uses TARGET_CC etc. for the target. However, NM, OBJCOPY and STRIP are used for the target. We currently pass the host-versions of these tools as part of $(HOST_CONFIGURE_OPTS).

While we're at it, also pass TARGET_LDFLAGS.

This problem had not been noticed up to now because usually we build on an x86 machine for the x86 architecture, so the binutils are compatible. However, this is not true on an i386 when building for x86_64.

Quoted 7 lines

---
I only did a build test, with an i386 host, so I haven't even verified that the bug is really solved. Christophe, can you do that and add your Tested-by tag if it works for you?

---
 boot/grub2/grub2.mk | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Applied, thanks.

Thomas

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