On Mon, Jan 12, 2026 at 12:13:35PM +0100, Florian Weimer wrote:
> One way to work around the libtool problem would be to stick the
> as-needed into an existing .so linker script, or create a new one under
> a different name (say libatomic_optional.so) that has AS_NEEDED in it,
> and link with -latomic_optional. Then libtool would not have to be
> taught about --push-state/--pop-state etc.
That seems to work.
So far bootstrapped (c,c++,fortran,lto only) and make install tested
on x86_64-linux, tested on a small program without need to libatomic and
struct S { char a[25]; };
_Atomic struct S s;
int main () { struct S t = s; s = t; }
which does at -O0.
Before this patch I got
for i in `find x86_64-pc-linux-gnu/ -name lib\*.so.\*.\*`; do ldd -u $i 2>&1 | grep -q libatomic.so.1 && echo $i; done
x86_64-pc-linux-gnu/libsanitizer/ubsan/.libs/libubsan.so.1.0.0
x86_64-pc-linux-gnu/libsanitizer/asan/.libs/libasan.so.8.0.0
x86_64-pc-linux-gnu/libsanitizer/hwasan/.libs/libhwasan.so.0.0.0
x86_64-pc-linux-gnu/libsanitizer/lsan/.libs/liblsan.so.0.0.0
x86_64-pc-linux-gnu/libsanitizer/tsan/.libs/libtsan.so.2.0.0
x86_64-pc-linux-gnu/32/libsanitizer/ubsan/.libs/libubsan.so.1.0.0
x86_64-pc-linux-gnu/32/libsanitizer/asan/.libs/libasan.so.8.0.0
x86_64-pc-linux-gnu/32/libstdc++-v3/src/.libs/libstdc++.so.6.0.35
x86_64-pc-linux-gnu/libgcobol/.libs/libgcobol.so.2.0.0
x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.35
With this patch it prints nothing.
2026-01-13 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/123396
gcc/
* configure.ac (gcc_cv_ld_use_as_needed_ldscript): New test.
(USE_LD_AS_NEEDED_LDSCRIPT): New AC_DEFINE.
* gcc.cc (LINK_LIBATOMIC_SPEC): Use "-latomic_asneeded" instead
of LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION
if USE_LD_AS_NEEDED_LDSCRIPT is defined.
(init_gcc_specs): Use "-lgcc_s_asneeded" instead of
LD_AS_NEEDED_OPTION " -lgcc_s " LD_NO_AS_NEEDED_OPTION
if USE_LD_AS_NEEDED_LDSCRIPT is defined.
* config.in: Regenerate.
* configure: Regenerate.
libatomic/
* acinclude.m4 (LIBAT_BUILD_ASNEEDED_SOLINK): New AM_CONDITIONAL.
* libatomic_asneeded.so: New file.
* libatomic_asneeded.a: New file.
* Makefile.am (toolexeclib_DATA): Set if LIBAT_BUILD_ASNEEDED_SOLINK.
(all-local): Install those files into gcc subdir.
* Makefile.in: Regenerate.
* configure: Regenerate.
libgcc/
* config/t-slibgcc (SHLIB_ASNEEDED_SOLINK,
SHLIB_MAKE_ASNEEDED_SOLINK, SHLIB_INSTALL_ASNEEDED_SOLINK): New
vars.
(SHLIB_LINK): Include $(SHLIB_MAKE_ASNEEDED_SOLINK).
(SHLIB_INSTALL): Include $(SHLIB_INSTALL_ASNEEDED_SOLINK).
This patch implements _BitInt support for RISC-V target by defining the
type layout and ABI requirements. The limb mode selection is based on
the bit width, using appropriate integer modes from QImode to TImode.
The implementation also adds the necessary libgcc version symbols for
_BitInt runtime support functions.
Changes in v3:
- Require sync_char_short effective target for bitint-64.c, bitint-82.c
and bitint-84.c tests since they use atomic operations.
- Add -fno-section-anchors to bitint-32-on-rv64.c and adjust expected
assembly output patterns.
Changes in v2:
- limb_mode use up to XLEN when N > XLEN, which is different setting from
the abi_limb_mode.
- Adding missing floatbitinthf in libgcc.
gcc/ChangeLog:
PR target/117581
* config/riscv/riscv.cc (riscv_bitint_type_info): New function.
(TARGET_C_BITINT_TYPE_INFO): Define.
gcc/testsuite/ChangeLog:
PR target/117581
* gcc.dg/torture/bitint-64.c: Add sync_char_short effective target
requirement.
* gcc.dg/torture/bitint-82.c: Likewise.
* gcc.dg/torture/bitint-84.c: Likewise.
* gcc.target/riscv/bitint-32-on-rv64.c: New test.
* gcc.target/riscv/bitint-alignments.c: New test.
* gcc.target/riscv/bitint-args.c: New test.
* gcc.target/riscv/bitint-sizes.c: New test.
libgcc/ChangeLog:
PR target/117581
* config/riscv/libgcc-riscv.ver: New file.
* config/riscv/t-elf (SHLIB_MAPFILES): Add libgcc-riscv.ver.
* config/riscv/t-softfp32 (softfp_extras): Add floatbitinttf and
fixtfbitint.
This header is not used any more and its inclusion is problematic
when building against Helix Cert as it might end up dragging LLVM-specific
headers from spinLockLib.h.
libgcc/
* config/gthr-vxworks.h: Remove #include of tickLib.h.
This patch adds support for _Float16. As time of writing this, there is
no hardware _Float16 support on s390. Therefore, _Float16 operations
have to be extended and truncated which is supported via soft-fp.
The ABI demands that _Float16 values are left aligned in FP registers
similar as it is already the case for 32-bit FP values. If vector
extensions are available, copying between left-aligned FPRs and
right-aligned GPRs is natively supported. Without vector extensions,
the alignment has to be taken care of manually. For target z10,
instructions lgdr/ldgr can be used in conjunction with shifts. Copying
via lgdr from an FPR into a GPR is the easy case since for the shift the
target GPR can be utilized. However, copying via ldgr from a GPR into a
FPR requires a secondary reload register which is used for the shift
result and is then copied into the FPR. Prior z10, there is no hardware
support in order to copy directly between FPRs and GPRs. Therefore, in
order to copy from a GPR into an FPR we would require a secondary reload
register for the shift and secondary memory for copying the aligned
value. Since this is not supported, _Float16 support starts with z10.
As a consequence, for all targets older than z10 test
libstdc++-abi/abi_check fails.
gcc/ChangeLog:
* config/s390/s390-modes.def (FLOAT_MODE): Add HF mode.
(VECTOR_MODE): Add V{1,2,4,8,16}HF modes.
* config/s390/s390.cc (s390_scalar_mode_supported_p): For 64-bit
targets z10 and newer support HF mode.
(s390_vector_mode_supported_p): Add HF mode.
(s390_register_move_cost): Keep HF mode operands in registers.
(s390_legitimate_constant_p): Support zero constant.
(s390_secondary_reload): For GPR to FPR moves a secondary reload
register is required.
(s390_secondary_memory_needed): GPR<->FPR moves don't require
secondary memory.
(s390_libgcc_floating_mode_supported_p): For 64-bit targets z10
and newer support HF mode.
(s390_hard_regno_mode_ok): Allow HF mode for FPRs and VRs.
(s390_function_arg_float): Consider HF mode, too.
(s390_excess_precision): For EXCESS_PRECISION_TYPE_FLOAT16
return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16.
(TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P): Define.
* config/s390/s390.md (movhf): Define.
(reload_half_gprtofpr_z10): Define.
(signbithf2): Define.
* config/s390/vector.md: Add new vector modes to various
iterators.
libgcc/ChangeLog:
* config.host: Include s390/t-float16.
* config/s390/libgcc-glibc.ver: Export symbols
__trunc{sf,df,tf}hf2, __extendhf{sf,df,tf}2, __fix{,uns}hfti,
__float{,un}tihf, __floatbitinthf.
* config/s390/t-softfp: Add to softfp_extras instead of setting
it.
* configure: Regenerate.
* configure.ac: Support float16 only for 64-bit targets z10 and
newer.
* config/s390/_dpd_dd_to_hf.c: New file.
* config/s390/_dpd_hf_to_dd.c: New file.
* config/s390/_dpd_hf_to_sd.c: New file.
* config/s390/_dpd_hf_to_td.c: New file.
* config/s390/_dpd_sd_to_hf.c: New file.
* config/s390/_dpd_td_to_hf.c: New file.
* config/s390/t-float16: New file.
libstdc++-v3/ChangeLog:
* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Add
names {,P,K}DF16.
gcc/testsuite/ChangeLog:
* g++.target/s390/float16-1.C: New test.
* g++.target/s390/float16-2.C: New test.
* gcc.target/s390/float16-1-2.h: New test.
* gcc.target/s390/float16-1.c: New test.
* gcc.target/s390/float16-10.c: New test.
* gcc.target/s390/float16-2.c: New test.
* gcc.target/s390/float16-3.c: New test.
* gcc.target/s390/float16-4.c: New test.
* gcc.target/s390/float16-5.c: New test.
* gcc.target/s390/float16-6.c: New test.
* gcc.target/s390/float16-7.c: New test.
* gcc.target/s390/float16-8.c: New test.
* gcc.target/s390/float16-9.c: New test.
* gcc.target/s390/float16-signbit.h: New test.
* gcc.target/s390/vector/vec-extract-4.c: New test.
* gcc.target/s390/vector/vec-float16-1.c: New test.
By using the test `with_system_libunwind', libgcc can use either
in-house implementation or reference external libunwind symbols.
However, this breaks the static libgcc.a library, as in t-linux it
references unwind-compat.c, which turns some _Unwind_* symbols into
references of the corresponding symbols in libunwind, but libunwind does
not exist in some conditions (e.g. bootstrapping a toolchain). The
linker complains about `missing version node for symbol', since it can
not find the symbol it is referring to.
The unwind-compat.c module should only exist, if system libunwind is
being used. Also GCC itself should add -lunwind only if this condition
is met, too.
Implementing better control for whether to embed unwind implementation
into libgcc to fix this issue.
gcc/
* config.gcc: limit -lunwind usage by testing if the system
libunwind is being used.
libgcc/
* config.host (ia64): include unwind-compat only if the system
libunwind is being used.
* config/ia64/t-linux-libunwind: include libgcc symver definition
for libgcc symbols, since it bears the same role as t-linux
(except libunwind); Include fde-glibc.c since the unwind
implementation requires _Unwind_FindTableEntry in this file.
* config/ia64/unwind-ia64.c: protect _Unwind_FindTableEntry inside
inihbit_libc ifndefs to allow it to build with newlib or
without proper headers.
PR target/123403
libgcc/
* config/v850/lib1funcs.S (__return_r25_r29): Fix ! __EP__ clause to
use SP, not EP.
(__return_r2_r31): Fix offsets to match store offsets.
This target was deleted in r5-3909-g3daa7bbf791203,
but a few files in libgcc were missed. Delete them.
libgcc/ChangeLog:
* config/score/crti.S: Delete.
* config/score/crtn.S: Delete.
* config/score/sfp-machine.h: Delete.
Signed-off-by: Peter Damianov <peter0x44@disroot.org>
LA32 does not support extreme code mode, change to medium code model on LA32.
libgcc/ChangeLog:
* configure: Regenerate.
* configure.ac:
* config/loongarch/t-crtstuff-la32: New file.
* config/loongarch/t-crtstuff: Rename to t-crtstuff-la64.
Reviewed-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Lulu Cheng <chenglulu@loongson.cn>
Following Andrew Pinski's suggestions in
https://gcc.gnu.org/pipermail/gcc-patches/2025-July/689683.html, just
use the output of:
$(CC) -print-sysroot
It is just used in one spot, in an AIX code-path. I just made (within
make) a shell variable to use instead.
I don't have AIX on-hand to test this, however.
gcc/ChangeLog:
* Makefile.in: No longer include TARGET_SYSTEM_ROOT in
libgcc.mvars.
libgcc/ChangeLog:
* config/rs6000/t-slibgcc-aix: Instead of using a
TARGET_SYSTEM_ROOT make variable, just define a shell variable
as part of the rule and use that.
Suggested-by: Andrew Pinski <quic_apinski@quicinc.com>
Signed-off-by: John Ericson <git@JohnEricson.me>
My goal is to be able to build libgcc cleanly in isolation --- today one
needs to figure `make ...` misc things in the gcc subdir.
Following Andrew Pinski's suggestions in
https://gcc.gnu.org/pipermail/gcc-patches/2025-July/689683.html, this
commit moves the NO_PIE_CFLAGS logic.
gcc/ChangeLog:
* Makefile.in:: Remove NO_PIE_CFLAGS logic, since it is now in
libgcc.
* configure: Regenerate.
* configure.ac: Remove the enable_default_pie substitution, since
libgcc now has its own logic.
libgcc/ChangeLog:
* Makefile.in: Define NO_PIE_CFLAGS make variable via autoconf
substitution.
* configure: Regenerate.
* configure.ac: New configure check to define NO_PIE_CFLAGS
using the algorithm Andrew asked for in the linked mail.
Suggested-by: Andrew Pinski <quic_apinski@quicinc.com>
Signed-off-by: John Ericson <git@JohnEricson.me>
This macro deduplicates the
$CC -v 2>&1 | sed -n 's/^Thread model: //p'
check that was occurring in various runtime libs.
Additionally, as a bit of an Easter egg, this also allows overriding
what the compiler would return by setting the
`gcc_cv_target_thread_file` cache variable first. I admit that it is in
fact this Easter egg that led me to write the patch. The use-case for it
is for making multilib builds where the library sets do not all share
the same thread model easier. See also `THREAD_MODEL_SPEC` for more
about the varying thread models use-case.
Arguably one could could try to define on `THREAD_MODEL_SPEC` on more
platforms (besides e.g. AIX) but the ramifications of this are a bit
unclear. Setting `gcc_cv_target_thread_file` directly is a "low tech"
solution that will work for now for sure. Of course, since setting a
cache variable like this a hacky trick, I will not expect this to be at
all stable/guaranteed to work, going forward.
Thanks to Arsen who on IRC discussed these things with me, including in
particular making it a cache var not `--with-model` flag, to not
prematurely foster expectations that this is stable.
Suggested-by: Arsen Arsenović <arsen@aarsen.me>
config/ChangeLog:
* gthr.m4: Create new GCC_AC_THREAD_MODEL macro
libatomic/ChangeLog:
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* configure.ac: Use GCC_AC_THREAD_MODEL instead of hand-rolled
* testsuite/Makefile.in: Regenerate.
libgcc/ChangeLog:
* configure: Regenerate.
* configure.ac: Use GCC_AC_THREAD_MODEL instead of hand-rolled
libphobos/ChangeLog:
* configure: Regenerate.
* m4/druntime/os.m4: Use AC_MSG_ERROR, not private as_fn_error
libstdc++-v3/ChangeLog:
* acinclude.m4: Use GCC_AC_THREAD_MODEL instead, via AC_REQUIRE
* configure: Regenerate.
The macros HWCAP_LOONGARCH_LSX and HWCAP_LOONGARCH_LASX were defined
in glibc 2.38. However, r16-5155 uses these two macros directly
without checking whether they are defined. This causes errors when
compiling libgcc with glibc versions earlier than 2.38.
gcc/ChangeLog:
* doc/extend.texi: Remove the incorrect prompt message.
libgcc/ChangeLog:
* config/loongarch/cpuinfo.c (HWCAP_LOONGARCH_LSX): Define
it if it is not defined.
(HWCAP_LOONGARCH_LASX): Likewise.
The x87 control word should be passed as an `unsigned short`. Previous
code passed `unsigned int`, and when building with `-masm=intel`,
__asm__ __volatile__ ("fnstcw\t%0" : "=m" (_cw));
could expand to `fnstcw DWORD PTR [esp+48]` and cause errors like
{standard input}: Assembler messages:
{standard input}:7137: Error: operand size mismatch for `fnstcw'
libgcc/ChangeLog:
PR target/122275
* config/i386/32/dfp-machine.h (DFP_GET_ROUNDMODE): Change `_frnd_orig` to
`unsigned short` for x87 control word.
(DFP_SET_ROUNDMODE): Manipulate the x87 control word as `unsigned short`,
and manipulate the MXCSR as `unsigned int`.
Signed-off-by: LIU Hao <lh_mouse@126.com>
This patch can obtain the CPUCFG and HWCAP value at runtime and
extract the flag bits of features for function selection.
HWCAP is used to obtain the support of LSX and LASX because the
kernel can control the enable/disable of these two features.
Note that this requires glibc version 2.38 or higher to compile
and run.
libgcc/ChangeLog:
* config/loongarch/t-loongarch64: Add cpuinfo.c to LIB2ADD.
* config/loongarch/cpuinfo.c: New file.
This matches what VXWORKS_ADDITIONAL_CPP_SPEC does, allowing libgcc to
build without VSB_DIR defined in the environment as soon as the configure
switches featured a proper --with-build-sysroot was provided.
Tested with a successful build for --target=powerpc-wrs-vxworks7r2
using mainline sources.
2025-10-23 Olivier Hainque <hainque@adacore.com>
libgcc/
* config/t-vxworks (LIBGCC2_INCLUDES): Replace $(VSB_DIR)
by sysroot references.
VxWorks provides its own version of the standard stdatomic.h, possibly
relying on non-gcc builtins, and our implementation of the gthr API resorts
to VxWorks specific functions for atomicity features.
When compiling libgcc (with gcc), make sure gcc's version of stdatomic.h
is used: #include it here, first, then define the macro used to guard the
system version so it doesn't get expanded when included indirectly by
other system headers.
2025-10-20 Olivier Hainque <hainque@adacore.com>
Ashley Gay <gay@adacore.com>
libgcc/
* config/gthr-vxworks.h: Include stdatomic.h and prevent indirect
inclusion of contents from the system version of that header.
This addresses a variety of warnings about missing prototypes
or suspicious ptr-to-function conversions.
libgcc/
* config/gthr-vxworks-thread.c (__init_gthread_tcb): Make static.
(__delete_gthread_tcb): Likewise.
(__task_wrapper): Likewise.
(__gthread_create): Convert __task_wrapper to (void *) before going
to (FUNCPTR).
* config/gthr-vxworks-tls.c (tls_delete_hook): Accommodate prototype
variations between kernel and rtp. Return STATUS.
This change moves, for VxWorks 7, the setting of the TOOL
and TOOL_FAMILY macros from a builtin_define to a run-time
computation from vxworks-predefs.h.
This is useful on Vx7 to allow a single toolchain to be used
for instances of VxWorks based on either a gnu or an llvm system
toolchain for a given cpu (typically, powerpc).
This is achieved by leveraging the existence of a very basic
autoconf.h file in all VxWorks 7 VSBs, #included directly from
vxworks-predef.h.
gcc/
* config/vxworks.h (VXWORKS_OS_CPP_BUILTINS): Only
builtin_define TOOL and TOOL_FAMILY for !TARGET_VXWORKS7.
Augment comment on VXWORKS_PERSONALITY.
* config/vxworks/vxworks-predef.h: Infer TOOL and TOOL_FAMILY
from the VSB autoconf.h when we have one, determined by the presence
of a _VSB_CONFIG_FILE definition.
libgcc/
* config/t-vxworks: -include vxworks-predef.h explicitly, as the
automatic inclusion is disabled by -nostdinc.
Since _Decimal128 arithmetic requires the round-to-nearest rounding
mode, define DFP_INIT_ROUNDMODE and DFP_RESTORE_ROUNDMODE, similar to
FP_INIT_ROUNDMODE in sfp-machine.h, to set the rounding mode to
round-to-nearest at _Decimal128 related arithmetic function entrances
and restores it upon return. This doesn't require linking with libm
when libgcc is used.
libgcc/
PR target/120691
* Makefile.in (DECNUMINC): Add -I$(srcdir)/config/$(cpu_type).
* config/i386/dfp-machine.h: New file.
* config/i386/32/dfp-machine.h: Likewise.
* config/i386/64/dfp-machine.h: Likewise.
libgcc/config/libbid/
PR target/120691
* bid128_div.c: Run DFP_INIT_ROUNDMODE at function entrace and
DFP_RESTORE_ROUNDMODE at function exit.
* bid128_rem.c: Likewise.
* bid128_sqrt.c: Likewise.
* bid64_div.c (bid64_div): Likewise.
* bid64_sqrt.c (bid64_sqrt): Likewise.
* bid_conf.h: Include <dfp-machine.h>.
* dfp-machine.h: New file.
gcc/testsuite/
PR target/120691
* gcc.target/i386/pr120691.c: New test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
fmin and fmax should return the non-NaN argument in the case where
exactly one argument is a NaN.
Moreover, IEEE double fmin and fmax can be performed without
first converting the args to the internal representation and
then converting back again.
PR target/122177
libgcc/config/avr/libf7/
* libf7-common.mk (m_ddd): Remove: fmin, fmax.
(F7_ASM_PARTS): Add: D_fminfmax.
* libf7-asm.sx (D_fmanfmax): New module.
* f7-wraps.h: Rebuild.
gcc/testsuite/
* gcc.target/avr/fminfmax-1.c: New test.
This patch circumvents the softfp_wrap for bitint functions in libgcc as certain
ports, like arm, can use softfp_wrap to distinquigh between targets they want to
use specialized assembly functions for and targets that they use the soft-fp
C implementations for. This is an orthogonal choice to the use of the soft-fp
C implementations for bitint conversions.
This patch also adds extra options to build bitint soft-fp functions, this is
needed by the arm port to build HF bitint conversion functions.
libgcc/ChangeLog:
* config/t-softfp: Don't use softfp_wrap for bitint functions.
(softfp_cflags): New parameter that is passed to the building of bitint
functions.
Fix typo in the asm in atomic_store_8. Also correct floating
point store.
Reported by Nick Hudson for netbsd.
2025-09-25 John David Anglin <danglin@gcc.gnu.org>
libgcc/ChangeLog:
* config/pa/sync-libfuncs.c (atomic_store_8): Fix asm.
Previously the spec
https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/70
has changed the save/restore routines to save/restore the registers which
are really used for ILP32E/LP64 rather than always save/restore all
of ra/s0/s1.
I also found here that lacks the implementation for lp64e. If it's
necessary I will file anothor patch for that.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_compute_frame_info): Remove the
dedicated calculation for RVE.
libgcc/ChangeLog:
* config/riscv/save-restore.S: Only save/restore the registers
which are really used for ILP32E/LP64.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/save-restore-cfi-3.c: New test.