Unlike for other targets, LDFLAGS_FOR_TARGET is not honored on Windows when
the shared libgcc is built.
libgcc/
* config/i386/t-slibgcc-cygming (SHLIB_LINK): Add $(LDFLAGS).
This patch adds support for FP_HANDLE_EXCEPTIONS when using hard float abi.
This is used by _BitInt software emulation for floating point conversions to
throw an exception.
This patch also adds support for FP_ROUNDMODE with hard float abi, which is
also used by _BitInt floating point emulation.
libgcc/ChangeLog:
* config/arm/sfp-exceptions.c: New file.
* config/arm/sfp-machine.h: Define FP_HANDLE_EXCEPTIONS, FP_EX_*
MACROs, _FP_DECL_EX, FP_ROUNDMODE, FP_INIT_ROUNDMODE, FP_RND_* MACROs
and declare __sfp_handle_exceptions.
* config/arm/t-softfp: Add sfp-exceptions.c to LIB2ADD.
Don't assume that malloc always returns a non-null pointer.
xmalloc is sometimes an alias for malloc due to this in libgcc/libgcov.h:
/* work around the poisoned malloc/calloc in system.h. */
#ifndef xmalloc
#define xmalloc malloc
#endif
libgcc/ChangeLog:
* libgcov-driver-system.c (gcov_exit_open_gcda_file): Handle
potential NULL value from malloc.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
The Windows ABI doesn't support _Float128:
https://learn.microsoft.com/en-us/cpp/build/ieee-floating-point-representation.
While it can be emulated for this target, the current implementation
prevents fortran from being built with this emulation.
This patch disables _Float128 emulation for aarch64-w64-mingw32 target.
This enables fortran to be built with no additional changes.
gcc/ChangeLog:
* config/aarch64/aarch64.cc
(aarch64_scalar_mode_supported_p): Only return true on TFmode if
TARGET_LONG_DOUBLE_128 is set.
libgcc/ChangeLog:
* config.host: Disable soft floating point.
Co-Authored-By: Evgeny Karpov <evgeny.karpov@arm.com>
In RTP mode, defining TLS_DELETE_HOOK_ARG as NULL AKA 0 elicits a
warning, that casting it to TASK_ID avoids.
objLibP.h defines an inline function that, depending on the
configuration, will have unused parameters. Allow warnings about
them.
vxTas calls are supposed to take __vx_tas_t, but upon passing it that
on aarch64, we get warnings about discarding volatile qualifiers, that
not even explicit type casts avoid. So, allow the warnings.
for libgcc/ChangeLog
* config/gthr-vxworks-tls.c (TLS_DELETE_HOOK_ARG): Type-cast
NULL constant to avoid warning.
* config/t-vxworks (LIBGCC2_CFLAGS): Tolerate unused-parameter
and discarded-qualifiers errors.
xtreme-header-8.C fails on VxWorks because various TU-local gthr
functions defined as static inline are referenced from libstdc++
symbols with global visibility.
C++ modules require those functions to be non-static inline, and other
gthr implementations adopt always_inline in C++.
Follow this practice in gthr-vxworks.h as well.
for libgcc/ChangeLog
* config/gthr-vxworks.h (__GTHREAD_ALWAYS_INLINE,
__GTHREAD_INLINE): Copy from gthr-posix.h. Replace static
inline with __GTHREAD_INLINE.
This patch adds support for C23's _BitInt feature to the arm port.
gcc/ChangeLog:
* config/arm/arm.cc (TARGET_C_BITINT_TYPE_INFO): New Macro.
(arm_return_in_memory): Return true for any _BitInt(N) where N > 64.
(arm_needs_doubleword_align): Return true for any _BitInt(N) where N > 32.
(arm_bitint_type_info): New.
* config/arm/arm-protos.h (arm_bitint_type_info): New declaration.
libgcc/ChangeLog:
* config/arm/libgcc-bpabi.ver: Add new symbols.
* config/arm/t-softfp: Enable use of floatbitinthf and pass necessary options to build fp16.
Fixes regression in C++ support without exception handling by:
1. Moving Makefile fragment config/i386/t-seh-eh to
config/mingw/t-seh-eh that handles C++ exception handling. This is
sufficient to fix the regression even if the exception handling
itself is not implemented yet.
2. Changing existing references of t-seh-eh in libgcc/config.host and
add it for aarch64-*-mingw*.
With these changes, the compiler can now be built with C and C++.
This doesn't add support for Structured Exception Handling (SEH)
which will be done separately.
libgcc/ChangeLog:
* config.host: Set tmake_eh_file for aarch64-*-mingw* and update
it for x86_64-*-mingw* and x86_64-*-cygwin*.
* config/i386/t-seh-eh: Move to...
* config/mingw/t-seh-eh: ...here.
* config/aarch64/t-no-eh: Removed.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/mingw/mingw.exp: Add support for C++ files.
* gcc.target/aarch64/mingw/minimal_new_del.C: New test.
Co-Authored-By: Evgeny Karpov <evgeny.karpov@arm.com>
Make __aarch64_cpu_features unconditionally available. This permits the
unconditional use of this global inside __arm_get_current_vg, which was
introduced in r16-7637-g41b4a73f370116.
For now this global is only initialised when <sys/auxv.h> is available,
but we can extend this in future to support other ways of initialising
the bits used for SME support, and use this remove __aarch64_have_sme.
This approach was recently adopted by LLVM.
This patch does introduce an inconsistency with __aarch64_have_sme when
<sys/auxv.h> is unavailable. However, this doesn't introduce any
regressions, because one of the following conditions will hold:
1. SVE is enabled at compile time whenever we use a streaming or
streaming compatible function. In this case the compiler won't need to
use __arm_get_current_vg, so it doesn't matter if it gives the wrong
answer.
2. There is a use of a streaming or streaming compatible function when
we don't know whether SVE is enabled. In order to get correct DWARF
unwind information, we then have to be able to test for SVE availability
at runtime. This isn't possible until a working __arm_get_current_vg
implementation is available, so the configuration has never (yet) been
supported.
libgcc/ChangeLog:
PR target/124333
* config/aarch64/cpuinfo.c: Define __aarch64_cpu_features
unconditionally.
AAPCS64* specifies several runtime support routines that must be
supported by any platform that supports SME. Add __arm_get_current_vg
to libgcc to help meet this requirement. This will be used to enable
support for SME without (non-streaming) SVE.
*https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst
libgcc/ChangeLog:
* config/aarch64/libgcc-sme.ver: Add __arm_get_current_vg.
* config/aarch64/t-aarch64: Add new source file.
* config/aarch64/__arm_get_current_vg.S: New file.
The use of UOItype with mode(OI) for 16-byte atomic operations is
non-standard. The OI mode is not defined in machmode.def and exists
only as an ad-hoc construct in libgcc/sync.c.
This patch replaces it with UTItype using mode(TI), which is the
standard GCC machine mode for 16-byte integers (Tetra Integer).
The size argument is also corrected from 8 to 16 to match the actual
operand width.
libgcc/ChangeLog:
* sync.c: Replace UOItype with UTItype and use mode(TI) pass 16, not
8, to DEFINE macro.
Signed-off-by: Xin Wang <wangxinw@hygon.cn>
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.