From c8edf81e6fd90c66701a92e18c14719ddfcebf74 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Thu, 17 Apr 2025 00:18:59 +0200 Subject: [PATCH] Fix riscv64 build Resolves: RHEL-149798 Thanks: Marcin Juszkiewicz Signed-off-by: Andrea Bolognani --- ...llow-linking-non-PIC-into-shared-obj.patch | 47 +++++++++++++++++++ libtool.spec | 10 +++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 0006-RISC-V-doesn-t-allow-linking-non-PIC-into-shared-obj.patch diff --git a/0006-RISC-V-doesn-t-allow-linking-non-PIC-into-shared-obj.patch b/0006-RISC-V-doesn-t-allow-linking-non-PIC-into-shared-obj.patch new file mode 100644 index 0000000..dc534af --- /dev/null +++ b/0006-RISC-V-doesn-t-allow-linking-non-PIC-into-shared-obj.patch @@ -0,0 +1,47 @@ +From 710874215f449c23b86eb1ce3ddcd6b8116e55d9 Mon Sep 17 00:00:00 2001 +From: Palmer Dabbelt +Date: Thu, 1 Feb 2024 12:34:14 -0800 +Subject: [PATCH] RISC-V doesn't allow linking non-PIC into shared objects + +I'm not sure exactly why, but it looks like this has started failing on +the latest Fedora rebuilds (with a bump to GCC-14 prereleases) with +errors along the lines of + + /usr/bin/ld: .libs/libhello_la-hello.o: relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC + /usr/bin/ld: .libs/libhello_la-foo.o: relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC + /usr/bin/ld: unresolvable R_RISCV_CALL_PLT relocation against symbol `puts@@GLIBC_2.27' + /usr/bin/ld: unresolvable R_RISCV_CALL_PLT relocation against symbol `__printf_chk@@GLIBC_2.27' + +As far as I can tell this always should have failed on RISC-V, as +non-PIC objects have never worked correctly in shared libraries. We +have added some stricter linker error checking over the last few months +so it's possible this is a newly reported error, but I'd guess that the +resulting binaries have always been invalid. + +Regardless of exactly why it's getting noticed now, R_RISCV_HI20 is very +much an absolute relocation (it maps to LUI, which just loads up a +constant address) and thus won't work for shared libraries. Given that +other ports skip this test that seems like the way to go for RISC-V +as well. + +Signed-off-by: Palmer Dabbelt +--- + tests/demo.at | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/demo.at b/tests/demo.at +index 28b2d1f0..b82684a1 100644 +--- a/tests/demo.at ++++ b/tests/demo.at +@@ -511,7 +511,7 @@ AT_CLEANUP + AT_SETUP([force non-PIC objects]) + + AT_CHECK([case $host in +-hppa*|x86_64*|s390*|arm*) ++hppa*|x86_64*|s390*|arm*|riscv*) + # These hosts cannot use non-PIC shared libs + exit 77 ;; + *-solaris*|*-sunos*) +-- +2.49.0 + diff --git a/libtool.spec b/libtool.spec index 60150a0..fb988b3 100644 --- a/libtool.spec +++ b/libtool.spec @@ -8,7 +8,7 @@ Summary: The GNU Portable Library Tool Name: libtool Version: 2.4.7 -Release: 13%{?dist} +Release: 14%{?dist} # To help future rebase, the following licenses were seen in the following files/folders: # '*' is anything that was not explicitly listed earlier in the folder @@ -76,6 +76,10 @@ Patch4: libtool-2.4.6-keep-compiler-deps.patch # https://lists.gnu.org/archive/html/libtool-patches/2022-12/msg00004.html Patch5: 0001-tests-Fix-grep-warning-about-stray-before.patch +# Patch sent upstream +# https://lists.gnu.org/archive/html/libtool-patches/2024-02/msg00002.html +Patch6: 0006-RISC-V-doesn-t-allow-linking-non-PIC-into-shared-obj.patch + %if ! 0%{?_module_build} Patch100: libtool-nodocs.patch %endif @@ -204,6 +208,10 @@ rm -f %{buildroot}%{_libdir}/libltdl.{a,la} %changelog +* Sun Feb 15 2026 Andrea Bolognani - 2.4.7-14 +- Fix riscv64 build + Resolves: RHEL-149798 + * Tue Oct 29 2024 Troy Dawson - 2.4.7-13 - Bump release for October 2024 mass rebuild: Resolves: RHEL-64018