Commit Graph

1947 Commits

Author SHA1 Message Date
GCC Administrator
7d736ecbc0 Daily bump. 2024-10-05 00:18:14 +00:00
Tsung Chun Lin
78d2af1fa5 [PATCH] RISC-V/libgcc: Fix incorrect .cfi_offset for saving ra in __riscv_save_[0-3] on ilp32e.
From 8b3c5ebe8aacbcc4ddf1be8dea9a555e7e1bcc39 Mon Sep 17 00:00:00 2001
From: Jim Lin <jim@andestech.com>
Date: Fri, 4 Oct 2024 14:48:12 +0800
Subject: [PATCH] RISC-V/libgcc: Fix incorrect .cfi_offset for saving ra in
 __riscv_save_[0-3] on ilp32e.

libgcc/ChangeLog:

	* config/riscv/save-restore.S: Fix .cfi_offset for saving ra in
	__riscv_save_[0-3] on ilp32e.
2024-10-04 08:02:48 -06:00
GCC Administrator
60f1feded2 Daily bump. 2024-10-02 00:17:48 +00:00
Tsung Chun Lin
97fd777248 [PATCH] RISC-V/libgcc: Fix incorrect and missing .cfi_offset for __riscv_save_[0-3] on RV32.
0001-RISC-V-libgcc-Fix-incorrect-and-missing-.cfi_offset-.patch

From 06a370a0a2329dd4da0ffcab7c35ea7df2353baf Mon Sep 17 00:00:00 2001
From: Jim Lin <jim@andestech.com>
Date: Tue, 1 Oct 2024 14:42:56 +0800
Subject: [PATCH] RISC-V/libgcc: Fix incorrect and missing .cfi_offset for
 __riscv_save_[0-3] on RV32.

libgcc/ChangeLog:

	* config/riscv/save-restore.S: Fix .cfi_offset for
	__riscv_save_[0-3] on RV32.
2024-10-01 09:10:29 -06:00
GCC Administrator
9261339092 Daily bump. 2024-09-28 00:19:05 +00:00
Matthieu Longo
0ff49a5c1d aarch64: fix build failure on aarch64-none-elf
A previous patch ([1]) introduced a build regression on aarch64-none-elf
target. The changes were primarilly tested on aarch64-unknown-linux-gnu,
so the issue was missed during development.
The includes are slighly different between the two targets, and due to some
include rules ([2]), "aarch64-unwind-def.h" was not found.

[1]: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=bdf41d627c13bc5f0dc676991f4513daa9d9ae36

[2]: https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
> include "file"
> ...  It searches for a file named file first in the directory
> containing the current file, ...

libgcc/ChangeLog:

	* config/aarch64/aarch64-unwind.h: Fix header path.
2024-09-27 15:35:10 +01:00
Mark Mentovai
dd5b823ce2 libgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14 [PR116809]
d9cafa0c4f stopped building libgcc_s.1 on macOS >= 15, in part because
that is required to bootstrap the compiler using the macOS 15 SDK. The
macOS 15 SDK ships in Xcode 16, which also runs on macOS 14. libgcc_s.1
can no longer be built on macOS 14 using Xcode 16 by the same logic that
the previous change disabled it for macOS 15.

	PR target/116809

libgcc/ChangeLog:

	* config.host: Don't build legacy libgcc_s.1 on macOS 14.

Signed-off-by: Mark Mentovai <mark@mentovai.com>
2024-09-27 13:17:44 +01:00
Jim Lin
bb01c9d6d2 RISC-V/libgcc: Save/Restore routines for E goes with ABI.
That Save/Restore routines for E can be used for RVI with ILP32E ABI.

libgcc/ChangeLog:

	* config/riscv/save-restore.S: Check with __riscv_abi_rve rather than
	__riscv_32e.
2024-09-27 17:29:06 +08:00
GCC Administrator
ff20f2b599 Daily bump. 2024-09-27 00:18:47 +00:00
Nathaniel Shead
6a4d1c374e libgcc, libstdc++: Make declarations no longer TU-local [PR115126]
In C++20, modules streaming check for exposures of TU-local entities.
In general exposing internal linkage functions in a header is liable to
cause ODR violations in C++, and this is now detected in a module
context.

This patch goes through and removes 'static' from many declarations
exposed through libstdc++ to prevent code like the following from
failing:

  export module M;
  extern "C++" {
    #include <bits/stdc++.h>
  }

Since gthreads is used from C as well, we need to choose whether to use
'inline' or 'static inline' depending on whether we're compiling for C
or C++ (since the semantics of 'inline' are different between the
languages).  Additionally we need to remove static global variables, so
we migrate these to function-local statics to avoid the ODR issues.

There doesn't seem to be a good workaround for weakrefs, so I've left
them as-is and will work around it in the modules streaming code to
consider them as not TU-local.

The same issue occurs in the objective-C specific parts of gthreads, but
I'm not familiar with the surrounding context and we don't currently
test modules with Objective C++ anyway so I've left it as-is.

	PR libstdc++/115126

libgcc/ChangeLog:

	* gthr-posix.h (__GTHREAD_ALWAYS_INLINE): New macro.
	(__GTHREAD_INLINE): New macro.
	(__gthread_active): Convert from variable to (hidden) function.
	(__gthread_active_p): Mark as __GTHREAD_INLINE instead of
	static; make visibility("hidden") when it has a static local
	variable.
	(__gthread_trigger): Mark as __GTHREAD_INLINE instead of static.
	(__gthread_create): Likewise.
	(__gthread_join): Likewise.
	(__gthread_detach): Likewise.
	(__gthread_equal): Likewise.
	(__gthread_self): Likewise.
	(__gthread_yield): Likewise.
	(__gthread_once): Likewise.
	(__gthread_key_create): Likewise.
	(__gthread_key_delete): Likewise.
	(__gthread_getspecific): Likewise.
	(__gthread_setspecific): Likewise.
	(__gthread_mutex_init_function): Likewise.
	(__gthread_mutex_destroy): Likewise.
	(__gthread_mutex_lock): Likewise.
	(__gthread_mutex_trylock): Likewise.
	(__gthread_mutex_timedlock): Likewise.
	(__gthread_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_init_function): Likewise.
	(__gthread_recursive_mutex_lock): Likewise.
	(__gthread_recursive_mutex_trylock): Likewise.
	(__gthread_recursive_mutex_timedlock): Likewise.
	(__gthread_recursive_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_destroy): Likewise.
	(__gthread_cond_init_function): Likewise.
	(__gthread_cond_broadcast): Likewise.
	(__gthread_cond_signal): Likewise.
	(__gthread_cond_wait): Likewise.
	(__gthread_cond_timedwait): Likewise.
	(__gthread_cond_wait_recursive): Likewise.
	(__gthread_cond_destroy): Likewise.
	(__gthread_rwlock_rdlock): Likewise.
	(__gthread_rwlock_tryrdlock): Likewise.
	(__gthread_rwlock_wrlock): Likewise.
	(__gthread_rwlock_trywrlock): Likewise.
	(__gthread_rwlock_unlock): Likewise.
	* gthr-single.h: (__GTHREAD_ALWAYS_INLINE): New macro.
	(__GTHREAD_INLINE): New macro.
	(__gthread_active_p): Mark as __GTHREAD_INLINE instead of static.
	(__gthread_once): Likewise.
	(__gthread_key_create): Likewise.
	(__gthread_key_delete): Likewise.
	(__gthread_getspecific): Likewise.
	(__gthread_setspecific): Likewise.
	(__gthread_mutex_destroy): Likewise.
	(__gthread_mutex_lock): Likewise.
	(__gthread_mutex_trylock): Likewise.
	(__gthread_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_lock): Likewise.
	(__gthread_recursive_mutex_trylock): Likewise.
	(__gthread_recursive_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_destroy): Likewise.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr.h (std::__is_shared_ptr): Remove
	unnecessary 'static'.
	* include/bits/unique_ptr.h (std::__is_unique_ptr): Likewise.
	* include/std/future (std::__create_task_state): Likewise.
	* include/std/shared_mutex (_GLIBCXX_GTRHW): Likewise.
	(__glibcxx_rwlock_init): Likewise.
	(__glibcxx_rwlock_timedrdlock): Likewise.
	(__glibcxx_rwlock_timedwrlock): Likewise.
	(__glibcxx_rwlock_rdlock): Likewise.
	(__glibcxx_rwlock_tryrdlock): Likewise.
	(__glibcxx_rwlock_wrlock): Likewise.
	(__glibcxx_rwlock_trywrlock): Likewise.
	(__glibcxx_rwlock_unlock): Likewise.
	(__glibcxx_rwlock_destroy): Likewise.
	(__glibcxx_rwlock_init): Likewise.
	* include/pstl/algorithm_impl.h
	(__pstl::__internal::__set_algo_cut_off): Mark inline.
	* include/pstl/unseq_backend_simd.h
	(__pstl::__unseq_backend::__lane_size): Mark inline.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Jakub Jelinek <jakub@redhat.com>
2024-09-27 09:16:53 +10:00
GCC Administrator
2d8392c4e7 Daily bump. 2024-09-25 00:18:47 +00:00
Iain Sandoe
d9cafa0c4f libgcc, Darwin: Drop the legacy library build for macOS >= 15 [PR116809].
We have been building a legacy libgcc_s.1 DSO to support code that
was built with older compilers.

From macOS 15,  the unwinder no longer exports some of the symbols used
in that library which (a) cuases bootstrap fail and (b) means that the
legacy library is no longer useful.

No open branch of GCC emits references to this library - and any already
-built code that depends on the symbols would need rework anyway.

	PR target/116809

libgcc/ChangeLog:

	* config.host: Build legacy libgcc_s.1 on hosts before macOS 15.
	* config/i386/t-darwin: Remove reference to legacy libgcc_s.1
	* config/rs6000/t-darwin: Likewise.
	* config/t-darwin-libgccs1: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-09-24 19:23:02 +01:00
GCC Administrator
4d6fa5b7f1 Daily bump. 2024-09-24 00:18:14 +00:00
Matthieu Longo
9e1c71bab5 dwarf2: add hooks for architecture-specific CFIs
Architecture-specific CFI directives are currently declared an processed
among others architecture-independent CFI directives in gcc/dwarf2* files.
This approach creates confusion, specifically in the case of DWARF
instructions in the vendor space and using the same instruction code.

Such a clash currently happen between DW_CFA_GNU_window_save (used on
SPARC) and DW_CFA_AARCH64_negate_ra_state (used on AArch64), and both
having the same instruction code 0x2d.
Then AArch64 compilers generates a SPARC CFI directive (.cfi_window_save)
instead of .cfi_negate_ra_state, contrarilly to what is expected in
[DWARF for the Arm 64-bit Architecture (AArch64)](https://github.com/
ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst).

This refactoring does not solve completely the problem, but improve the
situation by moving some of the processing of those directives (more
specifically their output in the assembly) to the backend via 2 target
hooks:
- DW_CFI_OPRND1_DESC: parse the first operand of the directive (if any).
- OUTPUT_CFI_DIRECTIVE: output the CFI directive as a string.

Additionally, this patch also contains a renaming of an enum used for
return address mangling on AArch64.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc
	(aarch64_output_cfi_directive): New hook for CFI directives.
	(aarch64_dw_cfi_oprnd1_desc): Same.
	(TARGET_OUTPUT_CFI_DIRECTIVE): Hook for output_cfi_directive.
	(TARGET_DW_CFI_OPRND1_DESC): Hook for dw_cfi_oprnd1_desc.
	* config/sparc/sparc.cc
	(sparc_output_cfi_directive): New hook for CFI directives.
	(sparc_dw_cfi_oprnd1_desc): Same.
	(TARGET_OUTPUT_CFI_DIRECTIVE): Hook for output_cfi_directive.
	(TARGET_DW_CFI_OPRND1_DESC): Hook for dw_cfi_oprnd1_desc.
	* coretypes.h
	(struct dw_cfi_node): Forward declaration of CFI type from
	gcc/dwarf2out.h.
	(enum dw_cfi_oprnd_type): Same.
	(enum dwarf_call_frame_info): Same.
	* doc/tm.texi: Regenerated from doc/tm.texi.in.
	* doc/tm.texi.in: Add doc for new target hooks.
	type of enum to allow forward declaration.
	* dwarf2cfi.cc
	(struct dw_cfi_row): Update the description for window_save
	and ra_mangled.
	(dwarf2out_frame_debug_cfa_negate_ra_state): Use AArch64 CFI
	directive instead of the SPARC one.
	(change_cfi_row): Use the right CFI directive's name for RA
	mangling.
	(output_cfi): Remove explicit architecture-specific CFI
	directive DW_CFA_GNU_window_save that falls into default case.
	(output_cfi_directive): Use target hook as default.
	* dwarf2out.cc (dw_cfi_oprnd1_desc): Use target hook as default.
	* dwarf2out.h (enum dw_cfi_oprnd_type): specify underlying type
	of enum to allow forward declaration.
	(dw_cfi_oprnd1_desc): Call target hook.
	(output_cfi_directive): Use dw_cfi_ref instead of struct
	dw_cfi_node *.
	* hooks.cc
	(hook_bool_dwcfi_dwcfioprndtyperef_false): New.
	(hook_bool_FILEptr_dwcfiptr_false): New.
	* hooks.h
	(hook_bool_dwcfi_dwcfioprndtyperef_false): New.
	(hook_bool_FILEptr_dwcfiptr_false): New.
	* target.def: Documentation for new hooks.

include/ChangeLog:

	* dwarf2.h (enum dwarf_call_frame_info): specify underlying

libffi/ChangeLog:

	* include/ffi_cfi.h (cfi_negate_ra_state): Declare AArch64 cfi
	directive.

libgcc/ChangeLog:

	* config/aarch64/aarch64-asm.h (PACIASP): Replace SPARC CFI
	directive by AArch64 one.
	(AUTIASP): Same.

libitm/ChangeLog:

	* config/aarch64/sjlj.S: Replace SPARC CFI directive by
	AArch64 one.

gcc/testsuite/ChangeLog:

	* g++.target/aarch64/pr94515-1.C: Replace SPARC CFI directive by
	AArch64 one.
	* g++.target/aarch64/pr94515-2.C: Same.
2024-09-23 15:37:05 +01:00
Matthieu Longo
bdf41d627c libgcc: hide CIE and FDE data for DWARF architecture extensions behind a handler.
This patch provides a new handler MD_ARCH_FRAME_STATE_T to hide an
architecture-specific structure containing CIE and FDE data related
to DWARF architecture extensions.

Hiding the architecture-specific attributes behind a handler has the
following benefits:
1. isolating those data from the generic ones in _Unwind_FrameState
2. avoiding casts to custom types.
3. preserving typing information when debugging with GDB, and so
   facilitating their printing.

This approach required to add a new header md-unwind-def.h included at
the top of libgcc/unwind-dw2.h, and redirecting to the corresponding
architecture header via a symbolic link.

An obvious drawback is the increase in complexity with macros, and
headers. It also caused a split of architecture definitions between
md-unwind-def.h (types definitions used in unwind-dw2.h) and
md-unwind.h (local types definitions and handlers implementations).
The naming of md-unwind.h with .h extension is a bit misleading as
the file is only included in the middle of unwind-dw2.c. Changing
this naming would require modification of others backends, which I
prefered to abstain from. Overall the benefits are worth the added
complexity from my perspective.

libgcc/ChangeLog:

	* Makefile.in: New target for symbolic link to md-unwind-def.h
	* config.host: New parameter md_unwind_def_header. Set it to
	aarch64/aarch64-unwind-def.h for AArch64 targets, or no-unwind.h
	by default.
	* config/aarch64/aarch64-unwind.h
	(aarch64_pointer_auth_key): Move to aarch64-unwind-def.h
	(aarch64_cie_aug_handler): Update.
	(aarch64_arch_extension_frame_init): Update.
	(aarch64_demangle_return_addr): Update.
	* configure.ac: New substitute variable md_unwind_def_header.
	* unwind-dw2.h (defined): MD_ARCH_FRAME_STATE_T.
	* config/aarch64/aarch64-unwind-def.h: New file.
	* configure: Regenerate.
	* config/no-unwind.h: Updated comment
2024-09-23 15:24:21 +01:00
Matthieu Longo
ba3e597681 aarch64: skip copy of RA state register into target context
The RA state register is local to a frame, so it should not be copied to
the target frame during the context installation.

This patch adds a new backend handler that check whether a register
needs to be skipped or not before its installation.

libgcc/ChangeLog:

	* config/aarch64/aarch64-unwind.h
	(MD_FRAME_LOCAL_REGISTER_P): new handler checking whether a register
	from the current context needs to be skipped before installation into
	the target context.
	(aarch64_frame_local_register): Likewise.
	* unwind-dw2.c (uw_install_context_1): use MD_FRAME_LOCAL_REGISTER_P.
2024-09-23 15:12:07 +01:00
Matthieu Longo
f531673917 aarch64: store signing key and signing method in DWARF _Unwind_FrameState
This patch is only a refactoring of the existing implementation
of PAuth and returned-address signing. The existing behavior is
preserved.

_Unwind_FrameState already contains several CIE and FDE information
(see the attributes below the comment "The information we care
about from the CIE/FDE" in libgcc/unwind-dw2.h).
The patch aims at moving the information from DWARF CIE (signing
key stored in the augmentation string) and FDE (the used signing
method) into _Unwind_FrameState along the already-stored CIE and
FDE information.
Note: those information have to be saved in frame_state_reg_info
instead of _Unwind_FrameState as they need to be savable by
DW_CFA_remember_state and restorable by DW_CFA_restore_state, that
both rely on the attribute "prev".

Those new information in _Unwind_FrameState simplifies the look-up
of the signing key when the return address is demangled. It also
allows future signing methods to be easily added.

_Unwind_FrameState is not a part of the public API of libunwind,
so the change is backward compatible.

A new architecture-specific handler MD_ARCH_EXTENSION_FRAME_INIT
allows to reset values (if needed) in the frame state and unwind
context before changing the frame state to the caller context.

A new architecture-specific handler MD_ARCH_EXTENSION_CIE_AUG_HANDLER
isolates the architecture-specific augmentation strings in AArch64
backend, and allows others architectures to reuse augmentation
strings that would have clashed with AArch64 DWARF extensions.

aarch64_demangle_return_addr, DW_CFA_AARCH64_negate_ra_state and
DW_CFA_val_expression cases in libgcc/unwind-dw2-execute_cfa.h
were documented to clarify where the value of the RA state register
is stored (FS and CONTEXT respectively).

libgcc/ChangeLog:

	* config/aarch64/aarch64-unwind.h
	(AARCH64_DWARF_RA_STATE_MASK): The mask for RA state register.
	(aarch64_ra_signing_method_t): The diversifiers used to sign a
	function's return address.
	(aarch64_pointer_auth_key): The key used to sign a function's
	return address.
	(aarch64_cie_signed_with_b_key): Deleted as the signing key is
	available now in _Unwind_FrameState.
	(MD_ARCH_EXTENSION_CIE_AUG_HANDLER): New CIE augmentation string
	handler for architecture extensions.
	(MD_ARCH_EXTENSION_FRAME_INIT): New architecture-extension
	initialization routine for DWARF frame state and context before
	execution of DWARF instructions.
	(aarch64_context_ra_state_get): Read RA state register from CONTEXT.
	(aarch64_ra_state_get): Read RA state register from FS.
	(aarch64_ra_state_set): Write RA state register into FS.
	(aarch64_ra_state_toggle): Toggle RA state register in FS.
	(aarch64_cie_aug_handler): Handler AArch64 augmentation strings.
	(aarch64_arch_extension_frame_init): Initialize defaults for the
	signing key (PAUTH_KEY_A), and RA state register (RA_no_signing).
	(aarch64_demangle_return_addr): Rely on the frame registers and
	the signing_key attribute in _Unwind_FrameState.
	* unwind-dw2-execute_cfa.h:
	Use the right alias DW_CFA_AARCH64_negate_ra_state for __aarch64__
	instead of DW_CFA_GNU_window_save.
	(DW_CFA_AARCH64_negate_ra_state): Save the signing method in RA
	state register. Toggle RA state register without resetting 'how'
	to REG_UNSAVED.
	* unwind-dw2.c:
	(extract_cie_info): Save the signing key in the current
	_Unwind_FrameState while parsing the augmentation data.
	(uw_frame_state_for): Reset some attributes related to architecture
	extensions in _Unwind_FrameState.
	(uw_update_context): Move authentication code to AArch64 unwinding.
	* unwind-dw2.h (enum register_rule): Give a name to the existing
	enum for the register rules, and replace 'unsigned char' by 'enum
	register_rule' to facilitate debugging in GDB.
	(_Unwind_FrameState): Add a new architecture-extension attribute
	to store the signing key.
2024-09-23 15:05:59 +01:00
GCC Administrator
ca12354fe2 Daily bump. 2024-09-23 00:18:00 +00:00
Iain Sandoe
43eab54939 libgcc, Darwin: From macOS 11, make that the earliest supported.
For libgcc, we have (so far) supported building a DSO that supports
earlier versions of the OS than the target.  From macOS 11, there are
APIs that do not exist on earlier OS versions, so limit the libgcc
range to macOS11..current.

libgcc/ChangeLog:

	* config.host: From macOS 11, limit earliest macOS support
	to macOS 11.
	* config/t-darwin-min-11: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-09-22 19:43:08 +01:00
GCC Administrator
ef84d2fea6 Daily bump. 2024-08-28 00:19:45 +00:00
YunQiang Su
9522fc8bb7 MIPS: Include missing mips16.S in libgcc/lib1funcs.S
mips16.S was missing since
commit 29b7454553
Date:   Thu Jun 1 10:14:24 2023 +0800

    MIPS: Add speculation_barrier support

Without mips16.S included, some symbols will miss for mips16, and
so some software will fail to build.

libgcc/ChangeLog:

	* config/mips/lib1funcs.S: Includes mips16.S.
2024-08-27 08:21:03 +08:00
GCC Administrator
471fb09260 Daily bump. 2024-06-15 00:16:29 +00:00
Georg-Johann Lay
2830b0b865 AVR: target/115419 - Tie breaks are rounded-to-even.
libgcc/config/avr/libf7/
	PR target/115419
	* libf7.c (f7_get_double): Round tie breaks to even LSB.
2024-06-14 18:33:05 +02:00
GCC Administrator
097bc0aeba Daily bump. 2024-06-11 00:18:01 +00:00
Jan Beulich
48d6d8c9e9 libgcc/aarch64: also provide AT_HWCAP2 fallback
Much like AT_HWCAP is already provided in case the platform headers
don't have the value (yet).

libgcc/

	* config/aarch64/cpuinfo.c: Provide AT_HWCAP2.
2024-06-10 08:47:58 +02:00
GCC Administrator
6af18e8c95 Daily bump. 2024-06-07 00:16:38 +00:00
Andre Vieira
c559353af4 arm: Add .type and .size to __gnu_cmse_nonsecure_call [PR115360]
This patch adds missing assembly directives to the CMSE library wrapper to call
functions with attribute cmse_nonsecure_call.  Without the .type directive the
linker will fail to produce the correct veneer if a call to this wrapper
function is to far from the wrapper itself.  The .size was added for
completeness, though we don't necessarily have a usecase for it.

libgcc/ChangeLog:

	PR target/115360
	* config/arm/cmse_nonsecure_call.S: Add .type and .size directives.
2024-06-06 16:02:50 +01:00
Thomas Schwinge
a29c5852a6 nvptx, libgcc: Stub unwinding implementation
Adding stub '_Unwind_Backtrace', '_Unwind_GetIPInfo' functions is necessary
for linking libbacktrace, as a normal (non-'LIBGFOR_MINIMAL') configuration
of libgfortran wants to do, for example.

The file 'libgcc/config/nvptx/unwind-nvptx.c' is copied from
'libgcc/config/gcn/unwind-gcn.c'.

libgcc/ChangeLog:

	* config/nvptx/t-nvptx: Add unwind-nvptx.c.
	* config/nvptx/unwind-nvptx.c: New file.

Co-authored-by: Andrew Stubbs <ams@gcc.gnu.org>
2024-06-06 13:41:47 +02:00
Thomas Schwinge
5bbe5350a0 nvptx offloading: Global constructor, destructor support, via nvptx-tools 'ld'
This extends commit d9c90c82d9
"nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'"
for offloading.

	libgcc/
	* config/nvptx/gbl-ctors.c ["mgomp"]
	(__do_global_ctors__entry__mgomp)
	(__do_global_dtors__entry__mgomp): New.
	[!"mgomp"] (__do_global_ctors__entry, __do_global_dtors__entry):
	New.
	libgomp/
	* plugin/plugin-nvptx.c (nvptx_do_global_cdtors): New.
	(nvptx_close_device, GOMP_OFFLOAD_load_image)
	(GOMP_OFFLOAD_unload_image): Call it.
2024-06-06 13:41:47 +02:00
GCC Administrator
10cb3336ba Daily bump. 2024-06-06 00:16:43 +00:00
Wilco Dijkstra
d7cbcfe7c3 AArch64: Fix cpu features initialization [PR115342]
The CPU features initialization code uses CPUID registers (rather than
HWCAP).  The equality comparisons it uses are incorrect: for example FEAT_SVE
is not set if SVE2 is available.  Using HWCAPs for these is both simpler and
correct.  The initialization must also be done atomically to avoid multiple
threads causing corruption due to non-atomic RMW accesses to the global.

libgcc:
	PR target/115342
	* config/aarch64/cpuinfo.c (__init_cpu_features_constructor):
	Use HWCAP where possible.  Use atomic write for initialization.
	Fix FEAT_PREDRES comparison.
	(__init_cpu_features_resolver): Use atomic load for correct
	initialization.
	(__init_cpu_features): Likewise.
2024-06-05 14:10:50 +01:00
GCC Administrator
3c7301f947 Daily bump. 2024-06-02 00:17:09 +00:00
Georg-Johann Lay
f12454278d AVR: target/115317 - Make isinf(-Inf) return -1.
PR target/115317
libgcc/config/avr/libf7/
	* libf7-asm.sx (__isinf): Map -Inf to -1.

gcc/testsuite/
	* gcc.target/avr/torture/pr115317-isinf.c: New test.
2024-06-01 12:49:45 +02:00
GCC Administrator
3c75a4c03d Daily bump. 2024-06-01 00:17:20 +00:00
Thomas Schwinge
d9c90c82d9 nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'
The function attributes 'constructor', 'destructor', and 'init_priority' now
work, as do the C++ features making use of this.  Test cases with effective
target 'global_constructor' and 'init_priority' now generally work, and
'check-gcc-c++' test results greatly improve; no more
"sorry, unimplemented: global constructors not supported on this target".

For proper execution test results, this depends on
<96f8fc59a7>
"ld: Global constructor/destructor support".

	gcc/
	* config/nvptx/nvptx.h: Configure global constructor, destructor
	support.
	gcc/testsuite/
	* gcc.dg/no_profile_instrument_function-attr-1.c: GCC/nvptx is
	'NO_DOT_IN_LABEL' but not 'NO_DOLLAR_IN_LABEL', so '$' may apper
	in identifiers.
	* lib/target-supports.exp
	(check_effective_target_global_constructor): Enable for nvptx.
	libgcc/
	* config/nvptx/crt0.c (__gbl_ctors): New weak function.
	(__main): Invoke it.
	* config/nvptx/gbl-ctors.c: New.
	* config/nvptx/t-nvptx: Configure global constructor, destructor
	support.
2024-05-31 15:02:01 +02:00
GCC Administrator
bad96a02c4 Daily bump. 2024-05-22 00:17:38 +00:00
Kewen Lin
5d1d2e955d libgcc, rs6000: Remove powerpcspe related code
Since r9-4728 the powerpcspe support had been removed, this
follow-up patch is to remove the remaining pieces in libgcc.

libgcc/ChangeLog:

	* config.host: Remove powerpc-*-eabispe* support.
	* config/rs6000/linux-unwind.h (ppc_fallback_frame_state): Remove
	__SPE__ code.
	* config/rs6000/t-savresfgpr (LIB2ADD_ST): Remove e500crtres32gpr.S,
	e500crtres32gpr.S, e500crtsav64gpr.S, e500crtsav64gprctr.S,
	e500crtres64gpr.S, e500crtsav32gpr.S, e500crtsavg32gpr.S,
	e500crtres64gprctr.S, e500crtsavg64gprctr.S, e500crtresx32gpr.S,
	e500crtrest32gpr.S, e500crtrest64gpr.S and e500crtresx64gpr.S.
	* config/rs6000/e500crtres32gpr.S: Remove.
	* config/rs6000/e500crtres64gpr.S: Remove.
	* config/rs6000/e500crtres64gprctr.S: Remove.
	* config/rs6000/e500crtrest32gpr.S: Remove.
	* config/rs6000/e500crtrest64gpr.S: Remove.
	* config/rs6000/e500crtresx32gpr.S: Remove.
	* config/rs6000/e500crtresx64gpr.S: Remove.
	* config/rs6000/e500crtsav32gpr.S: Remove.
	* config/rs6000/e500crtsav64gpr.S: Remove.
	* config/rs6000/e500crtsav64gprctr.S: Remove.
	* config/rs6000/e500crtsavg32gpr.S: Remove.
	* config/rs6000/e500crtsavg64gpr.S: Remove.
	* config/rs6000/e500crtsavg64gprctr.S: Remove.
2024-05-20 21:01:08 -05:00
GCC Administrator
8713d5eec2 Daily bump. 2024-05-19 18:15:28 +00:00
Wolfgang Hospital
988838da72 AVR: target/115065 - Tweak __clzhi2.
The libgcc implementation of __clzhi2 can be tweaked by
one cycle in some situations by re-arranging the instructions.
It also reduces the WCET by 1 cycle.

libgcc/
	PR target/115065
	* config/avr/lib1funcs.S (__clzhi2): Tweak.
2024-05-18 15:12:10 +02:00
GCC Administrator
f2d118932e Daily bump. 2024-05-13 08:45:27 +00:00
Georg-Johann Lay
af64af69c3 AVR: target/114981 - Tweak __builtin_powif / __powisf2
Implement __powisf2 in assembly.

	PR target/114981
libgcc/
	* config/avr/t-avr (LIB2FUNCS_EXCLUDE): Add _powisf2.
	(LIB1ASMFUNCS) [!avrtiny]: Add _powif.
	* config/avr/lib1funcs.S (mov4): New .macro.
	(L_powif, __powisf2) [!avrtiny]: New module and function.

gcc/testsuite/
	* gcc.target/avr/pr114981-powif.c: New test.
2024-05-10 11:36:25 +02:00
GCC Administrator
d508d70836 Daily bump. 2024-05-09 10:58:01 +00:00
Georg-Johann Lay
de4eea7d7e AVR: target/114981 - Support __builtin_powi[l] / __powidf2.
This supports __powidf2 by means of a double wrapper for already
existing f7_powi (renamed to __f7_powi by f7-renames.h).
It tweaks the implementation so that it does not perform trivial
multiplications with 1.0 any more, but instead uses a move.
It also fixes the last statement of f7_powi, which was wrong.
Notice that f7_powi was unused until now.

	PR target/114981
libgcc/config/avr/libf7/
	* libf7-common.mk (F7_ASM_PARTS): Add D_powi
	* libf7-asm.sx (F7MOD_D_powi_, __powidf2): New module and function.
	* libf7.c (f7_powi): Fix last (wrong) statement.
	Tweak trivial multiplications with 1.0.

gcc/testsuite/
	* gcc.target/avr/pr114981-powil.c: New test.
2024-05-08 19:04:06 +02:00
Zac Walker
d6d7afcdbc Add aarch64-w64-mingw32 target to libgcc
Reuse MinGW definitions from i386 for libgcc. Move reused files to
libgcc/config/mingw folder.

libgcc/ChangeLog:

	* config.host: Add aarch64-w64-mingw32 target. Adjust targets
	after moving MinGW files.
	* config/i386/t-gthr-win32: Move to...
	* config/mingw/t-gthr-win32: ...here.
	* config/i386/t-mingw-pthread: Move to...
	* config/mingw/t-mingw-pthread: ...here.
	* config/aarch64/t-no-eh: New file. EH is not yet implemented for
	the target, and the default definition should be disabled.
2024-05-07 16:02:35 +00:00
Wolfgang Hospital
8d2c93fcfe AVR: target/114835 - Tweak popcountqi2
libgcc/
	PR target/114835
	* config/avr/lib1funcs.S (__popcountqi2): Use code that
	is one instruction shorter / faster.
2024-05-07 16:32:07 +02:00
Rainer Orth
f68e90a0fe Remove obsolete Solaris 11.3 support
Support for Solaris 11.3 had already been obsoleted in GCC 13.  However,
since the only Solaris system in the cfarm was running 11.3, I've kept
it in tree until now when both Solaris 11.4/SPARC and x86 systems have
been added.

This patch actually removes the Solaris 11.3 support.  Apart from
several minor simplifications, there are two more widespread changes:

* In Solaris 11.4, libsocket and libnsl were folded into libc, so
  there's no longer a need to link them explictly.

* Since Solaris 11.4, Solaris includes all crts needed by gcc (like
  crt1.o and gcrt1.o) with the base system.  All workarounds to provide
  fallbacks can thus go.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 (as/ld, gas/ld, and gas/gld) as well as Solaris
11.3/x86 to ascertain that version is actually rejected.

2024-04-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	c++tools:
	* configure.ac (ax_lib_socket_nsl.m4): Don't sinclude.
	(AX_LIB_SOCKET_NSL): Don't call.
	(NETLIBS): Remove.
	* configure: Regenerate.
	* Makefile.in (NETLIBS): Remove.
	(g++-mapper-server$(exeext)): Remove $(NETLIBS).

	gcc:
	* config.gcc: Move *-*-solaris2.11.[0-3]* to unsupported list.
	<*-*-solaris2*> (default_use_cxa_atexit): Set unconditionally.
	* configure.ac (AX_LIB_SOCKET_NSL): Don't call.
	(NETLIBS): Remove.
	(gcc_cv_ld_aligned_shf_merge): Remove.
	(hidden_linkonce) <i?86-*-solaris2* | x86_64-*-solaris2*>: Remove.
	(gcc_cv_target_dl_iterate_phdr) <*-*-solaris2*>: Always set to yes.
	* Makefile.in (NETLIBS): Remove.
	* configure, config.in, aclocal.m4: Regenerate.
	* config/sol2.h: Don't check HAVE_SOLARIS_CRTS.
	(STARTFILE_SPEC): Remove !HAVE_SOLARIS_CRTS case.
	[USE_GLD] (LINK_EH_SPEC): Remove TARGET_DL_ITERATE_PHDR guard.
	* config/i386/i386.cc (USE_HIDDEN_LINKONCE): Remove guard.
	* varasm.cc (mergeable_string_section): Remove
	HAVE_LD_ALIGNED_SHF_MERGE handling.
	(mergeable_constant_section): Likewise.

	* doc/install.texi (Specific,i?86-*-solaris2*): Reference Solaris
	11.4 only.
	(Specific, *-*-solaris2*): Document Solaris 11.3 removal.  Remove
	11.3 references and caveats.  Update for 11.4.

	gcc/cp:
	* Make-lang.in (cc1plus$(exeext)): Remove $(NETLIBS).

	gcc/objcp:
	* Make-lang.in (cc1objplus$(exeext)): Remove $(NETLIBS).

	gcc/testsuite:
	* lib/target-supports.exp (check_effective_target_pie): Always
	enable on *-*-solaris2*.

	libgcc:
	* configure.ac <*-*-solaris2*> (libgcc_cv_solaris_crts): Remove.
	* config.host <*-*-solaris2*>: Remove !libgcc_cv_solaris_crts
	support.
	* configure, config.in: Regenerate.
	* config/sol2/gmon.c (internal_mcount) [!HAVE_SOLARIS_CRTS]: Remove.
	* config/i386/sol2-c1.S, config/sparc/sol2-c1.S: Remove.
	* config/sol2/t-sol2 (crt1.o, gcrt1.o): Remove.

	libstdc++-v3:
	* testsuite/lib/dg-options.exp (add_options_for_net_ts)
	<*-*-solaris2*>: Don't link with -lsocket -lnsl.
2024-05-07 10:45:55 +02:00
GCC Administrator
f56280d57f Daily bump. 2024-05-07 00:18:28 +00:00
Xiao Zeng
8c7cee80eb [RISC-V] Add support for _Bfloat16
1 At point <https://github.com/riscv/riscv-bfloat16>,
  BF16 has already been completed "post public review".

2 LLVM has also added support for RISCV BF16 in
  <https://reviews.llvm.org/D151313> and
  <https://reviews.llvm.org/D150929>.

3 According to the discussion <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/367>,
  this use __bf16 and use DF16b in riscv_mangle_type like x86.

Below test are passed for this patch
    * The riscv fully regression test.

gcc/ChangeLog:

	* config/riscv/iterators.md: New mode iterator HFBF.
	* config/riscv/riscv-builtins.cc (riscv_init_builtin_types):
	Initialize data type _Bfloat16.
	* config/riscv/riscv-modes.def (FLOAT_MODE): New.
	(ADJUST_FLOAT_FORMAT): New.
	* config/riscv/riscv.cc (riscv_mangle_type): Support for BFmode.
	(riscv_scalar_mode_supported_p): Ditto.
	(riscv_libgcc_floating_mode_supported_p): Ditto.
	(riscv_init_libfuncs): Set the conversion method for BFmode and
	HFmode.
	(riscv_block_arith_comp_libfuncs_for_mode): Set the arithmetic
	and comparison libfuncs for the mode.
	* config/riscv/riscv.md (mode" ): Add BF.
	(movhf): Support for BFmode.
	(mov<mode>): Ditto.
	(*movhf_softfloat): Ditto.
	(*mov<mode>_softfloat): Ditto.

libgcc/ChangeLog:

	* config/riscv/sfp-machine.h (_FP_NANFRAC_B): New.
	(_FP_NANSIGN_B): Ditto.
	* config/riscv/t-softfp32: Add support for BF16 libfuncs.
	* config/riscv/t-softfp64: Ditto.
	* soft-fp/floatsibf.c: For si -> bf16.
	* soft-fp/floatunsibf.c: For unsi -> bf16.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/bf16_arithmetic.c: New test.
	* gcc.target/riscv/bf16_call.c: New test.
	* gcc.target/riscv/bf16_comparison.c: New test.
	* gcc.target/riscv/bf16_float_libcall_convert.c: New test.
	* gcc.target/riscv/bf16_integer_libcall_convert.c: New test.

Co-authored-by: Jin Ma <jinma@linux.alibaba.com>
2024-05-06 15:39:12 -06:00
GCC Administrator
ce343444c0 Daily bump. 2024-05-06 00:16:49 +00:00
liuhongt
affd77d3fe Update libbid according to the latest Intel Decimal Floating-Point Math Library.
The Intel Decimal Floating-Point Math Library is available as open-source on Netlib[1].

[1] https://www.netlib.org/misc/intel/.

libgcc/config/libbid/ChangeLog:

	* bid128_fma.c (add_and_round): Fix bug: the result
	of (+5E+368)*(+10E-34)+(-10E+369) was returning
	-9999999999999999999999999999999999E+336 instead of expected
	result -1000000000000000000000000000000000E+337.
	(bid128_ext_fma): Ditto.
	(bid64qqq_fma): Ditto.
	* bid128_noncomp.c: Change return type of bid128_class from
	int to class_t.
	* bid128_round_integral.c: Add default case to avoid compiler
	warning.
	* bid128_string.c (bid128_to_string): Replace 0x30 with '0'
	for zero digit.
	(bid128_from_string): Ditto.
	* bid32_to_bid128.c (bid128_to_bid32): Fix Bug. In addition
	to the INEXACT flag, the UNDERFLOW flag needs to be set (and
	was not) when converting an input such as
	+6931674235302037148946035460357709E+1857 to +1000000E-101
	* bid32_to_bid64.c (bid64_to_bid32): fix Bug, In addition to
	the INEXACT flag, the UNDERFLOW flag needs to be set (and was
	not) when converting an input such as +9999999000000001E-111
	to +1000000E-101. Furthermore, significant bits of NaNs are
	set correctly now. For example,  0x7c00003b9aca0000 was
	returning 0x7c000002 instead of 0x 7c000100.
	* bid64_noncomp.c: Change return type of bid64_class from int
	to class_t.
	* bid64_round_integral.c (bid64_round_integral_exact): Add
	default case to avoid compiler warning.
	* bid64_string.c (bid64_from_string): Fix bug for rounding
	up. The input string "10000000000000000" was returning
	+1000000000000001E+1 instead of +1000000000000000E+1.
	* bid64_to_bid128.c (bid128_to_bid64): Fix bug, in addition to
	the INEXACT flag, the UNDERFLOW flag needs to be set (and was
	not) when converting an input such as
	+9999999999999999999999999999999999E-417 to
	+1000000000000000E-398.
	* bid_binarydecimal.c (bid32_to_binary64): Fix bug for
	conversion between binary and bid types. For example,
	0x7c0F4240 was returning 0x7FFFA12000000000 instead of
	expected double precision 0x7FF8000000000000.
	(binary64_to_bid32): Ditto.
	(binary80_to_bid32): Ditto.
	(binary128_to_bid32): Ditto.
	(binary80_to_bid64): Ditto.
	(binary128_to_bid64): Ditto.
	* bid_conf.h (BID_HIGH_128W): New macro.
	(BID_LOW_128W): Ditto.
	* bid_functions.h (__ENABLE_BINARY80__): Ditto.
	(ALIGN): Ditto.
	* bid_inline_add.h (get_add128): Add default case to avoid compiler
	warning.
	* bid_internal.h (get_BID64): Ditto.
	(fast_get_BID64_check_OF): Ditto.
	(ALIGN): New macro.

	Co-authored-by: Anderson, Cristina S <cristina.s.anderson@intel.com>
	Co-authored-by: Akkas, Ahmet <ahmet.akkas@intel.com>
	Co-authored-by: Cornea, Marius <marius.cornea@intel.com>
2024-05-05 16:03:46 +08:00