#2 Patches to fix FTBFS in F32/F33/ELN
Merged 3 years ago by javierm. Opened 3 years ago by merlinm.
rpms/ merlinm/syslinux ftbfs  into  master

@@ -0,0 +1,109 @@ 

+ From 951928f2cad5682c2844e6bd0f7201236c5d9b66 Mon Sep 17 00:00:00 2001

+ From: Merlin Mathesius <mmathesi@redhat.com>

+ Date: Wed, 13 May 2020 08:02:27 -0500

+ Subject: [PATCH] Workaround multiple definition of symbol errors

+ 

+ ---

+  com32/cmenu/Makefile           | 2 +-

+  com32/elflink/ldlinux/Makefile | 2 +-

+  com32/gpllib/Makefile          | 2 +-

+  com32/hdt/Makefile             | 2 +-

+  core/Makefile                  | 2 +-

+  dos/Makefile                   | 2 +-

+  efi/Makefile                   | 2 +-

+  7 files changed, 7 insertions(+), 7 deletions(-)

+ 

+ diff --git a/com32/cmenu/Makefile b/com32/cmenu/Makefile

+ index b81b68ed..2ae989c4 100644

+ --- a/com32/cmenu/Makefile

+ +++ b/com32/cmenu/Makefile

+ @@ -49,7 +49,7 @@ makeoutputdirs:

+  	@mkdir -p $(OBJ)/libmenu

+  

+  libmenu/libmenu.elf: $(LIBMENU)

+ -	$(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) \

+ +	$(LD) -shared $(LDFLAGS) -z muldefs -soname $(patsubst %.elf,%.c32,$(@F)) \

+  		-o $@ $^

+  

+  tidy dist:

+ diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile

+ index 87c0d362..2be2a01a 100644

+ --- a/com32/elflink/ldlinux/Makefile

+ +++ b/com32/elflink/ldlinux/Makefile

+ @@ -33,7 +33,7 @@ endif

+  all: $(BTARGET) ldlinux_lnx.a

+  

+  ldlinux.elf : $(OBJS)

+ -	$(LD) $(LDFLAGS) -soname $(SONAME) -o $@ $^ $(LIBS)

+ +	$(LD) $(LDFLAGS) -z muldefs -soname $(SONAME) -o $@ $^ $(LIBS)

+  

+  LNXCFLAGS += -D__export='__attribute__((visibility("default")))'

+  LNXLIBOBJS = get_key.lo

+ diff --git a/com32/gpllib/Makefile b/com32/gpllib/Makefile

+ index 1fec9145..2d764d0b 100644

+ --- a/com32/gpllib/Makefile

+ +++ b/com32/gpllib/Makefile

+ @@ -24,7 +24,7 @@ makeoutputdirs:

+  		$(addprefix $(OBJ),$(sort $(dir $(LIBOBJS)))),$(b))

+  

+  libgpl.elf : $(LIBOBJS)

+ -	$(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^

+ +	$(LD) -shared $(LDFLAGS) -z muldefs -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^

+  

+  tidy dist clean:

+  	find . \( -name \*.o -o -name .\*.d -o -name \*.tmp \) -print0 | \

+ diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile

+ index 61736d05..1d947857 100644

+ --- a/com32/hdt/Makefile

+ +++ b/com32/hdt/Makefile

+ @@ -52,7 +52,7 @@ QEMU			?= qemu-kvm

+  all: $(MODULES) $(TESTFILES)

+  

+  hdt.elf : $(OBJS) $(LIBS) $(C_LIBS)

+ -	$(LD) $(LDFLAGS) -o $@ $^

+ +	$(LD) $(LDFLAGS) -z muldefs -o $@ $^

+  

+  memtest:

+  	-[ ! -f $(FLOPPY_DIR)/$(MEMTEST) ] && $(WGET) $(MEMTEST_URL) -O $(FLOPPY_DIR)/$(MEMTEST)

+ diff --git a/core/Makefile b/core/Makefile

+ index 46cb037c..f0cfcbe9 100644

+ --- a/core/Makefile

+ +++ b/core/Makefile

+ @@ -156,7 +156,7 @@ LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld

+  NASM_ELF = elf

+  

+  %.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)

+ -	$(LD) $(LDFLAGS) -pie -Bsymbolic \

+ +	$(LD) $(LDFLAGS) -z muldefs -pie -Bsymbolic \

+  		-T $(LDSCRIPT) \

+  		--unresolved-symbols=report-all \

+  		-E --hash-style=gnu -M -o $@ $< \

+ diff --git a/dos/Makefile b/dos/Makefile

+ index 4c930d19..5d1c72ca 100644

+ --- a/dos/Makefile

+ +++ b/dos/Makefile

+ @@ -19,7 +19,7 @@ include $(MAKEDIR)/embedded.mk

+  CFLAGS	+= -D__MSDOS__ -mregparm=3 -DREGPARM=3

+  # CFLAGS  += -DDEBUG

+  

+ -LDFLAGS	 = -T $(SRC)/dosexe.ld

+ +LDFLAGS	 = -T $(SRC)/dosexe.ld -z muldefs

+  OPTFLAGS = -g

+  INCLUDES = -include code16.h -nostdinc -iwithprefix include \

+  	   -I$(SRC) -I$(SRC)/.. -I$(SRC)/../libfat \

+ diff --git a/efi/Makefile b/efi/Makefile

+ index bbf23f24..3dd922d5 100644

+ --- a/efi/Makefile

+ +++ b/efi/Makefile

+ @@ -69,7 +69,7 @@ $(OBJS): | $(OBJ)/$(ARCH)

+  BTARGET  = syslinux.efi

+  

+  syslinux.so: $(OBJS) $(CORE_OBJS) $(LIB_OBJS)

+ -	$(LD) $(LDFLAGS) --strip-debug -o $@ $^ -lgnuefi -lefi

+ +	$(LD) $(LDFLAGS) -z muldefs --strip-debug -o $@ $^ -lgnuefi -lefi

+  

+  # We need to rename the .hash section because the EFI firmware

+  # linker really doesn't like it.

+ -- 

+ 2.25.1

+ 

@@ -0,0 +1,40 @@ 

+ From eae06bdce9468d7fde263de1c53f80f2faff0c9e Mon Sep 17 00:00:00 2001

+ From: Merlin Mathesius <mmathesi@redhat.com>

+ Date: Wed, 13 May 2020 11:58:37 -0500

+ Subject: [PATCH] Replace builtin strlen that appears to get optimized away

+ 

+ ---

+  dos/string.h | 12 +++++++++++-

+  1 file changed, 11 insertions(+), 1 deletion(-)

+ 

+ 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)

+ -- 

+ 2.25.1

+ 

file modified
+7 -1
@@ -7,7 +7,7 @@ 

  Name: syslinux

  Version: 6.04

  %define tarball_version 6.04-pre1

- Release: 0.14%{?dist}

+ Release: 0.15%{?dist}

  License: GPLv2+

  URL: http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project

  Source0: http://www.kernel.org/pub/linux/utils/boot/syslinux/%{name}-%{tarball_version}.tar.xz
@@ -15,6 +15,8 @@ 

  Patch0002: 0002-ext4-64bit-feature.patch

  Patch0003: 0003-include-sysmacros-h.patch

  Patch0004: 0004-Add-RPMOPTFLAGS-to-CFLAGS-for-some-stuff.patch

+ Patch0005: 0005-Workaround-multiple-definition-of-symbol-errors.patch

+ Patch0006: 0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch

  

  # this is to keep rpmbuild from thinking the .c32 / .com / .0 / memdisk files

  # in noarch packages are a reason to stop the build.
@@ -24,6 +26,7 @@ 

  %ifarch %{buildarches}

  BuildRequires:  gcc

  BuildRequires: nasm >= 0.98.38-1, perl-interpreter, perl-generators, netpbm-progs

+ BuildRequires: perl(FileHandle)

  BuildRequires: /usr/include/gnu/stubs-32.h

  BuildRequires: libuuid-devel

  Requires: syslinux-nonlinux = %{version}-%{release}
@@ -252,6 +255,9 @@ 

  %endif

  

  %changelog

+ * Wed May 13 2020 Merlin Mathesius <mmathesi@redhat.com> - 6.04-0.15

+ - Patches to fix FTBFS in F32/F33/ELN (RHBZ#1800180)

+ 

  * Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 6.04-0.14

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

  

As reported by RHBZ#1800180, syslinux fails to built from source in Fedora 32 and Fedora 33. It also fails for the new ELN.

This PR provides patches to make the builds succeed. Three different problems were addressed:

  1. The Perl FileHandle.pm module was part of the base perl-interpreter package for F32 and earlier, and it is a separate sub-package for F33+ and ELN. Thus, a specific build dependency has been added to the SPEC file.
  2. The GNU linker handling of multiply defined symbols has apparently changed in recent releases. To address this, -z muldefs was added to the the loader flags in several Makefiles.
  3. The GCC optimizer apparently does away with using the internal version of strlen()--__builtin_strlen(). To address this, an inline version was added to dos/string.h.

There are probably better ways to do all of this, but these patches do get the package building again!

Signed-off-by: Merlin Mathesius mmathesi@redhat.com

@merlinm thanks a lot for this. I agree with the changes, we can latter address the issue of having multiple defined symbols in syslinux to not require -z muldefs.

Pull-Request has been merged by javierm

3 years ago