[37/62] syslinux: Fix build with GCC 10

Message ID 20200816102953.3881-37-michael.tremer@ipfire.org
State Accepted
Commit 8ba15ff89a02041cf6ee30d1c51f09039cd2fa9a
Headers
Series [01/62] bison: Update to 3.7.1 |

Commit Message

Michael Tremer Aug. 16, 2020, 10:29 a.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/syslinux                                  |  2 +
 src/patches/syslinux-6.04_pre1-fcommon.patch  | 54 +++++++++++++++++++
 ...strlen-that-appears-to-get-optimized.patch | 28 ++++++++++
 3 files changed, 84 insertions(+)
 create mode 100644 src/patches/syslinux-6.04_pre1-fcommon.patch
 create mode 100644 src/patches/syslinux-6.04_replace-builtin-strlen-that-appears-to-get-optimized.patch
  

Patch

diff --git a/lfs/syslinux b/lfs/syslinux
index 1670da27e..b2eec0d5b 100644
--- a/lfs/syslinux
+++ b/lfs/syslinux
@@ -77,6 +77,8 @@  $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 
 	# Apply patches
 	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/syslinux-6.03-sysmacros.patch
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/syslinux-6.04_replace-builtin-strlen-that-appears-to-get-optimized.patch
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/syslinux-6.04_pre1-fcommon.patch
 
 	# Build
 	cd $(DIR_APP) && make bios $(MAKETUNING)
diff --git a/src/patches/syslinux-6.04_pre1-fcommon.patch b/src/patches/syslinux-6.04_pre1-fcommon.patch
new file mode 100644
index 000000000..7d061db26
--- /dev/null
+++ b/src/patches/syslinux-6.04_pre1-fcommon.patch
@@ -0,0 +1,54 @@ 
+https://bugs.gentoo.org/705730
+
+gcc-10 enabled f-no-common by default. Broke syslinux linking.
+--- a/mk/com32.mk
++++ b/mk/com32.mk
+@@ -47,6 +47,7 @@ GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
+ GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+ GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+ GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
++GCCOPT += $(call gcc_ok,-fcommon)
+ 
+ ifeq ($(FWCLASS),EFI)
+ GCCOPT += -mno-red-zone
+--- a/mk/elf.mk
++++ b/mk/elf.mk
+@@ -42,6 +42,7 @@ GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
+ GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+ GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+ GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
++GCCOPT += $(call gcc_ok,-fcommon)
+ 
+ com32 = $(topdir)/com32
+ core = $(topdir)/core
+--- a/mk/embedded.mk
++++ b/mk/embedded.mk
+@@ -51,6 +51,7 @@ GCCOPT    += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+ GCCOPT    += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+ GCCOPT    += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
+ GCCOPT    += $(call gcc_ok,-fvisibility=hidden)
++GCCOPT    += $(call gcc_ok,-fcommon)
+ 
+ LIBGCC    := $(shell $(CC) $(GCCOPT) --print-libgcc)
+ 
+--- a/mk/lib.mk
++++ b/mk/lib.mk
+@@ -28,6 +28,7 @@ GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
+ GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+ GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+ GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
++GCCOPT += $(call gcc_ok,-fcommon)
+ 
+ INCLUDE	= -I$(SRC)
+ STRIP	= strip --strip-all -R .comment -R .note
+--- a/mk/efi.mk
++++ b/mk/efi.mk
+@@ -7,7 +7,7 @@ core = $(topdir)/core
+ # Set up architecture specifics; for cross compilation, set ARCH as apt
+ # gnuefi sets up architecture specifics in ia32 or x86_64 sub directories
+ # set up the LIBDIR and EFIINC for building for the appropriate architecture
+-GCCOPT := $(call gcc_ok,-fno-stack-protector,)
++GCCOPT := $(call gcc_ok,-fno-stack-protector,) $(call gcc_ok,-fcommon)
+ EFIINC = $(objdir)/include/efi
+ LIBDIR  = $(objdir)/lib
+ 
diff --git a/src/patches/syslinux-6.04_replace-builtin-strlen-that-appears-to-get-optimized.patch b/src/patches/syslinux-6.04_replace-builtin-strlen-that-appears-to-get-optimized.patch
new file mode 100644
index 000000000..c70769fce
--- /dev/null
+++ b/src/patches/syslinux-6.04_replace-builtin-strlen-that-appears-to-get-optimized.patch
@@ -0,0 +1,28 @@ 
+diff --git a/dos/string.h b/dos/string.h
+index f648de2d..407d0233 100644
+--- a/dos/string.h
++++ b/dos/string.h
+@@ -5,12 +5,22 @@
+ #ifndef _STRING_H
+ #define _STRING_H
+ 
++#include <stddef.h>
++
+ /* Standard routines */
+ #define memcpy(a,b,c)	__builtin_memcpy(a,b,c)
+ #define memmove(a,b,c)	__builtin_memmove(a,b,c)
+ #define memset(a,b,c)	__builtin_memset(a,b,c)
+ #define strcpy(a,b)	__builtin_strcpy(a,b)
+-#define strlen(a)	__builtin_strlen(a)
++#define strlen(a)	inline_strlen(a)
++
++/* replacement for builtin strlen that appears to get optimized away */
++static inline size_t inline_strlen(const char *str)
++{
++    size_t l;
++    for (l = 0; *str++; l++);
++    return l;
++}
+ 
+ /* This only returns true or false */
+ static inline int memcmp(const void *__m1, const void *__m2, unsigned int __n)