From 49f36a506668ac8a23a83acc6bfa1b003264bd3a Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 24 Feb 2025 12:55:57 +0000 Subject: [PATCH] Fix assertion failure in ppc64 ld due to compiler miscompilation. Relates: RHEL-80372 --- binutils-PPC64-LD-ASSERT.patch | 47 ++++++++++++++++++++++++++++++++++ binutils.spec | 19 +++++++++++--- 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 binutils-PPC64-LD-ASSERT.patch diff --git a/binutils-PPC64-LD-ASSERT.patch b/binutils-PPC64-LD-ASSERT.patch new file mode 100644 index 0000000..4075de3 --- /dev/null +++ b/binutils-PPC64-LD-ASSERT.patch @@ -0,0 +1,47 @@ +diff -rup binutils.orig/gold/Makefile.am binutils-2.41/gold/Makefile.am +--- binutils.orig/gold/Makefile.am 2025-02-24 09:38:42.201892521 +0000 ++++ binutils-2.41/gold/Makefile.am 2025-02-24 11:02:18.892145832 +0000 +@@ -207,7 +207,7 @@ dwp_SOURCES = dwp.cc + dwp_DEPENDENCIES = libgold.a $(LIBIBERTY) $(LIBINTL_DEP) + dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADLIBS) \ + $(LIBDL) $(ZLIB) $(ZSTD_LIBS) $(JANSSON_LIBS) +-dwp_LDFLAGS = $(GOLD_LDFLAGS) ++dwp_LDFLAGS = $(GOLD_LDFLAGS) -fno-lto + + CONFIG_STATUS_DEPENDENCIES = $(srcdir)/../bfd/development.sh + +diff -rup binutils.orig/gold/Makefile.in binutils-2.41/gold/Makefile.in +--- binutils.orig/gold/Makefile.in 2025-02-24 09:38:42.201892521 +0000 ++++ binutils-2.41/gold/Makefile.in 2025-02-24 11:02:11.812124673 +0000 +@@ -835,7 +835,7 @@ dwp_DEPENDENCIES = libgold.a $(LIBIBERTY + dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADLIBS) \ + $(LIBDL) $(ZLIB) $(ZSTD_LIBS) $(JANSSON_LIBS) + +-dwp_LDFLAGS = $(GOLD_LDFLAGS) ++dwp_LDFLAGS = $(GOLD_LDFLAGS) -fno-lto + CONFIG_STATUS_DEPENDENCIES = $(srcdir)/../bfd/development.sh + POTFILES = $(CCFILES) $(HFILES) $(TARGETSOURCES) + @GCC_TRUE@@NATIVE_LINKER_TRUE@ld1_SOURCES = $(sources_var) +diff -rup binutils.orig/ld/ldlang.c binutils-2.41/ld/ldlang.c +--- binutils.orig/ld/ldlang.c 2025-02-24 09:38:42.413893857 +0000 ++++ binutils-2.41/ld/ldlang.c 2025-02-24 09:39:34.394224393 +0000 +@@ -7947,6 +7947,19 @@ lang_list_remove_tail (lang_statement_li + lang_statement_list_type *origlist) + { + union lang_statement_union **savetail; ++ ++ if (getenv ("LD_DEBUG_NEVER") != NULL) ++ { ++ /* FIXME: RHEL-49348: For some reason building this function for the ++ PowerPC architecture on RHEL-10 is resulting in a linker that ++ triggers the ASSERT below - because the origlist pointer is ++ corrupt. These fprintf statements, even if they will never be ++ used, are enough to cause the compiler to build the function ++ correctly, thus avoiding the problem. */ ++ fprintf (stderr, "origlist %p destlist %p\n", origlist, destlist); ++ fprintf (stderr, "heads: %p %p\n", origlist->head, destlist->head); ++ } ++ + /* Check that ORIGLIST really is an earlier state of DESTLIST. */ + ASSERT (origlist->head == destlist->head); + savetail = origlist->tail; diff --git a/binutils.spec b/binutils.spec index d52ec8f..d672078 100644 --- a/binutils.spec +++ b/binutils.spec @@ -9,7 +9,7 @@ BuildRequires: scl-utils-build Summary: A GNU collection of binary utilities Name: %{?scl_prefix}binutils Version: 2.41 -Release: 4%{?dist} +Release: 5%{?dist} License: GPL-3.0-or-later AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND (LGPL-2.0-or-later WITH GCC-exception-2.0) AND BSD-3-Clause AND GFDL-1.3-or-later AND GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later URL: https://sourceware.org/binutils @@ -346,6 +346,11 @@ Patch40: binutils-Intel-APX-CODE_6_GOTTPOFF.patch Patch41: binutils-LTO-plugin-common-symbols.patch +# Purpose: Workaround for an unresolved bug in ppc gcc +# which generates bad code in the linker. cf RHEL-49348 +# Lifetime: TEMPORARY +Patch98: binutils-PPC64-LD-ASSERT.patch + # Purpose: Suppress the x86 linker's p_align-1 tests due to kernel bug on CentOS-10 # Lifetime: TEMPORARY Patch99: binutils-suppress-ld-align-tests.patch @@ -942,7 +947,12 @@ build_target() %if %{with docs} # Because of parallel building, info has to be made after all. - %make_build %{_smp_mflags} tooldir=%{_prefix} CC=%gcc_for_binutils CXX=%gxx_for_binutils all + + # FIXME: Setting CXXFLAGS is a workaround for the PPC64 compiler bug (cf RHEL-49348). + # It allows the binutils to build using a version of gcc-toolset-14-ld that is already affected by the bug. + # Once built and installed into the buildroot, this fix will no longer be needed. + # Although whilst the bug in the PPC64 compiler remains Patch98 will still be needed. + %make_build %{_smp_mflags} tooldir=%{_prefix} CC=%gcc_for_binutils CXX=%gxx_for_binutils all CXXFLAGS="$RPM_OPT_FLAGS -fno-lto" %make_build %{_smp_mflags} tooldir=%{_prefix} CC=%gcc_for_binutils CXX=%gxx_for_binutils info %else %make_build %{_smp_mflags} tooldir=%{_prefix} CC=%gcc_for_binutils CXX=%gxx_for_binutils MAKEINFO=true all @@ -1493,8 +1503,11 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Feb 24 2025 Nick Clifton - 2.41-5 +- Fix assertion failure in ppc64 ld due to compiler miscompilation. + * Thu Feb 20 2025 Nick Clifton - 2.41-4 -- Backport fixes for PR 32082 and PR 32153 in order to fix the PR 20267 linker tests. +- Backport fixes for PR 32082 and PR 32153 in order to fix the PR 20267 linker tests. (RHEL-80372) * Fri Aug 16 2024 Nick Clifton - 2.41-3 - Fix restoring contect to gprofng.rc file. (RHEL-54563)