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
This commit is contained in:
Eduard Abdullin 2026-08-13 12:59:02 +00:00 committed by root
parent 8371abc679
commit bcef07fab4
3 changed files with 67 additions and 1 deletions

View File

@ -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 <eabdullin@almalinux.org> - 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 <polacek@redhat.com> 16.1.1-4.1
- fix gating problems
- fix asneeded libraries

View File

@ -0,0 +1,29 @@
From 8afa08292030c4da33ebf80ce39353678d9d9955 Mon Sep 17 00:00:00 2001
From: Andrew Lukoshko <alukoshko@almalinux.org>
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

View File

@ -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<wchar_t>::_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");