commit 15f71716aa17dc446cbb4f76aeaf002f1a7bc776 Author: eabdullin Date: Thu Aug 13 15:50:07 2026 +0300 Initial commit Fix riscv64 and x86_64_v2 builds of gcc-toolset-16-gcc, and stop the v2 build from configuring the compiler for x86-64-v3. --with-arch_64 is guarded by %ifarch x86_64 in the spec, and AlmaLinux's rpm treats x86_64_v2 as matching x86_64, so the v2 toolset would otherwise default to generating x86-64-v3 code. Same rule as gcc-toolset-15-gcc. No bugurl rule is needed here: this spec already uses --with-bugurl=%dist_bug_report_url, which expands to bugs.almalinux.org. The other two failures are in the libstdc++ "nonshared" compat sources that Patch1000 (gcc16-libstdc++-compat.patch) creates, so neither has an upstream fix -- Red Hat builds neither arch. riscv64: nonshared98/extfloat.S has no __riscv branch in its arch chain and no #else fallback, so ALIGN1 reaches gas as a bare token: extfloat.S:279: Error: unrecognized opcode `align1' riscv64 was also missing from the 64-bit POINTER/SIZE group, which would have emitted a 32-bit typeinfo layout on LP64. Patch taken as is from autopatch/gcc-toolset-15-gcc, where it is already in use. x86_64_v2: nonshared20/format-inst.cc hardcodes .hidden for basic_string::__resize_and_overwrite::_M_localize>. That list was derived at the el10 baseline -march=x86-64-v3; at v2 the compiler inlines the instantiation away and emits nothing, so the bare .hidden directive leaves an undefined hidden symbol in libstdc++_nonshared140.a and the compat test link at the end of %build fails with hidden symbol `_ZNSt7__cxx1112basic_string...' isn't defined final link failed: bad value This is driven by %optflags, not by --with-arch_64, so it needs its own fix. Emission tracks the AVX2 boundary exactly (v1/v2 emit nothing, v3/v4 emit a 670-byte FUNC WEAK HIDDEN), so guard that one directive on __AVX2__. This is a no-op at v3 -- the symbol table is unchanged -- and it removes the dangling reference at v2. All 41 nonshared sources carrying .hidden were checked at both ISA levels; this is the only symbol that differs. diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..2de479b --- /dev/null +++ b/config.yaml @@ -0,0 +1,42 @@ +actions: + - replace: +# The spec guards --with-arch_64 with %ifarch x86_64, which also matches the +# x86_64_v2 arch, so without this the v2 toolset would default to generating +# x86-64-v3 code. + - target: "spec" + find: | + %if 0%{?rhel} > 9 + --with-arch_64=x86-64-v3 \ + replace: | + %if 0%{?rhel} > 9 + %ifarch x86_64_v2 + --with-arch_64=x86-64-v2 \ + %else + --with-arch_64=x86-64-v3 \ + %endif + count: 1 + +# No bugurl rule here: unlike gcc-toolset-15-gcc, this spec already uses +# --with-bugurl=%dist_bug_report_url, which almalinux-release expands to +# https://bugs.almalinux.org/ . + + - modify_release: + - suffix: ".alma.1" + enabled: true + auto_increment: true + + - changelog_entry: + - name: "Eduard Abdullin" + email: "eabdullin@almalinux.org" + line: + - "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" + + - add_files: + - type: "patch" + name: "gcc16-riscv64-extfloat.patch" + number: 9001 + - type: "patch" + name: "gcc16-x86_64_v2-nonshared-hidden.patch" + number: 9002 diff --git a/files/gcc16-riscv64-extfloat.patch b/files/gcc16-riscv64-extfloat.patch new file mode 100644 index 0000000..f0e4ef5 --- /dev/null +++ b/files/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/files/gcc16-x86_64_v2-nonshared-hidden.patch b/files/gcc16-x86_64_v2-nonshared-hidden.patch new file mode 100644 index 0000000..1cc4675 --- /dev/null +++ b/files/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");