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

List all undefined hidden symbols before the nonshared compat link

Set --with-arch_64=x86-64-v2 on v2 arch
This commit is contained in:
Eduard Abdullin 2026-08-20 09:57:30 +00:00 committed by root
parent 91405b2339
commit a4378c224d
2 changed files with 64 additions and 19 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.3
Release: %{gcc_release}.1%{?dist}.alma.4
# 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,6 +1260,12 @@ 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
@ -3079,13 +3085,16 @@ fi
%endif
%changelog
* Mon Aug 17 2026 Eduard Abdullin <eabdullin@almalinux.org> - 16.1.1-4.1.alma.3
* Thu Aug 20 2026 Eduard Abdullin <eabdullin@almalinux.org> - 16.1.1-4.1.alma.4
- 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
- List all undefined hidden symbols before the nonshared compat link
- 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

@ -46,9 +46,9 @@
asm (".hidden _ZNSt23_Sp_counted_ptr_inplaceINSt10filesystem4_DirESaIS1_ELN9__gnu_cxx12_Lock_policyE2EED2Ev");
#ifndef __i386__
asm (".hidden _ZNSt5dequeINSt10filesystem4_DirESaIS1_EE17_M_reallocate_mapEmb");
+/* Not emitted on riscv64: the compiler does not produce an out-of-line
+ copy of this noinline cold helper there, so asserting .hidden on it
+ would leave an undefined hidden symbol in libstdc++_nonshared140.a. */
+/* 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
@ -57,13 +57,26 @@
asm (".hidden _ZNSt10unique_ptrINSt10filesystem4path5_List5_ImplENS2_13_Impl_deleterEED1Ev");
--- a/libstdc++-v3/src/nonshared17/cow-fs_ops.cc
+++ b/libstdc++-v3/src/nonshared17/cow-fs_ops.cc
@@ -48,7 +48,12 @@
@@ -21,7 +21,12 @@
// <http://www.gnu.org/licenses/>.
#include "../c++17/cow-fs_ops.cc"
+/* 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 _ZNSt15_Sp_counted_ptrIDnLN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv");
+#endif
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv");
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 _ZNSs6resizeEmc");
//asm (".hidden _ZNSt10filesystem4pathD1Ev");
//asm (".hidden _ZNSt10filesystem4pathD2Ev");
+/* Not emitted on riscv64: the compiler does not produce an out-of-line
+ copy of this noinline cold helper there, so asserting .hidden on it
+ would leave an undefined hidden symbol in libstdc++_nonshared140.a. */
+/* 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
@ -76,9 +89,9 @@
//asm (".hidden _ZNSt10filesystem4path5_List5beginEv");
//asm (".hidden _ZNSt10filesystem4path7_Parser4nextEv");
#ifndef __i386__
+/* Not emitted on riscv64: the compiler does not produce an out-of-line
+ copy of this noinline cold helper there, so asserting .hidden on it
+ would leave an undefined hidden symbol in libstdc++_nonshared140.a. */
+/* 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
@ -91,24 +104,47 @@
asm (".hidden _ZZNSt19_Sp_make_shared_tag5_S_tiEvE5__tag");
asm (".hidden _ZNSt23_Sp_counted_ptr_inplaceINSt10filesystem7__cxx114_DirESaIS2_ELN9__gnu_cxx12_Lock_policyE2EED2Ev");
#ifndef __i386__
+/* Not emitted on riscv64: the compiler does not produce an out-of-line
+ copy of this noinline cold helper there, so asserting .hidden on it
+ would leave an undefined hidden symbol in libstdc++_nonshared140.a. */
+/* 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
asm (".hidden _ZNSt5dequeINSt10filesystem7__cxx114_DirESaIS2_EE17_M_reallocate_mapEmb");
#endif
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 @@
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");
+/* 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 _ZNSt15_Sp_counted_ptrIDnLN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv");
+#endif
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv");
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv");
//asm (".hidden _ZNSt5dequeINSt10filesystem7__cxx114pathESaIS2_EE16_M_push_back_auxIJRKS2_EEEvDpOT_");
--- a/libstdc++-v3/src/nonshared20/clock.cc
+++ b/libstdc++-v3/src/nonshared20/clock.cc
@@ -31,7 +31,12 @@
@@ -28,10 +28,20 @@
// P0355R7
#include "../c++20/clock.cc"
+/* 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 _ZNSt15_Sp_counted_ptrIDnLN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv");
+#endif
asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv");
#ifndef __i386__
+/* Not emitted on riscv64: the compiler does not produce an out-of-line
+ copy of this noinline cold helper there, so asserting .hidden on it
+ would leave an undefined hidden symbol in libstdc++_nonshared140.a. */
+/* 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