All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] syslinux: Builds with the target toolchain
@ 2017-04-05 10:09 Benoît Allard
  2017-04-05 11:02 ` Thomas Petazzoni
  2017-04-05 13:28 ` [Buildroot] [PATCH v2 1/2] " Benoît Allard
  0 siblings, 2 replies; 18+ messages in thread
From: Benoît Allard @ 2017-04-05 10:09 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
---
 DEVELOPERS                                             |  1 +
 boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch   | 16 ++++++++++++++++
 boot/syslinux/0004-fix-ld-oformat-32bits.patch         | 15 +++++++++++++++
 .../0005-build-utils-with-host-toolchain.patch         | 18 ++++++++++++++++++
 boot/syslinux/syslinux.mk                              | 10 +++++-----
 5 files changed, 55 insertions(+), 5 deletions(-)
 create mode 100644 boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch
 create mode 100644 boot/syslinux/0004-fix-ld-oformat-32bits.patch
 create mode 100644 boot/syslinux/0005-build-utils-with-host-toolchain.patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 37c610e..fbc70e5 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -150,6 +150,7 @@ N:	Benjamin Kamath <kamath.ben@gmail.com>
 F:	package/lapack/
 
 N:	Beno?t Allard <benoit.allard@greenbone.net>
+F:	boot/syslinux/
 F:	package/dc3dd/
 
 N:	Bernd Kuhls <bernd.kuhls@t-online.de>
diff --git a/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch b/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch
new file mode 100644
index 0000000..dacc07c
--- /dev/null
+++ b/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch
@@ -0,0 +1,16 @@
+Fix for https://bugs.debian.org/846679 : syslinux: FTBFS: ld:
+ldlinux.elf: Not enough room for program headers, try linking with -N
+
+Patch from: Steve McIntyre <93sam@debian.org>
+https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=846679;filename=syslinux_6.03%2Bdfsg-14.1.debdiff;msg=10
+--- a/core/Makefile	2017-01-28 18:33:22.750959519 +0000
++++ b/core/Makefile	2017-01-28 18:27:47.387981830 +0000
+@@ -165,7 +165,7 @@
+ 
+ %.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
+ 	$(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
+-		--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
++		--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group --no-dynamic-linker \
+ 		> $(@:.elf=.map)
+ 	$(OBJDUMP) -h $@ > $(@:.elf=.sec)
+ 	$(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
diff --git a/boot/syslinux/0004-fix-ld-oformat-32bits.patch b/boot/syslinux/0004-fix-ld-oformat-32bits.patch
new file mode 100644
index 0000000..2187772
--- /dev/null
+++ b/boot/syslinux/0004-fix-ld-oformat-32bits.patch
@@ -0,0 +1,15 @@
+Force ld to output i386 bytecodes and not x86_64 to be consistent with the
+other .o files.
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+--- a/memdisk/Makefile	2017-04-04 16:45:43.033844618 +0200
++++ b/memdisk/Makefile	2017-04-04 16:45:11.298619204 +0200
+@@ -78,7 +78,7 @@ memdisk16.o: memdisk16.asm
+ 	$(NASM) -f bin $(NASMOPT) $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
+ 
+ memdisk_%.o: memdisk_%.bin
+-	$(LD) -r -b binary -o $@ $<
++	$(LD) --oformat elf32-i386 -r -b binary -o $@ $<
+ 
+ memdisk16.elf: $(OBJS16)
+ 	$(LD) -Ttext 0 -o $@ $^
diff --git a/boot/syslinux/0005-build-utils-with-host-toolchain.patch b/boot/syslinux/0005-build-utils-with-host-toolchain.patch
new file mode 100644
index 0000000..09778d3
--- /dev/null
+++ b/boot/syslinux/0005-build-utils-with-host-toolchain.patch
@@ -0,0 +1,18 @@
+The utilities are meant to run on the host machine, hence must be built using
+the host toolchain.
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+--- a/utils/Makefile	2017-04-05 11:49:48.156097181 +0200
++++ b/utils/Makefile	2017-04-05 11:50:30.234872515 +0200
+@@ -17,8 +17,9 @@
+ VPATH = $(SRC)
+ include $(MAKEDIR)/syslinux.mk
+ 
+-CFLAGS   = $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
+-LDFLAGS  = -O2
++CC       = $(HOSTCC)
++CFLAGS   = $(HOST_CFLAGS) $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
++LDFLAGS  = $(HOST_LDFLAGS) -O2
+ 
+ C_TARGETS	 = isohybrid gethostip memdiskfind
+ SCRIPT_TARGETS	 = mkdiskimage
diff --git a/boot/syslinux/syslinux.mk b/boot/syslinux/syslinux.mk
index 5b7906c..50feea3 100644
--- a/boot/syslinux/syslinux.mk
+++ b/boot/syslinux/syslinux.mk
@@ -51,8 +51,10 @@ SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
 # 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)" $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
+        $(TARGET_MAKE_ENV) $(MAKE1) \
+            CC="$(TARGET_CC)" LD="$(TARGET_LD)" NASM="$(HOST_DIR)/usr/bin/nasm" \
+            HOSTCC="$(HOSTCC)" HOST_CFLAGS="$(HOST_CFLAGS)" HOST_LDFLAGS="$(HOST_LDFLAGS)" \
+            $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
 endef
 
 # While the actual bootloader is compiled for the target, several
@@ -61,9 +63,7 @@ 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)" $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \
-		-C $(@D) $(SYSLINUX_TARGET) install
+	$(TARGET_MAKE_ENV) $(MAKE) $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) -C $(@D) $(SYSLINUX_TARGET) install
 endef
 
 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_ISOLINUX) += bios/core/isolinux.bin
-- 
2.1.4

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

* [Buildroot] [PATCH] syslinux: Builds with the target toolchain
  2017-04-05 10:09 [Buildroot] [PATCH] syslinux: Builds with the target toolchain Benoît Allard
@ 2017-04-05 11:02 ` Thomas Petazzoni
  2017-04-05 13:38   ` Benoît Allard
  2017-04-05 13:28 ` [Buildroot] [PATCH v2 1/2] " Benoît Allard
  1 sibling, 1 reply; 18+ messages in thread
From: Thomas Petazzoni @ 2017-04-05 11:02 UTC (permalink / raw)
  To: buildroot

Hello,

Thanks a lot for doing this work. I have a number of comments below,
nothing really major.

First of all, this deserves a longer commit log to explain why you're
doing this.

On Wed,  5 Apr 2017 12:09:47 +0200, Beno?t Allard wrote:
> Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
> ---
>  DEVELOPERS                                             |  1 +

This change should be in a separate patch. For new packages, we want it
to be with the patch adding the package. But since the syslinux package
already exists, it should be a separate patch, as it's unrelated to
making syslinux build with the target toolchain.

> diff --git a/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch b/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch
> new file mode 100644
> index 0000000..dacc07c
> --- /dev/null
> +++ b/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch
> @@ -0,0 +1,16 @@
> +Fix for https://bugs.debian.org/846679 : syslinux: FTBFS: ld:
> +ldlinux.elf: Not enough room for program headers, try linking with -N
> +
> +Patch from: Steve McIntyre <93sam@debian.org>
> +https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=846679;filename=syslinux_6.03%2Bdfsg-14.1.debdiff;msg=10

This needs your Signed-off-by as well. Also leave an empty line between
the Signed-off-by line and the start of the patch itself.

> diff --git a/boot/syslinux/0004-fix-ld-oformat-32bits.patch b/boot/syslinux/0004-fix-ld-oformat-32bits.patch
> new file mode 100644
> index 0000000..2187772
> --- /dev/null
> +++ b/boot/syslinux/0004-fix-ld-oformat-32bits.patch
> @@ -0,0 +1,15 @@
> +Force ld to output i386 bytecodes and not x86_64 to be consistent with the
> +other .o files.
> +
> +Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>

Ditto: add an empty line here. But in fact, since syslinux is using Git
(http://www.syslinux.org/wiki/index.php?title=Development), we would
like to have Git-formatted patches instead (i.e patches generated with
git format-patch).

> diff --git a/boot/syslinux/0005-build-utils-with-host-toolchain.patch b/boot/syslinux/0005-build-utils-with-host-toolchain.patch
> new file mode 100644
> index 0000000..09778d3
> --- /dev/null
> +++ b/boot/syslinux/0005-build-utils-with-host-toolchain.patch
> @@ -0,0 +1,18 @@
> +The utilities are meant to run on the host machine, hence must be built using
> +the host toolchain.
> +
> +Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>

Please  format with "git format-patch" as well.

> +--- a/utils/Makefile	2017-04-05 11:49:48.156097181 +0200
> ++++ b/utils/Makefile	2017-04-05 11:50:30.234872515 +0200
> +@@ -17,8 +17,9 @@
> + VPATH = $(SRC)
> + include $(MAKEDIR)/syslinux.mk
> + 
> +-CFLAGS   = $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
> +-LDFLAGS  = -O2
> ++CC       = $(HOSTCC)
> ++CFLAGS   = $(HOST_CFLAGS) $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
> ++LDFLAGS  = $(HOST_LDFLAGS) -O2
> + 
> + C_TARGETS	 = isohybrid gethostip memdiskfind
> + SCRIPT_TARGETS	 = mkdiskimage

Also, if you could submit those patches to the upstream syslinux
project, it would be nice.



> diff --git a/boot/syslinux/syslinux.mk b/boot/syslinux/syslinux.mk
> index 5b7906c..50feea3 100644
> --- a/boot/syslinux/syslinux.mk
> +++ b/boot/syslinux/syslinux.mk
> @@ -51,8 +51,10 @@ SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
>  # 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)" $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
> +        $(TARGET_MAKE_ENV) $(MAKE1) \
> +            CC="$(TARGET_CC)" LD="$(TARGET_LD)" NASM="$(HOST_DIR)/usr/bin/nasm" \
> +            HOSTCC="$(HOSTCC)" HOST_CFLAGS="$(HOST_CFLAGS)" HOST_LDFLAGS="$(HOST_LDFLAGS)" \

In fact, it would have been better to use CC_FOR_BUILD,
CFLAGS_FOR_BUILD, LDFLAGS_FOR_BUILD in the syslinux Makefile. If you do
this, then you can simplify this to:

	$(TARGET_MAKE_ENV) $(MAKE1) $(TARGET_CONFIGURE_OPTS) \
		NASM=... $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)

>  # Repeat CC and AR, since syslinux really wants to check them at
>  # install time

You're no longer repeating CC and AR, so this comment no longer makes
sense.

>  define SYSLINUX_INSTALL_TARGET_CMDS
> -	$(TARGET_MAKE_ENV) $(MAKE1) CC="$(HOSTCC) -idirafter $(HOST_DIR)/usr/include $(HOST_LDFLAGS)" \
> -		AR="$(HOSTAR)" $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \
> -		-C $(@D) $(SYSLINUX_TARGET) install
> +	$(TARGET_MAKE_ENV) $(MAKE) $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) -C $(@D) $(SYSLINUX_TARGET) install
>  endef

It would also be good in the commit log to explicitly say that you have
tested this with a x86-64 Buildroot toolchain, and that it produces as
expected a working 32-bit syslinux, tested on HW.

Thanks a lot!

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

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

* [Buildroot] [PATCH v2 1/2] syslinux: Builds with the target toolchain
  2017-04-05 10:09 [Buildroot] [PATCH] syslinux: Builds with the target toolchain Benoît Allard
  2017-04-05 11:02 ` Thomas Petazzoni
@ 2017-04-05 13:28 ` Benoît Allard
  2017-04-05 13:28   ` [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package Benoît Allard
                     ` (2 more replies)
  1 sibling, 3 replies; 18+ messages in thread
From: Benoît Allard @ 2017-04-05 13:28 UTC (permalink / raw)
  To: buildroot

Until now, the host toolchain was used to build syslinux. syslinux does requires gnu-efi, and this is built using the target toolchain. Mixing different toolchains doesn't work well, so let's use the target toolchain for syslinux as well.

Well, almost, as syslinux also contains some utilities that have to run on the host. Those ones need to be built with the host toolchain.

This was tested using a buildroot's built x86_64 toolchain, and checked that some output binaries are 32-bits. It was tested as well if they actually boot on Hardware.

Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
---
Changes v1 -> v2:
 - Move the DEVELOPERS note to another patch
 - Add Signed-Off-By to the patch 0003
 - Format the patches using git format-patch
 - Use XX_FOR_BUILD instead of HOSTXX
 - Remove old comment in the syslinuc.mk file

---
 .../0003-fix_ftbfs_no_dynamic_linker.patch         | 19 ++++++++++++
 ...memdisk-Force-ld-output-format-to-32-bits.patch | 32 ++++++++++++++++++++
 ...005-utils-Use-the-host-toolchain-to-build.patch | 35 ++++++++++++++++++++++
 boot/syslinux/syslinux.mk                          | 12 ++++----
 4 files changed, 91 insertions(+), 7 deletions(-)
 create mode 100644 boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch
 create mode 100644 boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
 create mode 100644 boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch

diff --git a/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch b/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch
new file mode 100644
index 0000000..ff8af5b
--- /dev/null
+++ b/boot/syslinux/0003-fix_ftbfs_no_dynamic_linker.patch
@@ -0,0 +1,19 @@
+Fix for https://bugs.debian.org/846679 : syslinux: FTBFS: ld:
+ldlinux.elf: Not enough room for program headers, try linking with -N
+
+Patch from: Steve McIntyre <93sam@debian.org>
+https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=846679;filename=syslinux_6.03%2Bdfsg-14.1.debdiff;msg=10
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+
+--- a/core/Makefile	2017-01-28 18:33:22.750959519 +0000
++++ b/core/Makefile	2017-01-28 18:27:47.387981830 +0000
+@@ -165,7 +165,7 @@
+ 
+ %.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
+ 	$(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
+-		--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
++		--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group --no-dynamic-linker \
+ 		> $(@:.elf=.map)
+ 	$(OBJDUMP) -h $@ > $(@:.elf=.sec)
+ 	$(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
diff --git a/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch b/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
new file mode 100644
index 0000000..69947e7
--- /dev/null
+++ b/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
@@ -0,0 +1,32 @@
+From 948aec20d1b0233e509f547dba7efb2274359947 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Beno=C3=AEt=20Allard?= <benoit.allard@greenbone.net>
+Date: Wed, 5 Apr 2017 14:18:09 +0200
+Subject: [PATCH 1/2] memdisk: Force ld output format to 32-bits
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On toolchains where the default output is x86_64, we need to be
+consistent with the other .o files
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ memdisk/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/memdisk/Makefile b/memdisk/Makefile
+index 42e56e0..ccd5738 100644
+--- a/memdisk/Makefile
++++ b/memdisk/Makefile
+@@ -78,7 +78,7 @@ memdisk16.o: memdisk16.asm
+ 	$(NASM) -f bin $(NASMOPT) $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
+ 
+ memdisk_%.o: memdisk_%.bin
+-	$(LD) -r -b binary -o $@ $<
++	$(LD) --oformat elf32-i386 -r -b binary -o $@ $<
+ 
+ memdisk16.elf: $(OBJS16)
+ 	$(LD) -Ttext 0 -o $@ $^
+-- 
+2.1.4
+
diff --git a/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch b/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch
new file mode 100644
index 0000000..7774453
--- /dev/null
+++ b/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch
@@ -0,0 +1,35 @@
+From 91777a0a7f693db71b5f77813c188ad6ebe4c9e8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Beno=C3=AEt=20Allard?= <benoit.allard@greenbone.net>
+Date: Wed, 5 Apr 2017 14:25:02 +0200
+Subject: [PATCH 2/2] utils: Use the host toolchain to build.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The utilities are meant to run on the host machine, hence must be built using
+the host toolchain.
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ utils/Makefile | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/utils/Makefile b/utils/Makefile
+index dfe6259..f31f117 100644
+--- a/utils/Makefile
++++ b/utils/Makefile
+@@ -17,8 +17,9 @@
+ VPATH = $(SRC)
+ include $(MAKEDIR)/syslinux.mk
+ 
+-CFLAGS   = $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
+-LDFLAGS  = -O2
++CC       = $(CC_FOR_BUILD)
++CFLAGS   = $(CFLAGS_FOR_BUILD) $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
++LDFLAGS  = $(LDFLAGS_FOR_BUILD) -O2
+ 
+ C_TARGETS	 = isohybrid gethostip memdiskfind
+ SCRIPT_TARGETS	 = mkdiskimage
+-- 
+2.1.4
+
diff --git a/boot/syslinux/syslinux.mk b/boot/syslinux/syslinux.mk
index 5b7906c..e0ab2a1 100644
--- a/boot/syslinux/syslinux.mk
+++ b/boot/syslinux/syslinux.mk
@@ -51,19 +51,17 @@ SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
 # 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)" $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
+        $(TARGET_MAKE_ENV) $(MAKE1) \
+            CC="$(TARGET_CC)" LD="$(TARGET_LD)" NASM="$(HOST_DIR)/usr/bin/nasm" \
+            CC_FOR_BUILD="$(HOSTCC)" CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
+            $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
 endef
 
 # While the actual bootloader is compiled for the target, several
 # utilities for installing the bootloader are meant for the host.
 # Repeat the target, otherwise syslinux will try to build everything
-# 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)" $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \
-		-C $(@D) $(SYSLINUX_TARGET) install
+	$(TARGET_MAKE_ENV) $(MAKE) $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) -C $(@D) $(SYSLINUX_TARGET) install
 endef
 
 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_ISOLINUX) += bios/core/isolinux.bin
-- 
2.1.4

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

* [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package.
  2017-04-05 13:28 ` [Buildroot] [PATCH v2 1/2] " Benoît Allard
@ 2017-04-05 13:28   ` Benoît Allard
  2017-04-05 14:51     ` Arnout Vandecappelle
  2017-04-05 19:07     ` Thomas Petazzoni
  2017-04-05 20:25   ` [Buildroot] [PATCH v2 1/2] syslinux: Builds with the target toolchain Thomas Petazzoni
  2017-04-06 10:04   ` [Buildroot] [PATCH v4 1/1] syslinux: build " Benoît Allard
  2 siblings, 2 replies; 18+ messages in thread
From: Benoît Allard @ 2017-04-05 13:28 UTC (permalink / raw)
  To: buildroot

As it turns out, I am the only one who touched it in the last year.

Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
---
 DEVELOPERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/DEVELOPERS b/DEVELOPERS
index 37c610e..fbc70e5 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -150,6 +150,7 @@ N:	Benjamin Kamath <kamath.ben@gmail.com>
 F:	package/lapack/
 
 N:	Beno?t Allard <benoit.allard@greenbone.net>
+F:	boot/syslinux/
 F:	package/dc3dd/
 
 N:	Bernd Kuhls <bernd.kuhls@t-online.de>
-- 
2.1.4

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

* [Buildroot] [PATCH] syslinux: Builds with the target toolchain
  2017-04-05 11:02 ` Thomas Petazzoni
@ 2017-04-05 13:38   ` Benoît Allard
  2017-04-05 14:48     ` Arnout Vandecappelle
  0 siblings, 1 reply; 18+ messages in thread
From: Benoît Allard @ 2017-04-05 13:38 UTC (permalink / raw)
  To: buildroot

On Wed, 5 Apr 2017 13:02:27 +0200
Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:
> > diff --git a/boot/syslinux/syslinux.mk b/boot/syslinux/syslinux.mk
> > index 5b7906c..50feea3 100644
> > --- a/boot/syslinux/syslinux.mk
> > +++ b/boot/syslinux/syslinux.mk
> > @@ -51,8 +51,10 @@ SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
> >  # 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)" $(SYSLINUX_EFI_ARGS) -C $(@D)
> > $(SYSLINUX_TARGET)
> > +        $(TARGET_MAKE_ENV) $(MAKE1) \
> > +            CC="$(TARGET_CC)" LD="$(TARGET_LD)"
> > NASM="$(HOST_DIR)/usr/bin/nasm" \
> > +            HOSTCC="$(HOSTCC)" HOST_CFLAGS="$(HOST_CFLAGS)"
> > HOST_LDFLAGS="$(HOST_LDFLAGS)" \
> 
> In fact, it would have been better to use CC_FOR_BUILD,
> CFLAGS_FOR_BUILD, LDFLAGS_FOR_BUILD in the syslinux Makefile. If you
> do this, then you can simplify this to:
> 
> 	$(TARGET_MAKE_ENV) $(MAKE1) $(TARGET_CONFIGURE_OPTS) \
> 		NASM=... $(SYSLINUX_EFI_ARGS) -C $(@D)
> $(SYSLINUX_TARGET)
> 

I didn't addressed this in my version 2 of the patch as somehow, when
using $(TARGET_CONFIGURE_OPTS) instead of the various variables, the
Makefiles from syslinux were not able to define CFLAGS on their own, or
somehow, they didn't used their version of it.

Regards,
Ben.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170405/6d7b9aff/attachment.asc>

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

* [Buildroot] [PATCH] syslinux: Builds with the target toolchain
  2017-04-05 13:38   ` Benoît Allard
@ 2017-04-05 14:48     ` Arnout Vandecappelle
  0 siblings, 0 replies; 18+ messages in thread
From: Arnout Vandecappelle @ 2017-04-05 14:48 UTC (permalink / raw)
  To: buildroot



On 05-04-17 15:38, Beno?t Allard wrote:
> On Wed, 5 Apr 2017 13:02:27 +0200
> Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:
>>> diff --git a/boot/syslinux/syslinux.mk b/boot/syslinux/syslinux.mk
>>> index 5b7906c..50feea3 100644
>>> --- a/boot/syslinux/syslinux.mk
>>> +++ b/boot/syslinux/syslinux.mk
>>> @@ -51,8 +51,10 @@ SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
>>>  # 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)" $(SYSLINUX_EFI_ARGS) -C $(@D)
>>> $(SYSLINUX_TARGET)
>>> +        $(TARGET_MAKE_ENV) $(MAKE1) \
>>> +            CC="$(TARGET_CC)" LD="$(TARGET_LD)"
>>> NASM="$(HOST_DIR)/usr/bin/nasm" \
>>> +            HOSTCC="$(HOSTCC)" HOST_CFLAGS="$(HOST_CFLAGS)"
>>> HOST_LDFLAGS="$(HOST_LDFLAGS)" \
>>
>> In fact, it would have been better to use CC_FOR_BUILD,
>> CFLAGS_FOR_BUILD, LDFLAGS_FOR_BUILD in the syslinux Makefile. If you
>> do this, then you can simplify this to:
>>
>> 	$(TARGET_MAKE_ENV) $(MAKE1) $(TARGET_CONFIGURE_OPTS) \
>> 		NASM=... $(SYSLINUX_EFI_ARGS) -C $(@D)
>> $(SYSLINUX_TARGET)
>>
> 
> I didn't addressed this in my version 2 of the patch as somehow, when
> using $(TARGET_CONFIGURE_OPTS) instead of the various variables, the
> Makefiles from syslinux were not able to define CFLAGS on their own, or
> somehow, they didn't used their version of it.

 That's because the Makefile in syslinux does

CFLAGS = ...

This means that if you pass CFLAGS on the left-hand side of $(MAKE) (i.e., in
the environment), they won't be used at all, and if you pass it on the
right-hand side, the one from the Makefile won't be used.

 The solution is to patch the syslinux Makefile to either:

- not assign to CFLAGS at all, instead use some other variable and use that in
the build command;
- assign CFLAGS with either ?= (for defaults that can be overridden by the user)
or += (for things that always have to be there) instead of just =; in this case
you should pass TARGET_CONFIGURE_OPTS in the environment, not as a Makefile
override.

 The second option is a bit simpler to patch in, but it requires GNU make which
some upstreams don't like.

 Regards,
 Arnout

 PS should we make this a FAQ entry in the manual?

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170405/119d142e/attachment.asc>

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

* [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package.
  2017-04-05 13:28   ` [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package Benoît Allard
@ 2017-04-05 14:51     ` Arnout Vandecappelle
  2017-04-05 19:07     ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Arnout Vandecappelle @ 2017-04-05 14:51 UTC (permalink / raw)
  To: buildroot

 Probably Thomas will apply before you respin, but if he doesn't:

 It is nice for 'git log --oneline' output if the subject line contains your
name, i.e.:

DEVELOPERS: add Beno?t Allard for boot/syslinux

On 05-04-17 15:28, Beno?t Allard wrote:
> As it turns out, I am the only one who touched it in the last year.

 Also we generally avoid using "I" in commit messages (except below --- of
course). In this case I think it's warranted, though.

 Regards,
 Arnout

> 
> Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
> ---
>  DEVELOPERS | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 37c610e..fbc70e5 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -150,6 +150,7 @@ N:	Benjamin Kamath <kamath.ben@gmail.com>
>  F:	package/lapack/
>  
>  N:	Beno?t Allard <benoit.allard@greenbone.net>
> +F:	boot/syslinux/
>  F:	package/dc3dd/
>  
>  N:	Bernd Kuhls <bernd.kuhls@t-online.de>
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

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

* [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package.
  2017-04-05 13:28   ` [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package Benoît Allard
  2017-04-05 14:51     ` Arnout Vandecappelle
@ 2017-04-05 19:07     ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2017-04-05 19:07 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed,  5 Apr 2017 15:28:50 +0200, Beno?t Allard wrote:
> As it turns out, I am the only one who touched it in the last year.
> 
> Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
> ---
>  DEVELOPERS | 1 +
>  1 file changed, 1 insertion(+)

Applied to master after tweaking the commit log as suggested by Arnout.

Thanks!

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

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

* [Buildroot] [PATCH v2 1/2] syslinux: Builds with the target toolchain
  2017-04-05 13:28 ` [Buildroot] [PATCH v2 1/2] " Benoît Allard
  2017-04-05 13:28   ` [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package Benoît Allard
@ 2017-04-05 20:25   ` Thomas Petazzoni
  2017-04-06 10:04   ` [Buildroot] [PATCH v4 1/1] syslinux: build " Benoît Allard
  2 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2017-04-05 20:25 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed,  5 Apr 2017 15:28:49 +0200, Beno?t Allard wrote:
> Until now, the host toolchain was used to build syslinux. syslinux does requires gnu-efi, and this is built using the target toolchain. Mixing different toolchains doesn't work well, so let's use the target toolchain for syslinux as well.
> 
> Well, almost, as syslinux also contains some utilities that have to run on the host. Those ones need to be built with the host toolchain.
> 
> This was tested using a buildroot's built x86_64 toolchain, and checked that some output binaries are 32-bits. It was tested as well if they actually boot on Hardware.
> 
> Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>

Unfortunately, this doesn't build for me: the prepcore tool is built
for the target, but executed on the host. I've intentionally tested
with a x86-64 musl toolchain, so that the C library of the target is
not the one of my host machine, which guarantees a target executable
will not run on my host machine. It fails with:

perl /home/thomas/projets/buildroot/output/build/syslinux-6.03/core/lstadjust.pl ldlinux.lsr ldlinux.sec ldlinux.lst
objcopy -O binary -S ldlinux.elf ldlinux.raw
/home/thomas/projets/buildroot/output/build/syslinux-6.03/bios/core/../lzo/prepcore ldlinux.raw ldlinux.bin
make[5]: /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
make[5]: *** [ldlinux.bin] Error 127
rm ldlinux.o ldlinux.raw
/home/thomas/projets/buildroot/output/build/syslinux-6.03/Makefile:285: recipe for target 'core' failed
make[4]: *** [core] Error 2
/home/thomas/projets/buildroot/output/build/syslinux-6.03/Makefile:254: recipe for target 'bios' failed
make[3]: *** [bios] Error 2
Makefile:103: recipe for target 'bios' failed
make[2]: *** [bios] Error 2

To reproduce this issue, build the following configuration:

BR2_x86_64=y
BR2_x86_atom=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-x86-64-musl-2017.02-744-g40962a0.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_5=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_10=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=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_SYSLINUX=y
BR2_TARGET_SYSLINUX_ISOLINUX=y
BR2_TARGET_SYSLINUX_PXELINUX=y
BR2_TARGET_SYSLINUX_MBR=y

Also, I've done a number of improvements to your patch, so if you could
restart from the version I was about to commit before seeing the issue,
it would be nice. I pushed it at:

  http://git.free-electrons.com/users/thomas-petazzoni/buildroot/commit/?h=syslinux-fix

Thanks a lot!

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

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

* [Buildroot] [PATCH v4 1/1] syslinux: build with the target toolchain
  2017-04-05 13:28 ` [Buildroot] [PATCH v2 1/2] " Benoît Allard
  2017-04-05 13:28   ` [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package Benoît Allard
  2017-04-05 20:25   ` [Buildroot] [PATCH v2 1/2] syslinux: Builds with the target toolchain Thomas Petazzoni
@ 2017-04-06 10:04   ` Benoît Allard
  2017-04-06 15:13     ` Thomas Petazzoni
  2017-04-07  9:05     ` [Buildroot] [PATCH v5] " Benoît Allard
  2 siblings, 2 replies; 18+ messages in thread
From: Benoît Allard @ 2017-04-06 10:04 UTC (permalink / raw)
  To: buildroot

Until now, the host toolchain was used to build syslinux, as it was
not possible to build a 32-bit syslinux with a x86-64 toolchain.

However, syslinux requires gnu-efi, and gnu-efi is built using the
target toolchain. Mixing different toolchains doesn't work well, so
this commit changes the syslinux package to use the target toolchain
for syslinux as well. This is made possible by patches
0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch and
0004-memdisk-Force-ld-output-format-to-32-bits.patch.

Since syslinux also contains some utilities that have to run on the
host, those have to continue being built with the host toolchain,
which requires patch 0005-utils-Use-the-host-toolchain-to-build.patch.

This was tested using a Buildroot's built x86_64 toolchain, and
checked that the output binaries are 32-bits. It was tested as well if
they actually boot on hardware.

Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>

---

Changes v1 -> v2:
 - Move the DEVELOPERS note to another patch
 - Add Signed-Off-By to the patch 0003
 - Format the patches using git format-patch
 - Use XX_FOR_BUILD instead of HOSTXX
 - Remove old comment in the syslinuc.mk file
Changes v2 -> v3 (by Thomas):
 - reformat patch 0003 as a Git formatted patch, remove numbering in
   patches 0004 and 0005
 - remove BR2_HOSTARCH_NEEDS_IA32_COMPILER dependency
 - improve commit log.
 - fix indentation in .mk file.
Changes v3 -> v4:
 - Add patch 0006 to build lzo and prepcore with the host toolchain as
   well.
 - Rewrite patch 0004 to use new variable and not redefine previous
   ones.
 - Add dependency to libuuid needed by extlinux.
 - Define LD in the install command. Somehow installing finalize some
   linking.
 - Remove dependency on host-util-linux.

---
 ....elf-Not-enough-room-for-program-headers-.patch | 35 +++++++++++++
 ...memdisk-Force-ld-output-format-to-32-bits.patch | 32 ++++++++++++
 ...005-utils-Use-the-host-toolchain-to-build.patch | 60 ++++++++++++++++++++++
 ...6-lzo-Use-the-host-toolchain-for-prepcore.patch | 44 ++++++++++++++++
 boot/syslinux/Config.in                            |  3 +-
 boot/syslinux/syslinux.mk                          | 21 +++++---
 6 files changed, 187 insertions(+), 8 deletions(-)
 create mode 100644 boot/syslinux/0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch
 create mode 100644 boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
 create mode 100644 boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch
 create mode 100644 boot/syslinux/0006-lzo-Use-the-host-toolchain-for-prepcore.patch

diff --git a/boot/syslinux/0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch b/boot/syslinux/0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch
new file mode 100644
index 0000000..83a87ee
--- /dev/null
+++ b/boot/syslinux/0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch
@@ -0,0 +1,35 @@
+From 61de7762389d460da7ffdd644f50c60175cce23b Mon Sep 17 00:00:00 2001
+From: Steve McIntyre <93sam@debian.org>
+Date: Wed, 5 Apr 2017 22:09:37 +0200
+Subject: [PATCH] Fix 'ldlinux.elf: Not enough room for program headers, try
+ linking with -N'
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Fix for https://bugs.debian.org/846679: syslinux: FTBFS: ld:
+ldlinux.elf: Not enough room for program headers, try linking with -N
+
+https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=846679;filename=syslinux_6.03%2Bdfsg-14.1.debdiff;msg=10
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ core/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/core/Makefile b/core/Makefile
+index ad0acb5..58a3545 100644
+--- a/core/Makefile
++++ b/core/Makefile
+@@ -165,7 +165,7 @@ LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
+ 
+ %.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
+ 	$(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
+-		--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
++		--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group --no-dynamic-linker \
+ 		> $(@:.elf=.map)
+ 	$(OBJDUMP) -h $@ > $(@:.elf=.sec)
+ 	$(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
+-- 
+2.7.4
+
diff --git a/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch b/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
new file mode 100644
index 0000000..4eedf49
--- /dev/null
+++ b/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
@@ -0,0 +1,32 @@
+From c0287594239d5af2082cac20817f8e8b11a4b1b2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Beno=C3=AEt=20Allard?= <benoit.allard@greenbone.net>
+Date: Wed, 5 Apr 2017 14:18:09 +0200
+Subject: [PATCH] memdisk: Force ld output format to 32-bits
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On toolchains where the default output is x86_64, we need to be
+consistent with the other .o files
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ memdisk/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/memdisk/Makefile b/memdisk/Makefile
+index e6557d8..06613ff 100644
+--- a/memdisk/Makefile
++++ b/memdisk/Makefile
+@@ -78,7 +78,7 @@ memdisk16.o: memdisk16.asm
+ 	$(NASM) -f bin $(NASMOPT) $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
+ 
+ memdisk_%.o: memdisk_%.bin
+-	$(LD) -r -b binary -o $@ $<
++	$(LD) --oformat elf32-i386 -r -b binary -o $@ $<
+ 
+ memdisk16.elf: $(OBJS16)
+ 	$(LD) -Ttext 0 -o $@ $^
+-- 
+2.7.4
+
diff --git a/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch b/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch
new file mode 100644
index 0000000..e091a3a
--- /dev/null
+++ b/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch
@@ -0,0 +1,60 @@
+From e000251144056c99e390a2a4449d06cbd2a19c0a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Beno=C3=AEt=20Allard?= <benoit.allard@greenbone.net>
+Date: Wed, 5 Apr 2017 14:25:02 +0200
+Subject: [PATCH] utils: Use the host toolchain to build.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The utilities are meant to run on the host machine, hence must be built using
+the host toolchain.
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ utils/Makefile | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/utils/Makefile b/utils/Makefile
+index dfe6259..ac91aaa 100644
+--- a/utils/Makefile
++++ b/utils/Makefile
+@@ -17,8 +17,8 @@
+ VPATH = $(SRC)
+ include $(MAKEDIR)/syslinux.mk
+ 
+-CFLAGS   = $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
+-LDFLAGS  = -O2
++CFLAGS   = $(CFLAGS_FOR_BUILD) $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
++LDFLAGS  = $(LDFLAGS_FOR_BUILD) -O2
+ 
+ C_TARGETS	 = isohybrid gethostip memdiskfind
+ SCRIPT_TARGETS	 = mkdiskimage
+@@ -35,7 +35,7 @@ ISOHDPFX = $(addprefix $(OBJ)/,../mbr/isohdpfx.bin ../mbr/isohdpfx_f.bin \
+ all: $(TARGETS)
+ 
+ %.o: %.c
+-	$(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
++	$(CC_FOR_BUILD) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
+ 
+ mkdiskimage: mkdiskimage.in ../mbr/mbr.bin bin2hex.pl
+ 	$(PERL) $(SRC)/bin2hex.pl < $(OBJ)/../mbr/mbr.bin | cat $(SRC)/mkdiskimage.in - > $@
+@@ -51,13 +51,13 @@ isohdpfx.c: $(ISOHDPFX) isohdpfxarray.pl
+ 	$(PERL) $(SRC)/isohdpfxarray.pl $(ISOHDPFX) > $@
+ 
+ isohybrid: isohybrid.o isohdpfx.o
+-	$(CC) $(LDFLAGS) -o $@ $^ -luuid
++	$(CC_FOR_BUILD) $(LDFLAGS) -o $@ $^ -luuid
+ 
+ gethostip: gethostip.o
+-	$(CC) $(LDFLAGS) -o $@ $^
++	$(CC_FOR_BUILD) $(LDFLAGS) -o $@ $^
+ 
+ memdiskfind: memdiskfind.o
+-	$(CC) $(LDFLAGS) -o $@ $^
++	$(CC_FOR_BUILD) $(LDFLAGS) -o $@ $^
+ 
+ tidy dist:
+ 	rm -f *.o .*.d isohdpfx.c
+-- 
+2.1.4
+
diff --git a/boot/syslinux/0006-lzo-Use-the-host-toolchain-for-prepcore.patch b/boot/syslinux/0006-lzo-Use-the-host-toolchain-for-prepcore.patch
new file mode 100644
index 0000000..c6fa7fe
--- /dev/null
+++ b/boot/syslinux/0006-lzo-Use-the-host-toolchain-for-prepcore.patch
@@ -0,0 +1,44 @@
+From 83e1f00990c25554723609bb549e18b987034317 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Beno=C3=AEt=20Allard?= <benoit.allard@greenbone.net>
+Date: Thu, 6 Apr 2017 09:43:46 +0200
+Subject: [PATCH] lzo: Use the host toolchain for prepcore
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ lzo/Makefile | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/lzo/Makefile b/lzo/Makefile
+index 29f1fa6..c016e5a 100644
+--- a/lzo/Makefile
++++ b/lzo/Makefile
+@@ -11,10 +11,13 @@
+ ## -----------------------------------------------------------------------
+ 
+ VPATH = $(SRC)
+-include $(MAKEDIR)/build.mk
++include $(MAKEDIR)/syslinux.mk
+ 
+ INCLUDES += -I$(SRC)/include
+ 
++%.o: %.c
++	$(CC_FOR_BUILD) $(UMAKEDEPS) $(CFLAGS_FOR_BUILD) $(INCLUDES) -c -o $@ $<
++
+ LIBOBJS = $(patsubst %.c,%.o,$(subst $(SRC)/,,$(wildcard $(SRC)/src/*.c)))
+ LIB     = lzo.a
+ BINS    = prepcore
+@@ -30,7 +33,7 @@ $(LIB) : $(LIBOBJS)
+ 	$(RANLIB) $@
+ 
+ prepcore : prepcore.o $(LIB)
+-	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
++	$(CC_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $^ $(LIBS)
+ 
+ tidy dist clean spotless:
+ 	rm -f $(BINS)
+-- 
+2.1.4
+
diff --git a/boot/syslinux/Config.in b/boot/syslinux/Config.in
index 6067e9c..299a559 100644
--- a/boot/syslinux/Config.in
+++ b/boot/syslinux/Config.in
@@ -1,12 +1,13 @@
 config BR2_TARGET_SYSLINUX
 	bool "syslinux"
 	depends on BR2_i386 || BR2_x86_64
-	select BR2_HOSTARCH_NEEDS_IA32_COMPILER
 	# Make sure@least one of the flavors is installed
 	select BR2_TARGET_SYSLINUX_ISOLINUX \
 		if !BR2_TARGET_SYSLINUX_PXELINUX && \
 		   !BR2_TARGET_SYSLINUX_MBR && \
 		   !BR2_TARGET_SYSLINUX_EFI
+	select BR2_PACKAGE_UTIL_LINUX
+	select BR2_PACKAGE_UTIL_LINUX_LIBUUID
 	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 5b7906c..0d0436a 100644
--- a/boot/syslinux/syslinux.mk
+++ b/boot/syslinux/syslinux.mk
@@ -13,7 +13,7 @@ SYSLINUX_LICENSE_FILES = COPYING
 
 SYSLINUX_INSTALL_IMAGES = YES
 
-SYSLINUX_DEPENDENCIES = host-nasm host-util-linux host-upx
+SYSLINUX_DEPENDENCIES = host-nasm host-upx util-linux
 
 ifeq ($(BR2_TARGET_SYSLINUX_LEGACY_BIOS),y)
 SYSLINUX_TARGET += bios
@@ -51,18 +51,25 @@ SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
 # 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)" $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
+	$(TARGET_MAKE_ENV) $(MAKE1) \
+		CC="$(TARGET_CC)" \
+		LD="$(TARGET_LD)" \
+		NASM="$(HOST_DIR)/usr/bin/nasm" \
+		CC_FOR_BUILD="$(HOSTCC)" \
+		CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
+		LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
+            $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
 endef
 
 # While the actual bootloader is compiled for the target, several
 # utilities for installing the bootloader are meant for the host.
 # Repeat the target, otherwise syslinux will try to build everything
-# Repeat CC and AR, since syslinux really wants to check them at
-# install time
+# Repeat LD (and CC) as it happens that some binaries are linked at
+# install-time.
 define SYSLINUX_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) CC="$(HOSTCC) -idirafter $(HOST_DIR)/usr/include $(HOST_LDFLAGS)" \
-		AR="$(HOSTAR)" $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \
+	$(TARGET_MAKE_ENV) $(MAKE1) $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \
+		CC="$(TARGET_CC)" \
+		LD="$(TARGET_LD)" \
 		-C $(@D) $(SYSLINUX_TARGET) install
 endef
 
-- 
2.1.4

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

* [Buildroot] [PATCH v4 1/1] syslinux: build with the target toolchain
  2017-04-06 10:04   ` [Buildroot] [PATCH v4 1/1] syslinux: build " Benoît Allard
@ 2017-04-06 15:13     ` Thomas Petazzoni
  2017-04-07  8:06       ` Benoît Allard
  2017-04-07  9:05     ` [Buildroot] [PATCH v5] " Benoît Allard
  1 sibling, 1 reply; 18+ messages in thread
From: Thomas Petazzoni @ 2017-04-06 15:13 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu,  6 Apr 2017 12:04:46 +0200, Beno?t Allard wrote:
> Until now, the host toolchain was used to build syslinux, as it was
> not possible to build a 32-bit syslinux with a x86-64 toolchain.
> 
> However, syslinux requires gnu-efi, and gnu-efi is built using the
> target toolchain. Mixing different toolchains doesn't work well, so
> this commit changes the syslinux package to use the target toolchain
> for syslinux as well. This is made possible by patches
> 0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch and
> 0004-memdisk-Force-ld-output-format-to-32-bits.patch.
> 
> Since syslinux also contains some utilities that have to run on the
> host, those have to continue being built with the host toolchain,
> which requires patch 0005-utils-Use-the-host-toolchain-to-build.patch.
> 
> This was tested using a Buildroot's built x86_64 toolchain, and
> checked that the output binaries are 32-bits. It was tested as well if
> they actually boot on hardware.
> 
> Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>

Thanks, this now builds fine. However, in output/host/usr/bin, I still
have a program built with the target toolchain:

$ file output/host/usr/bin/syslinux
output/host/usr/bin/syslinux: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, not stripped

See the /lib/ld-musl-x86_64 interpreter? This means it has been built
against the musl C library, and therefore with the target toolchain.

What is this program useful for?

Best regards,

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

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

* [Buildroot] [PATCH v4 1/1] syslinux: build with the target toolchain
  2017-04-06 15:13     ` Thomas Petazzoni
@ 2017-04-07  8:06       ` Benoît Allard
  2017-04-07  8:16         ` Thomas Petazzoni
  0 siblings, 1 reply; 18+ messages in thread
From: Benoît Allard @ 2017-04-07  8:06 UTC (permalink / raw)
  To: buildroot

On Thu, 6 Apr 2017 17:13:23 +0200
Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:

> Hello,
> 
> On Thu,  6 Apr 2017 12:04:46 +0200, Beno?t Allard wrote:
> > Until now, the host toolchain was used to build syslinux, as it was
> > not possible to build a 32-bit syslinux with a x86-64 toolchain.
> > 
> > However, syslinux requires gnu-efi, and gnu-efi is built using the
> > target toolchain. Mixing different toolchains doesn't work well, so
> > this commit changes the syslinux package to use the target toolchain
> > for syslinux as well. This is made possible by patches
> > 0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch and
> > 0004-memdisk-Force-ld-output-format-to-32-bits.patch.
> > 
> > Since syslinux also contains some utilities that have to run on the
> > host, those have to continue being built with the host toolchain,
> > which requires patch
> > 0005-utils-Use-the-host-toolchain-to-build.patch.
> > 
> > This was tested using a Buildroot's built x86_64 toolchain, and
> > checked that the output binaries are 32-bits. It was tested as well
> > if they actually boot on hardware.
> > 
> > Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
> 
> Thanks, this now builds fine. However, in output/host/usr/bin, I still
> have a program built with the target toolchain:
> 
> $ file output/host/usr/bin/syslinux
> output/host/usr/bin/syslinux: ELF 64-bit LSB executable, x86-64,
> version 1 (SYSV), dynamically linked,
> interpreter /lib/ld-musl-x86_64.so.1, not stripped
> 
> See the /lib/ld-musl-x86_64 interpreter? This means it has been built
> against the musl C library, and therefore with the target toolchain.
> 
> What is this program useful for?

As I understand it, this is an "installer" you should run on the target
machine in order to install the syslinux bootloader. There should be (?)
another one "extlinux" next to it that is suitable for installing the
bootloader on an ext2 (4?) filesystem (that is the binary that has
dependency on libuuid).

Regards,
Ben.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170407/22533656/attachment.asc>

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

* [Buildroot] [PATCH v4 1/1] syslinux: build with the target toolchain
  2017-04-07  8:06       ` Benoît Allard
@ 2017-04-07  8:16         ` Thomas Petazzoni
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2017-04-07  8:16 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 7 Apr 2017 10:06:30 +0200, Beno?t Allard wrote:

> > See the /lib/ld-musl-x86_64 interpreter? This means it has been built
> > against the musl C library, and therefore with the target toolchain.
> > 
> > What is this program useful for?  
> 
> As I understand it, this is an "installer" you should run on the target
> machine in order to install the syslinux bootloader. There should be (?)
> another one "extlinux" next to it that is suitable for installing the
> bootloader on an ext2 (4?) filesystem (that is the binary that has
> dependency on libuuid).

If this program is not useful on the host (and therefore it is expected
to have it built with the target toolchain), then we should not install
it in HOST_DIR. On my side, I am fine with a post-install hook that
simply deletes it, provided it comes with a comment that explains why.

Thanks!

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

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

* [Buildroot] [PATCH v5] syslinux: build with the target toolchain
  2017-04-06 10:04   ` [Buildroot] [PATCH v4 1/1] syslinux: build " Benoît Allard
  2017-04-06 15:13     ` Thomas Petazzoni
@ 2017-04-07  9:05     ` Benoît Allard
  2017-04-08 14:08       ` Thomas Petazzoni
  2017-04-24 19:19       ` Peter Korsgaard
  1 sibling, 2 replies; 18+ messages in thread
From: Benoît Allard @ 2017-04-07  9:05 UTC (permalink / raw)
  To: buildroot

Until now, the host toolchain was used to build syslinux, as it was
not possible to build a 32-bit syslinux with a x86-64 toolchain.

However, syslinux requires gnu-efi, and gnu-efi is built using the
target toolchain. Mixing different toolchains doesn't work well, so
this commit changes the syslinux package to use the target toolchain
for syslinux as well. This is made possible by patches
0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch and
0004-memdisk-Force-ld-output-format-to-32-bits.patch.

Since syslinux also contains some utilities that have to run on the
host, those have to continue being built with the host toolchain,
which requires patch 0005-utils-Use-the-host-toolchain-to-build.patch.

Patch 0006-lzo-Use-the-host-toolchain-for-prepcore.patch is about
building prepcore, another utility with the host toolchain as it is
required at build-time.

This was tested using a Buildroot's built x86_64 toolchain, and
checked that the output binaries are 32-bits. It was tested as well if
they actually boot on hardware.

Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>

---

Changes v1 -> v2:
 - Move the DEVELOPERS note to another patch
 - Add Signed-Off-By to the patch 0003
 - Format the patches using git format-patch
 - Use XX_FOR_BUILD instead of HOSTXX
 - Remove old comment in the syslinuc.mk file
Changes v2 -> v3 (by Thomas):
 - reformat patch 0003 as a Git formatted patch, remove numbering in
   patches 0004 and 0005
 - remove BR2_HOSTARCH_NEEDS_IA32_COMPILER dependency
 - improve commit log.
 - fix indentation in .mk file.
Changes v3 -> v4:
 - Add patch 0006 to build lzo and prepcore with the host toolchain as
   well.
 - Rewrite patch 0004 to use new variable and not redefine previous
   ones.
 - Add dependency to libuuid needed by extlinux.
 - Define LD in the install command. Somehow installing finalize some
   linking.
 - Remove dependency on host-util-linux.
Changes v4 -> v5:
 - Remove host/usr/bin/syslinux as it's meant for the target
 - Extend commit message about patch 0006.

---
 ....elf-Not-enough-room-for-program-headers-.patch | 35 +++++++++++++
 ...memdisk-Force-ld-output-format-to-32-bits.patch | 32 ++++++++++++
 ...005-utils-Use-the-host-toolchain-to-build.patch | 60 ++++++++++++++++++++++
 ...6-lzo-Use-the-host-toolchain-for-prepcore.patch | 44 ++++++++++++++++
 boot/syslinux/Config.in                            |  3 +-
 boot/syslinux/syslinux.mk                          | 29 ++++++++---
 6 files changed, 195 insertions(+), 8 deletions(-)
 create mode 100644 boot/syslinux/0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch
 create mode 100644 boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
 create mode 100644 boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch
 create mode 100644 boot/syslinux/0006-lzo-Use-the-host-toolchain-for-prepcore.patch

diff --git a/boot/syslinux/0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch b/boot/syslinux/0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch
new file mode 100644
index 0000000..83a87ee
--- /dev/null
+++ b/boot/syslinux/0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch
@@ -0,0 +1,35 @@
+From 61de7762389d460da7ffdd644f50c60175cce23b Mon Sep 17 00:00:00 2001
+From: Steve McIntyre <93sam@debian.org>
+Date: Wed, 5 Apr 2017 22:09:37 +0200
+Subject: [PATCH] Fix 'ldlinux.elf: Not enough room for program headers, try
+ linking with -N'
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Fix for https://bugs.debian.org/846679: syslinux: FTBFS: ld:
+ldlinux.elf: Not enough room for program headers, try linking with -N
+
+https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=846679;filename=syslinux_6.03%2Bdfsg-14.1.debdiff;msg=10
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ core/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/core/Makefile b/core/Makefile
+index ad0acb5..58a3545 100644
+--- a/core/Makefile
++++ b/core/Makefile
+@@ -165,7 +165,7 @@ LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
+ 
+ %.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
+ 	$(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
+-		--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
++		--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group --no-dynamic-linker \
+ 		> $(@:.elf=.map)
+ 	$(OBJDUMP) -h $@ > $(@:.elf=.sec)
+ 	$(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
+-- 
+2.7.4
+
diff --git a/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch b/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
new file mode 100644
index 0000000..4eedf49
--- /dev/null
+++ b/boot/syslinux/0004-memdisk-Force-ld-output-format-to-32-bits.patch
@@ -0,0 +1,32 @@
+From c0287594239d5af2082cac20817f8e8b11a4b1b2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Beno=C3=AEt=20Allard?= <benoit.allard@greenbone.net>
+Date: Wed, 5 Apr 2017 14:18:09 +0200
+Subject: [PATCH] memdisk: Force ld output format to 32-bits
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On toolchains where the default output is x86_64, we need to be
+consistent with the other .o files
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ memdisk/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/memdisk/Makefile b/memdisk/Makefile
+index e6557d8..06613ff 100644
+--- a/memdisk/Makefile
++++ b/memdisk/Makefile
+@@ -78,7 +78,7 @@ memdisk16.o: memdisk16.asm
+ 	$(NASM) -f bin $(NASMOPT) $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
+ 
+ memdisk_%.o: memdisk_%.bin
+-	$(LD) -r -b binary -o $@ $<
++	$(LD) --oformat elf32-i386 -r -b binary -o $@ $<
+ 
+ memdisk16.elf: $(OBJS16)
+ 	$(LD) -Ttext 0 -o $@ $^
+-- 
+2.7.4
+
diff --git a/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch b/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch
new file mode 100644
index 0000000..e091a3a
--- /dev/null
+++ b/boot/syslinux/0005-utils-Use-the-host-toolchain-to-build.patch
@@ -0,0 +1,60 @@
+From e000251144056c99e390a2a4449d06cbd2a19c0a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Beno=C3=AEt=20Allard?= <benoit.allard@greenbone.net>
+Date: Wed, 5 Apr 2017 14:25:02 +0200
+Subject: [PATCH] utils: Use the host toolchain to build.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The utilities are meant to run on the host machine, hence must be built using
+the host toolchain.
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ utils/Makefile | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/utils/Makefile b/utils/Makefile
+index dfe6259..ac91aaa 100644
+--- a/utils/Makefile
++++ b/utils/Makefile
+@@ -17,8 +17,8 @@
+ VPATH = $(SRC)
+ include $(MAKEDIR)/syslinux.mk
+ 
+-CFLAGS   = $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
+-LDFLAGS  = -O2
++CFLAGS   = $(CFLAGS_FOR_BUILD) $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
++LDFLAGS  = $(LDFLAGS_FOR_BUILD) -O2
+ 
+ C_TARGETS	 = isohybrid gethostip memdiskfind
+ SCRIPT_TARGETS	 = mkdiskimage
+@@ -35,7 +35,7 @@ ISOHDPFX = $(addprefix $(OBJ)/,../mbr/isohdpfx.bin ../mbr/isohdpfx_f.bin \
+ all: $(TARGETS)
+ 
+ %.o: %.c
+-	$(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
++	$(CC_FOR_BUILD) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
+ 
+ mkdiskimage: mkdiskimage.in ../mbr/mbr.bin bin2hex.pl
+ 	$(PERL) $(SRC)/bin2hex.pl < $(OBJ)/../mbr/mbr.bin | cat $(SRC)/mkdiskimage.in - > $@
+@@ -51,13 +51,13 @@ isohdpfx.c: $(ISOHDPFX) isohdpfxarray.pl
+ 	$(PERL) $(SRC)/isohdpfxarray.pl $(ISOHDPFX) > $@
+ 
+ isohybrid: isohybrid.o isohdpfx.o
+-	$(CC) $(LDFLAGS) -o $@ $^ -luuid
++	$(CC_FOR_BUILD) $(LDFLAGS) -o $@ $^ -luuid
+ 
+ gethostip: gethostip.o
+-	$(CC) $(LDFLAGS) -o $@ $^
++	$(CC_FOR_BUILD) $(LDFLAGS) -o $@ $^
+ 
+ memdiskfind: memdiskfind.o
+-	$(CC) $(LDFLAGS) -o $@ $^
++	$(CC_FOR_BUILD) $(LDFLAGS) -o $@ $^
+ 
+ tidy dist:
+ 	rm -f *.o .*.d isohdpfx.c
+-- 
+2.1.4
+
diff --git a/boot/syslinux/0006-lzo-Use-the-host-toolchain-for-prepcore.patch b/boot/syslinux/0006-lzo-Use-the-host-toolchain-for-prepcore.patch
new file mode 100644
index 0000000..c6fa7fe
--- /dev/null
+++ b/boot/syslinux/0006-lzo-Use-the-host-toolchain-for-prepcore.patch
@@ -0,0 +1,44 @@
+From 83e1f00990c25554723609bb549e18b987034317 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Beno=C3=AEt=20Allard?= <benoit.allard@greenbone.net>
+Date: Thu, 6 Apr 2017 09:43:46 +0200
+Subject: [PATCH] lzo: Use the host toolchain for prepcore
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
+---
+ lzo/Makefile | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/lzo/Makefile b/lzo/Makefile
+index 29f1fa6..c016e5a 100644
+--- a/lzo/Makefile
++++ b/lzo/Makefile
+@@ -11,10 +11,13 @@
+ ## -----------------------------------------------------------------------
+ 
+ VPATH = $(SRC)
+-include $(MAKEDIR)/build.mk
++include $(MAKEDIR)/syslinux.mk
+ 
+ INCLUDES += -I$(SRC)/include
+ 
++%.o: %.c
++	$(CC_FOR_BUILD) $(UMAKEDEPS) $(CFLAGS_FOR_BUILD) $(INCLUDES) -c -o $@ $<
++
+ LIBOBJS = $(patsubst %.c,%.o,$(subst $(SRC)/,,$(wildcard $(SRC)/src/*.c)))
+ LIB     = lzo.a
+ BINS    = prepcore
+@@ -30,7 +33,7 @@ $(LIB) : $(LIBOBJS)
+ 	$(RANLIB) $@
+ 
+ prepcore : prepcore.o $(LIB)
+-	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
++	$(CC_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $^ $(LIBS)
+ 
+ tidy dist clean spotless:
+ 	rm -f $(BINS)
+-- 
+2.1.4
+
diff --git a/boot/syslinux/Config.in b/boot/syslinux/Config.in
index 6067e9c..299a559 100644
--- a/boot/syslinux/Config.in
+++ b/boot/syslinux/Config.in
@@ -1,12 +1,13 @@
 config BR2_TARGET_SYSLINUX
 	bool "syslinux"
 	depends on BR2_i386 || BR2_x86_64
-	select BR2_HOSTARCH_NEEDS_IA32_COMPILER
 	# Make sure at least one of the flavors is installed
 	select BR2_TARGET_SYSLINUX_ISOLINUX \
 		if !BR2_TARGET_SYSLINUX_PXELINUX && \
 		   !BR2_TARGET_SYSLINUX_MBR && \
 		   !BR2_TARGET_SYSLINUX_EFI
+	select BR2_PACKAGE_UTIL_LINUX
+	select BR2_PACKAGE_UTIL_LINUX_LIBUUID
 	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 5b7906c..2b3b9a7 100644
--- a/boot/syslinux/syslinux.mk
+++ b/boot/syslinux/syslinux.mk
@@ -13,7 +13,7 @@ SYSLINUX_LICENSE_FILES = COPYING
 
 SYSLINUX_INSTALL_IMAGES = YES
 
-SYSLINUX_DEPENDENCIES = host-nasm host-util-linux host-upx
+SYSLINUX_DEPENDENCIES = host-nasm host-upx util-linux
 
 ifeq ($(BR2_TARGET_SYSLINUX_LEGACY_BIOS),y)
 SYSLINUX_TARGET += bios
@@ -51,21 +51,36 @@ SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
 # 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)" $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
+	$(TARGET_MAKE_ENV) $(MAKE1) \
+		CC="$(TARGET_CC)" \
+		LD="$(TARGET_LD)" \
+		NASM="$(HOST_DIR)/usr/bin/nasm" \
+		CC_FOR_BUILD="$(HOSTCC)" \
+		CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
+		LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
+            $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
 endef
 
 # While the actual bootloader is compiled for the target, several
 # utilities for installing the bootloader are meant for the host.
 # Repeat the target, otherwise syslinux will try to build everything
-# Repeat CC and AR, since syslinux really wants to check them at
-# install time
+# Repeat LD (and CC) as it happens that some binaries are linked at
+# install-time.
 define SYSLINUX_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) CC="$(HOSTCC) -idirafter $(HOST_DIR)/usr/include $(HOST_LDFLAGS)" \
-		AR="$(HOSTAR)" $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \
+	$(TARGET_MAKE_ENV) $(MAKE1) $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \
+		CC="$(TARGET_CC)" \
+		LD="$(TARGET_LD)" \
 		-C $(@D) $(SYSLINUX_TARGET) install
 endef
 
+# That 'syslinux' binary is an installer actually built for the target.
+# However, buildroot makes no usage of it, so better delete it than have it
+# installed@the wrong place
+define SYSLINUX_POST_INSTALL_CLEANUP
+	rm -rf $(HOST_DIR)/usr/bin/syslinux
+endef
+SYSLINUX_POST_INSTALL_TARGET_HOOKS += SYSLINUX_POST_INSTALL_CLEANUP
+
 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_ISOLINUX) += bios/core/isolinux.bin
 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_PXELINUX) += bios/core/pxelinux.bin
 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_MBR) += bios/mbr/mbr.bin
-- 
2.1.4

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

* [Buildroot] [PATCH v5] syslinux: build with the target toolchain
  2017-04-07  9:05     ` [Buildroot] [PATCH v5] " Benoît Allard
@ 2017-04-08 14:08       ` Thomas Petazzoni
  2017-04-11  7:45         ` Benoît Allard
  2017-04-24 19:19       ` Peter Korsgaard
  1 sibling, 1 reply; 18+ messages in thread
From: Thomas Petazzoni @ 2017-04-08 14:08 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri,  7 Apr 2017 11:05:13 +0200, Beno?t Allard wrote:
> Until now, the host toolchain was used to build syslinux, as it was
> not possible to build a 32-bit syslinux with a x86-64 toolchain.
> 
> However, syslinux requires gnu-efi, and gnu-efi is built using the
> target toolchain. Mixing different toolchains doesn't work well, so
> this commit changes the syslinux package to use the target toolchain
> for syslinux as well. This is made possible by patches
> 0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch and
> 0004-memdisk-Force-ld-output-format-to-32-bits.patch.
> 
> Since syslinux also contains some utilities that have to run on the
> host, those have to continue being built with the host toolchain,
> which requires patch 0005-utils-Use-the-host-toolchain-to-build.patch.
> 
> Patch 0006-lzo-Use-the-host-toolchain-for-prepcore.patch is about
> building prepcore, another utility with the host toolchain as it is
> required at build-time.
> 
> This was tested using a Buildroot's built x86_64 toolchain, and
> checked that the output binaries are 32-bits. It was tested as well if
> they actually boot on hardware.
> 
> Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>
> 
> ---

Applied to master, thanks. Now, could you try to submit those patches
to the upstream project?

Thanks a lot!

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

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

* [Buildroot] [PATCH v5] syslinux: build with the target toolchain
  2017-04-08 14:08       ` Thomas Petazzoni
@ 2017-04-11  7:45         ` Benoît Allard
  2017-04-12  8:34           ` Thomas Petazzoni
  0 siblings, 1 reply; 18+ messages in thread
From: Benoît Allard @ 2017-04-11  7:45 UTC (permalink / raw)
  To: buildroot

On Sat, 8 Apr 2017 16:08:25 +0200
Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:

> Applied to master, thanks. Now, could you try to submit those patches
> to the upstream project?

I'm on it, unfortunately, the traction is not very high. I feel like I
opened one of those can of worms that have been tackled over and over
again without reaching a satisfactory solution (autoconf ?!). The first
answer I got was 'stop assuming everyone has needs similars to yours',
I'm now waiting on further one.

You can follow the show over there:
http://www.syslinux.org/archives/2017-April/

Regards,
Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170411/0badbbcc/attachment.asc>

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

* [Buildroot] [PATCH v5] syslinux: build with the target toolchain
  2017-04-11  7:45         ` Benoît Allard
@ 2017-04-12  8:34           ` Thomas Petazzoni
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2017-04-12  8:34 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue, 11 Apr 2017 09:45:51 +0200, Beno?t Allard wrote:

> > Applied to master, thanks. Now, could you try to submit those patches
> > to the upstream project?  
> 
> I'm on it, unfortunately, the traction is not very high. I feel like I
> opened one of those can of worms that have been tackled over and over
> again without reaching a satisfactory solution (autoconf ?!). The first
> answer I got was 'stop assuming everyone has needs similars to yours',
> I'm now waiting on further one.
> 
> You can follow the show over there:
> http://www.syslinux.org/archives/2017-April/

Thanks for doing this work. I think your reply is good, and hopefully
will make the syslinux developers change a bit their mind. If not, then
fine, we can keep the patches in Buildroot. I at least would like
people to try upstreaming the patches, and make reasonable efforts,
which you did.

Thanks a lot!

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

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

* [Buildroot] [PATCH v5] syslinux: build with the target toolchain
  2017-04-07  9:05     ` [Buildroot] [PATCH v5] " Benoît Allard
  2017-04-08 14:08       ` Thomas Petazzoni
@ 2017-04-24 19:19       ` Peter Korsgaard
  1 sibling, 0 replies; 18+ messages in thread
From: Peter Korsgaard @ 2017-04-24 19:19 UTC (permalink / raw)
  To: buildroot

>>>>> "Beno?t" == Beno?t Allard <benoit.allard@greenbone.net> writes:

 > Until now, the host toolchain was used to build syslinux, as it was
 > not possible to build a 32-bit syslinux with a x86-64 toolchain.

 > However, syslinux requires gnu-efi, and gnu-efi is built using the
 > target toolchain. Mixing different toolchains doesn't work well, so
 > this commit changes the syslinux package to use the target toolchain
 > for syslinux as well. This is made possible by patches
 > 0003-Fix-ldlinux.elf-Not-enough-room-for-program-headers-.patch and
 > 0004-memdisk-Force-ld-output-format-to-32-bits.patch.

 > Since syslinux also contains some utilities that have to run on the
 > host, those have to continue being built with the host toolchain,
 > which requires patch 0005-utils-Use-the-host-toolchain-to-build.patch.

 > Patch 0006-lzo-Use-the-host-toolchain-for-prepcore.patch is about
 > building prepcore, another utility with the host toolchain as it is
 > required at build-time.

 > This was tested using a Buildroot's built x86_64 toolchain, and
 > checked that the output binaries are 32-bits. It was tested as well if
 > they actually boot on hardware.

 > Signed-off-by: Beno?t Allard <benoit.allard@greenbone.net>

Committed to 2017.02.x, thanks.

-- 
Bye, Peter Korsgaard

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

end of thread, other threads:[~2017-04-24 19:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-05 10:09 [Buildroot] [PATCH] syslinux: Builds with the target toolchain Benoît Allard
2017-04-05 11:02 ` Thomas Petazzoni
2017-04-05 13:38   ` Benoît Allard
2017-04-05 14:48     ` Arnout Vandecappelle
2017-04-05 13:28 ` [Buildroot] [PATCH v2 1/2] " Benoît Allard
2017-04-05 13:28   ` [Buildroot] [PATCH v2 2/2] Take ownership of the (orphaned) syslinux package Benoît Allard
2017-04-05 14:51     ` Arnout Vandecappelle
2017-04-05 19:07     ` Thomas Petazzoni
2017-04-05 20:25   ` [Buildroot] [PATCH v2 1/2] syslinux: Builds with the target toolchain Thomas Petazzoni
2017-04-06 10:04   ` [Buildroot] [PATCH v4 1/1] syslinux: build " Benoît Allard
2017-04-06 15:13     ` Thomas Petazzoni
2017-04-07  8:06       ` Benoît Allard
2017-04-07  8:16         ` Thomas Petazzoni
2017-04-07  9:05     ` [Buildroot] [PATCH v5] " Benoît Allard
2017-04-08 14:08       ` Thomas Petazzoni
2017-04-11  7:45         ` Benoît Allard
2017-04-12  8:34           ` Thomas Petazzoni
2017-04-24 19:19       ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.