Fix compilation on RISC-V

Use 32-bit manglings in the libstdc++ nonshared .hidden list (fixes i686)

Do not assert .hidden on _M_release_last_use_cold, which is not emitted on riscv64

Do not assert .hidden on a libstdc++ instantiation that is not emitted below x86-64-v3 (fixes x86_64_v2)

Do not assert .hidden on _Sp_counted_ptr<nullptr_t>::_M_dispose, which is not emitted on riscv64

Do not assert .hidden on _Sp_counted_base<_S_atomic>::_M_destroy, which is not emitted on riscv64

Do not assert .hidden on __to_chars_10_impl<unsigned long>, which is not emitted on riscv64

Set --with-arch_64=x86-64-v2 on v2 arch
This commit is contained in:
Eduard Abdullin 2026-08-24 11:16:03 +00:00 committed by root
parent a4378c224d
commit 91680dcf40
2 changed files with 39 additions and 18 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}.alma.4
Release: %{gcc_release}.1%{?dist}.alma.5
# License notes for some of the less obvious ones:
# gcc/doc/cppinternals.texi: Linux-man-pages-copyleft-2-para
# isl: MIT, BSD-2-Clause
@ -1260,12 +1260,6 @@ cd ../..
# Test the nonshared bits.
mkdir libstdc++_compat_test
cd libstdc++_compat_test
# Report every undefined hidden symbol left in the nonshared archive up
# front: the link below stops at the first one, which turns each stale
# .hidden entry into a separate build.
echo ==============NONSHARED HIDDEN UND==============
readelf -Ws ../obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/src/.libs/libstdc++_nonshared%{nonsharedver}.a | grep HIDDEN.*UND | grep -v __dso_handle || :
echo ==============NONSHARED HIDDEN UND END==============
readelf -Ws %{?scl:%{_root_prefix}}%{!?scl:%{_prefix}}/%{_lib}/libstdc++.so.6 | sed -n '/\.symtab/,$d;/ UND /d;/@GLIBC_PRIVATE/d;/\(GLOBAL\|WEAK\|UNIQUE\)/p' | awk '{ if ($4 == "OBJECT") { printf "%s %s %s %s %s\n", $8, $4, $5, $6, $3 } else { printf "%s %s %s %s\n", $8, $4, $5, $6 }}' | sed 's/ UNIQUE / GLOBAL /;s/ WEAK / GLOBAL /;s/@@GLIBCXX_\(LDBL_\)\?[0-9.]*//;s/@@CXXABI_TM_[0-9.]*//;s/@@CXXABI_FLOAT128//;s/@@CXXABI_\(LDBL_\)\?[0-9.]*//' | LC_ALL=C sort -u > system.abilist
readelf -Ws ../obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/src/.libs/libstdc++.so.6 | sed -n '/\.symtab/,$d;/ UND /d;/@GLIBC_PRIVATE/d;/\(GLOBAL\|WEAK\|UNIQUE\)/p' | awk '{ if ($4 == "OBJECT") { printf "%s %s %s %s %s\n", $8, $4, $5, $6, $3 } else { printf "%s %s %s %s\n", $8, $4, $5, $6 }}' | sed 's/ UNIQUE / GLOBAL /;s/ WEAK / GLOBAL /;s/@@GLIBCXX_\(LDBL_\)\?[0-9.]*//;s/@@CXXABI_TM_[0-9.]*//;s/@@CXXABI_FLOAT128//;s/@@CXXABI_\(LDBL_\)\?[0-9.]*//' | LC_ALL=C sort -u > vanilla.abilist
diff -up system.abilist vanilla.abilist | awk '/^\+\+\+/{next}/^\+/{print gensub(/^+(.*)$/,"\\1","1",$0)}' > system2vanilla.abilist.diff
@ -3085,7 +3079,7 @@ fi
%endif
%changelog
* Thu Aug 20 2026 Eduard Abdullin <eabdullin@almalinux.org> - 16.1.1-4.1.alma.4
* Mon Aug 24 2026 Eduard Abdullin <eabdullin@almalinux.org> - 16.1.1-4.1.alma.5
- Fix compilation on RISC-V
- Use 32-bit manglings in the libstdc++ nonshared .hidden list (fixes i686)
- Do not assert .hidden on _M_release_last_use_cold, which is not emitted on
@ -3094,7 +3088,10 @@ fi
x86-64-v3 (fixes x86_64_v2)
- Do not assert .hidden on _Sp_counted_ptr<nullptr_t>::_M_dispose, which is not
emitted on riscv64
- List all undefined hidden symbols before the nonshared compat link
- Do not assert .hidden on _Sp_counted_base<_S_atomic>::_M_destroy, which is not
emitted on riscv64
- Do not assert .hidden on __to_chars_10_impl<unsigned long>, which is not
emitted on riscv64
- Set --with-arch_64=x86-64-v2 on v2 arch
* Tue Jul 14 2026 Marek Polacek <polacek@redhat.com> 16.1.1-4.1

View File

@ -1,11 +1,15 @@
--- a/libstdc++-v3/src/nonshared20/format-inst.cc
+++ b/libstdc++-v3/src/nonshared20/format-inst.cc
@@ -26,21 +26,39 @@
@@ -26,21 +26,43 @@
#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
asm (".hidden _ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEaSEOS4_");
asm (".hidden _ZNSt8__detail13__to_chars_16ImEESt15to_chars_resultPcS2_T_");
+#elif defined(__i386__)
+asm (".hidden _ZNSt8__detail18__to_chars_10_implIyEEvPcjT_");
+#elif defined(__riscv)
+/* __to_chars_10_impl<unsigned long> is not emitted on riscv64 -- unlike
+ s390x, which takes the same branch -- so the bare .hidden would leave an
+ undefined hidden symbol in libstdc++_nonshared140.a. */
#else
asm (".hidden _ZNSt8__detail18__to_chars_10_implImEEvPcjT_");
#endif
@ -42,7 +46,7 @@
asm (".hidden _ZNKSt8__format13_Padding_sinkINS_10_Sink_iterIcEEcE13_M_discardingEv");
--- a/libstdc++-v3/src/nonshared17/cow-fs_dir.cc
+++ b/libstdc++-v3/src/nonshared17/cow-fs_dir.cc
@@ -87,7 +87,12 @@
@@ -87,8 +87,13 @@
asm (".hidden _ZNSt23_Sp_counted_ptr_inplaceINSt10filesystem4_DirESaIS1_ELN9__gnu_cxx12_Lock_policyE2EED2Ev");
#ifndef __i386__
asm (".hidden _ZNSt5dequeINSt10filesystem4_DirESaIS1_EE17_M_reallocate_mapEmb");
@ -51,13 +55,14 @@
+ libstdc++_nonshared140.a. */
+#if !defined(__riscv)
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE24_M_release_last_use_coldEv");
+#endif
#endif
+#endif
#ifndef __powerpc64__
asm (".hidden _ZNSt10unique_ptrINSt10filesystem4path5_List5_ImplENS2_13_Impl_deleterEED1Ev");
asm (".hidden _ZNSt10unique_ptrINSt10filesystem4path5_List5_ImplENS2_13_Impl_deleterEED2Ev");
--- a/libstdc++-v3/src/nonshared17/cow-fs_ops.cc
+++ b/libstdc++-v3/src/nonshared17/cow-fs_ops.cc
@@ -21,7 +21,12 @@
@@ -21,8 +21,18 @@
// <http://www.gnu.org/licenses/>.
#include "../c++17/cow-fs_ops.cc"
@ -67,10 +72,16 @@
+#if !defined(__riscv)
asm (".hidden _ZNSt15_Sp_counted_ptrIDnLN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv");
+#endif
+/* Not emitted on riscv64: gcc produces no out-of-line copy there, so
+ asserting .hidden would leave an undefined hidden symbol in
+ libstdc++_nonshared140.a. */
+#if !defined(__riscv)
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv");
+#endif
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv");
//asm (".hidden _ZNSt5dequeINSt10filesystem4pathESaIS1_EE16_M_push_back_auxIJRKS1_EEEvDpOT_");
@@ -48,7 +53,12 @@
//asm (".hidden _ZNSt5dequeINSt10filesystem4pathESaIS1_EE16_M_push_back_auxIIRKS1_EEEvDpOT_");
@@ -48,8 +58,13 @@
//asm (".hidden _ZNSs6resizeEmc");
//asm (".hidden _ZNSt10filesystem4pathD1Ev");
//asm (".hidden _ZNSt10filesystem4pathD2Ev");
@ -79,10 +90,11 @@
+ libstdc++_nonshared140.a. */
+#if !defined(__riscv)
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE24_M_release_last_use_coldEv");
+#endif
#endif
+#endif
#if defined(__x86_64__)
//asm (".hidden _ZSt13move_backwardISt15_Deque_iteratorINSt10filesystem4pathERS2_PS2_ES5_ET0_T_S7_S6_");
//asm (".hidden _ZSt4moveISt15_Deque_iteratorINSt10filesystem4pathERS2_PS2_ES5_ET0_T_S7_S6_");
--- a/libstdc++-v3/src/nonshared17/cow-fs_path.cc
+++ b/libstdc++-v3/src/nonshared17/cow-fs_path.cc
@@ -85,7 +85,12 @@
@ -115,7 +127,7 @@
asm (".hidden _ZNSt10unique_ptrINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEED1Ev");
--- a/libstdc++-v3/src/nonshared17/fs_ops80.cc
+++ b/libstdc++-v3/src/nonshared17/fs_ops80.cc
@@ -25,7 +25,12 @@
@@ -25,8 +25,18 @@
asm (".hidden _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEED1Ev");
asm (".hidden _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEED2Ev");
asm (".hidden _ZNSt10filesystem12do_copy_fileEPKcS1_NS_26copy_options_existing_fileEP4statS4_RSt10error_code");
@ -125,12 +137,18 @@
+#if !defined(__riscv)
asm (".hidden _ZNSt15_Sp_counted_ptrIDnLN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv");
+#endif
+/* Not emitted on riscv64: gcc produces no out-of-line copy there, so
+ asserting .hidden would leave an undefined hidden symbol in
+ libstdc++_nonshared140.a. */
+#if !defined(__riscv)
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv");
+#endif
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv");
//asm (".hidden _ZNSt5dequeINSt10filesystem7__cxx114pathESaIS2_EE16_M_push_back_auxIJRKS2_EEEvDpOT_");
//asm (".hidden _ZNSt5dequeINSt10filesystem7__cxx114pathESaIS2_EE16_M_push_back_auxIIRKS2_EEEvDpOT_");
--- a/libstdc++-v3/src/nonshared20/clock.cc
+++ b/libstdc++-v3/src/nonshared20/clock.cc
@@ -28,10 +28,20 @@
@@ -28,11 +28,26 @@
// P0355R7
#include "../c++20/clock.cc"
@ -140,14 +158,20 @@
+#if !defined(__riscv)
asm (".hidden _ZNSt15_Sp_counted_ptrIDnLN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv");
+#endif
+/* Not emitted on riscv64: gcc produces no out-of-line copy there, so
+ asserting .hidden would leave an undefined hidden symbol in
+ libstdc++_nonshared140.a. */
+#if !defined(__riscv)
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv");
+#endif
#ifndef __i386__
+/* Not emitted on riscv64: gcc produces no out-of-line copy there, so
+ asserting .hidden would leave an undefined hidden symbol in
+ libstdc++_nonshared140.a. */
+#if !defined(__riscv)
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE24_M_release_last_use_coldEv");
+#endif
#endif
+#endif
#if defined(__i386__) || (defined(__powerpc__) && !defined(__powerpc64__))
asm (".hidden _ZNSt6chrono8__detail22__get_leap_second_infoENS_10time_pointINS_3_V212system_clockENS_8durationIxSt5ratioILx1ELx1EEEEEEb");
#else