From bcef07fab4aa92fbbd28c65f1348c0e70bf02253 Mon Sep 17 00:00:00 2001 From: Eduard Abdullin Date: Thu, 13 Aug 2026 12:59:02 +0000 Subject: [PATCH] Fix compilation on RISC-V Do not assert .hidden on a libstdc++ instantiation that is not emitted below x86-64-v3 (fixes x86_64_v2) Set --with-arch_64=x86-64-v2 on v2 arch --- gcc-toolset-16-gcc.spec | 20 +++++++++++++++++- gcc16-riscv64-extfloat.patch | 29 ++++++++++++++++++++++++++ gcc16-x86_64_v2-nonshared-hidden.patch | 19 +++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 gcc16-riscv64-extfloat.patch create mode 100644 gcc16-x86_64_v2-nonshared-hidden.patch diff --git a/gcc-toolset-16-gcc.spec b/gcc-toolset-16-gcc.spec index dd146c8..bfa2faa 100644 --- a/gcc-toolset-16-gcc.spec +++ b/gcc-toolset-16-gcc.spec @@ -180,7 +180,7 @@ BuildRequires: gcc-toolset-%{gts_ver}-devel Summary: GCC version %{gcc_major} Name: %{?scl_prefix}gcc Version: %{gcc_version} -Release: %{gcc_release}.1%{?dist} +Release: %{gcc_release}.1%{?dist}.alma.1 # License notes for some of the less obvious ones: # gcc/doc/cppinternals.texi: Linux-man-pages-copyleft-2-para # isl: MIT, BSD-2-Clause @@ -394,6 +394,10 @@ Patch3015: 0018-Use-CXX11-ABI.patch Patch3017: 0020-more-fixes.patch Patch3018: 0021-libstdc++-disable-tests.patch +# AlmaLinux Patch +Patch9001: gcc16-riscv64-extfloat.patch +Patch9002: gcc16-x86_64_v2-nonshared-hidden.patch + %if 0%{?rhel} == 10 %global nonsharedver 140 %endif @@ -785,6 +789,10 @@ touch -r isl-0.24/m4/ax_prog_cxx_for_build.m4 isl-0.24/m4/ax_prog_cc_for_build.m %patch -P3017 -p1 -b .dts-test-17~ %patch -P3018 -p1 -b .dts-test-18~ +# Applying AlmaLinux Patch +%patch -P9001 -p1 -b .gcc16-riscv64-extfloat +%patch -P9002 -p1 -b .gcc16-x86_64_v2-nonshared-hidden + find gcc/testsuite -name \*.pr96939~ | xargs rm -f echo 'Red Hat %{version}-%{gcc_release}' > gcc/DEV-PHASE @@ -1054,7 +1062,11 @@ CONFIGURE_OPTS="\ %ifarch x86_64 %if 0%{?rhel} > 8 %if 0%{?rhel} > 9 +%ifarch x86_64_v2 + --with-arch_64=x86-64-v2 \ +%else --with-arch_64=x86-64-v3 \ +%endif %else --with-arch_64=x86-64-v2 \ %endif @@ -3067,6 +3079,12 @@ fi %endif %changelog +* Thu Aug 13 2026 Eduard Abdullin - 16.1.1-4.1.alma.1 +- Fix compilation on RISC-V +- Do not assert .hidden on a libstdc++ instantiation that is not emitted below + x86-64-v3 (fixes x86_64_v2) +- Set --with-arch_64=x86-64-v2 on v2 arch + * Tue Jul 14 2026 Marek Polacek 16.1.1-4.1 - fix gating problems - fix asneeded libraries diff --git a/gcc16-riscv64-extfloat.patch b/gcc16-riscv64-extfloat.patch new file mode 100644 index 0000000..f0e4ef5 --- /dev/null +++ b/gcc16-riscv64-extfloat.patch @@ -0,0 +1,29 @@ +From 8afa08292030c4da33ebf80ce39353678d9d9955 Mon Sep 17 00:00:00 2001 +From: Andrew Lukoshko +Date: Wed, 18 Feb 2026 14:37:39 +0000 +Subject: [PATCH] libstdc++-v3: add __riscv constants to extfloat.S + +--- + libstdc++-v3/src/nonshared98/extfloat.S | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/libstdc++-v3/src/nonshared98/extfloat.S b/libstdc++-v3/src/nonshared98/extfloat.S +index c72980884..9fad014c4 100644 +--- a/libstdc++-v3/src/nonshared98/extfloat.S ++++ b/libstdc++-v3/src/nonshared98/extfloat.S +@@ -53,8 +53,11 @@ + #elif defined __s390__ + #define ALIGN1 .align 4 + #define ALIGN3 .align 2 ++#elif defined __riscv ++#define ALIGN1 .align 3 ++#define ALIGN3 .align 3 + #endif +-#if defined __x86_64__ || defined __powerpc64__ || defined __s390x__ || defined __ia64__ || defined __aarch64__ ++#if defined __x86_64__ || defined __powerpc64__ || defined __s390x__ || defined __ia64__ || defined __aarch64__ || defined __riscv + #define SIZE1 32 + #define SIZE2 16 + #define OFF 16 +-- +2.43.7 + diff --git a/gcc16-x86_64_v2-nonshared-hidden.patch b/gcc16-x86_64_v2-nonshared-hidden.patch new file mode 100644 index 0000000..1cc4675 --- /dev/null +++ b/gcc16-x86_64_v2-nonshared-hidden.patch @@ -0,0 +1,19 @@ +--- a/libstdc++-v3/src/nonshared20/format-inst.cc ++++ b/libstdc++-v3/src/nonshared20/format-inst.cc +@@ -30,7 +30,16 @@ + asm (".hidden _ZNSt8__detail18__to_chars_10_implImEEvPcjT_"); + #endif + #if defined(__x86_64__) ++/* The out-of-line copy of this instantiation only exists when the compiler ++ declines to inline it into __formatter_fp::_M_localize. On ++ x86-64 that happens from the x86-64-v3 ISA level upwards; with a lower ++ baseline (e.g. -march=x86-64-v2) the symbol is never emitted, and a bare ++ .hidden directive would then leave an undefined hidden symbol behind in ++ libstdc++_nonshared140.a, which cannot be satisfied from libstdc++.so.6 ++ and breaks the link with "hidden symbol ... isn't defined". */ ++#if defined(__AVX2__) + asm (".hidden _ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE22__resize_and_overwriteIZNKSt8__format14__formatter_fpIwE11_M_localizeESt17basic_string_viewIwS2_EcRKSt6localeEUlPwmE_EEvmT_"); ++#endif + asm (".hidden _ZNSt8__detail13__to_chars_16IjEESt15to_chars_resultPcS2_T_"); + #endif + asm (".hidden _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv");