File 0019-gcc-10-compatibility.patch of Package syslinux
From: Lukas Schwaighofer <lukas@schwaighofer.name>
Date: Sun, 16 Aug 2020 15:23:21 +0200
Subject: GCC-10 compatibility patch
* Add `-fcommon` to most gcc invocations to allow duplicate definitions
* __builtin_strlen is not really a "builtin" an implementation still
needs to be provided (source:
https://bugzilla.suse.com/show_bug.cgi?id=1166605#c5). Work around the
issue by supplying an inline function. The strlen function added to
dos/string.h was copied from com32/lib/strlen.c.
---
dos/string.h | 11 ++++++++++-
mk/efi.mk | 1 +
mk/elf.mk | 1 +
mk/embedded.mk | 2 +-
mk/lib.mk | 2 +-
5 files changed, 14 insertions(+), 3 deletions(-)
Index: b/dos/string.h
===================================================================
--- a/dos/string.h
+++ b/dos/string.h
@@ -5,12 +5,21 @@
#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)
+
+static inline size_t strlen(const char *s)
+{
+ const char *ss = s;
+ while (*ss)
+ ss++;
+ return ss - s;
+}
/* This only returns true or false */
static inline int memcmp(const void *__m1, const void *__m2, unsigned int __n)
Index: b/mk/efi.mk
===================================================================
--- a/mk/efi.mk
+++ b/mk/efi.mk
@@ -25,6 +25,7 @@ FORMAT=efi-app-$(EFI_SUBARCH)
CFLAGS = -I$(EFIINC) -I$(EFIINC)/$(EFI_SUBARCH) \
-DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \
+ -fcommon \
-Wall -I$(com32)/include -I$(com32)/include/sys \
-I$(core)/include -I$(core)/ $(ARCHOPT) \
-I$(com32)/lib/ -I$(com32)/libutil/include -std=gnu99 \
Index: b/mk/elf.mk
===================================================================
--- a/mk/elf.mk
+++ b/mk/elf.mk
@@ -55,6 +55,7 @@ GPLINCLUDE =
endif
CFLAGS = $(GCCOPT) $(GCCWARN) -W -Wall \
+ -fcommon \
-fomit-frame-pointer -D__COM32__ -D__FIRMWARE_$(FIRMWARE)__ -DDYNAMIC_MODULE \
-nostdinc -iwithprefix include \
-I$(com32)/libutil/include -I$(com32)/include \
Index: b/mk/embedded.mk
===================================================================
--- a/mk/embedded.mk
+++ b/mk/embedded.mk
@@ -57,7 +57,7 @@ LIBGCC := $(shell $(CC) $(GCCOPT) --p
LD += -m elf_$(ARCH)
# Note: use += for CFLAGS and SFLAGS in case something is set in MCONFIG.local
-CFLAGS += $(GCCOPT) -g $(GCCWARN) -Wno-sign-compare $(OPTFLAGS) $(INCLUDES)
+CFLAGS += $(GCCOPT) -g $(GCCWARN) -Wno-sign-compare -fcommon $(OPTFLAGS) $(INCLUDES)
SFLAGS += $(CFLAGS) -D__ASSEMBLY__
.SUFFIXES: .c .o .S .s .i .elf .com .bin .asm .lst .c32 .lss
Index: b/mk/lib.mk
===================================================================
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -49,7 +49,7 @@ OPTFLAGS = -Os -march=$(MARCH) -falign-
-falign-labels=0 -ffast-math -fomit-frame-pointer
WARNFLAGS = $(GCCWARN) -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
-CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS)
+CFLAGS = $(OPTFLAGS) $(REQFLAGS) -fcommon $(WARNFLAGS) $(LIBFLAGS)
ifeq ($(FWCLASS),EFI)
CFLAGS += -mno-red-zone