]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 hours agomatch.pd: Only merge truncation with conversion for -fno-signed-zeros releases/gcc-12 65/head
Joe Ramsay [Fri, 15 Mar 2024 09:20:45 +0000 (09:20 +0000)] 
match.pd: Only merge truncation with conversion for -fno-signed-zeros

This optimisation does not honour signed zeros, so should not be
enabled except with -fno-signed-zeros.

gcc/ChangeLog:

* match.pd: Fix truncation pattern for -fno-signed-zeroes

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/no_merge_trunc_signed_zero.c: New test.

(cherry picked from commit 7dd3b2b09cbeb6712ec680a0445cb0ad41070423)

12 hours agoLoongArch: Fix eh_return epilogue for normal returns.
Yang Yujie [Fri, 8 Dec 2023 10:01:18 +0000 (18:01 +0800)] 
LoongArch: Fix eh_return epilogue for normal returns.

On LoongArch, the regitsters $r4 - $r7 (EH_RETURN_DATA_REGNO) will be saved
and restored in the function prologue and epilogue if the given function calls
__builtin_eh_return.  This causes the return value to be overwritten on normal
return paths and breaks a rare case of libgcc's _Unwind_RaiseException.

gcc/ChangeLog:

PR target/114848
* config/loongarch/loongarch.cc: Do not restore the saved eh_return
data registers ($r4-$r7) for a normal return of a function that calls
__builtin_eh_return elsewhere.
* config/loongarch/loongarch-protos.h: Same.
* config/loongarch/loongarch.md: Same.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/eh_return-normal-return.c: New test.

(cherry picked from commit 4b421728289e6f1caa0dfaa953a11698ab95d37d)

12 hours agoDaily bump.
GCC Administrator [Tue, 30 Apr 2024 00:19:59 +0000 (00:19 +0000)] 
Daily bump.

36 hours agoDaily bump.
GCC Administrator [Mon, 29 Apr 2024 00:20:30 +0000 (00:20 +0000)] 
Daily bump.

2 days agoDaily bump.
GCC Administrator [Sun, 28 Apr 2024 00:19:55 +0000 (00:19 +0000)] 
Daily bump.

3 days agoDaily bump.
GCC Administrator [Sat, 27 Apr 2024 00:19:59 +0000 (00:19 +0000)] 
Daily bump.

3 days agoFortran: Fix assumed length chars and len inquiry [PR103716]
Paul Thomas [Tue, 23 May 2023 05:46:37 +0000 (06:46 +0100)] 
Fortran: Fix assumed length chars and len inquiry [PR103716]

2023-05-23  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/103716
* resolve.cc (gfc_resolve_ref): Conversion of array_ref into an
element should be done for all characters without a len expr,
not just deferred lens, and for integer expressions.
* trans-expr.cc (conv_inquiry): For len and kind inquiry refs,
set the se string_length to NULL_TREE.

gcc/testsuite/
PR fortran/103716
* gfortran.dg/pr103716.f90 : New test.

(cherry picked from commit 842a432b02238361ecc601d301ac400a7f30f4fa)

3 days agoaarch64: Fix SCHEDULER_IDENT for Cortex-A510
Richard Ball [Fri, 26 Apr 2024 17:21:07 +0000 (18:21 +0100)] 
aarch64: Fix SCHEDULER_IDENT for Cortex-A510

The SCHEDULER_IDENT for this CPU was incorrectly
set to cortexa55. This can cause
sub-optimal asm to be generated.

gcc/ChangeLog:
PR target/114272
* config/aarch64/aarch64-cores.def (AARCH64_CORE):
Change SCHEDULER_IDENT from cortexa55 to cortexa53
for Cortex-A510.

3 days agogfortran: Allow ref'ing PDT's len() in parameter-initializer.
Andre Vehreschild [Wed, 12 Jul 2023 10:51:30 +0000 (12:51 +0200)] 
gfortran: Allow ref'ing PDT's len() in parameter-initializer.

Fix declaring a parameter initialized using a pdt_len reference
not simplifying the reference to a constant.

2023-07-12  Andre Vehreschild  <vehre@gcc.gnu.org>

gcc/fortran/ChangeLog:

PR fortran/102003
* expr.cc (find_inquiry_ref): Replace len of pdt_string by
constant.
(simplify_ref_chain): Ensure input to find_inquiry_ref is
NULL.
(gfc_match_init_expr): Prevent PDT analysis for function calls.
(gfc_pdt_find_component_copy_initializer): Get the initializer
value for given component.
* gfortran.h (gfc_pdt_find_component_copy_initializer): New
function.
* simplify.cc (gfc_simplify_len): Replace len() of PDT with pdt
component ref or constant.

gcc/testsuite/ChangeLog:

* gfortran.dg/pdt_33.f03: New test.

(cherry picked from commit f9182da3213aa57c16dd0b52862126de4a259f6a)

4 days agoDaily bump.
GCC Administrator [Fri, 26 Apr 2024 00:20:25 +0000 (00:20 +0000)] 
Daily bump.

4 days agoarm: Zero/Sign extends for CMSE security
Richard Ball [Thu, 25 Apr 2024 14:30:42 +0000 (15:30 +0100)] 
arm: Zero/Sign extends for CMSE security

Co-Authored by: Andre Simoes Dias Vieira <Andre.SimoesDiasVieira@arm.com>

This patch makes the following changes:

1) When calling a secure function from non-secure code then any arguments
   smaller than 32-bits that are passed in registers are zero- or sign-extended.
2) After a non-secure function returns into secure code then any return value
   smaller than 32-bits that is passed in a register is  zero- or sign-extended.

This patch addresses the following CVE-2024-0151.

gcc/ChangeLog:
PR target/114837
* config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear):
Add zero/sign extend.
(arm_expand_prologue): Add zero/sign extend.

gcc/testsuite/ChangeLog:

* gcc.target/arm/cmse/extend-param.c: New test.
* gcc.target/arm/cmse/extend-return.c: New test.

(cherry picked from commit ad45086178d833254d66fab518b14234418f002b)

5 days agors6000: Fix wrong align passed to build_aligned_type [PR88309]
Kewen Lin [Tue, 9 Apr 2024 02:01:36 +0000 (21:01 -0500)] 
rs6000: Fix wrong align passed to build_aligned_type [PR88309]

As the comments in PR88309 show, there are two oversights
in rs6000_gimple_fold_builtin that pass align in bytes to
build_aligned_type but which actually requires align in
bits, it causes unexpected ICE or hanging in function
is_miss_rate_acceptable due to zero align_unit value.

This patch is to fix them by converting bytes to bits, add
an assertion on positive align_unit value and notes function
build_aligned_type requires align measured in bits in its
function comment.

PR target/88309

Co-authored-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/ChangeLog:

* config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_builtin): Fix
wrong align passed to function build_aligned_type.
* tree-ssa-loop-prefetch.cc (is_miss_rate_acceptable): Add an
assertion to ensure align_unit should be positive.
* tree.cc (build_qualified_type): Update function comments.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr88309.c: New test.

5 days agoDaily bump.
GCC Administrator [Thu, 25 Apr 2024 00:20:15 +0000 (00:20 +0000)] 
Daily bump.

6 days agoDaily bump.
GCC Administrator [Wed, 24 Apr 2024 00:20:32 +0000 (00:20 +0000)] 
Daily bump.

6 days agotsan: Don't instrument non-generic AS accesses [PR111736]
Jakub Jelinek [Tue, 26 Mar 2024 10:06:15 +0000 (11:06 +0100)] 
tsan: Don't instrument non-generic AS accesses [PR111736]

Similar to the asan and ubsan changes, we shouldn't instrument non-generic
address space accesses with tsan, because we just have library functions
which take address of the objects as generic address space pointers, so they
can't handle anything else.

2024-03-26  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/111736
* tsan.cc (instrument_expr): Punt on non-generic address space
accesses.

* gcc.dg/tsan/pr111736.c: New test.

(cherry picked from commit 471967ab8b4c49338ba77defbe24b06cc51c0093)

6 days agoubsan: Don't -fsanitize=null instrument __seg_fs/gs pointers [PR111736]
Jakub Jelinek [Fri, 22 Mar 2024 08:23:44 +0000 (09:23 +0100)] 
ubsan: Don't -fsanitize=null instrument __seg_fs/gs pointers [PR111736]

On x86 and avr some address spaces allow 0 pointers (on avr actually
even generic as, but libsanitizer isn't ported to it and
I'm not convinced we should completely kill -fsanitize=null in that
case).
The following patch makes sure those aren't diagnosed for -fsanitize=null,
though they are still sanitized for -fsanitize=alignment.

2024-03-22  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/111736
* ubsan.cc (ubsan_expand_null_ifn, instrument_mem_ref): Avoid
SANITIZE_NULL instrumentation for non-generic address spaces
for which targetm.addr_space.zero_address_valid (as) is true.

* gcc.dg/ubsan/pr111736.c: New test.

(cherry picked from commit ddd4a3ca87410886b039cc225907b4f6e650082e)

6 days agotree-optimization/111736 - avoid address sanitizing of __seg_gs
Richard Biener [Thu, 21 Mar 2024 07:30:39 +0000 (08:30 +0100)] 
tree-optimization/111736 - avoid address sanitizing of __seg_gs

The following more thoroughly avoids address sanitizing accesses
to non-generic address-spaces.

PR tree-optimization/111736
* asan.cc (instrument_derefs): Do not instrument accesses
to non-generic address-spaces.

* gcc.target/i386/pr111736.c: New testcase.

(cherry picked from commit 134ef2a8cac1a5cc718739bd7d3b3472947c80d6)

6 days agosanitizer/111736 - skip ASAN for globals in alternate address-space
Richard Biener [Tue, 5 Dec 2023 13:00:43 +0000 (14:00 +0100)] 
sanitizer/111736 - skip ASAN for globals in alternate address-space

PR sanitizer/111736
* asan.cc (asan_protect_global): Do not protect globals
in non-generic address-space.

(cherry picked from commit 7e40497805c0831596334fe474112f991276e11b)

7 days agoDaily bump.
GCC Administrator [Tue, 23 Apr 2024 00:21:01 +0000 (00:21 +0000)] 
Daily bump.

7 days agotestsuite: Remove duplicate -lgcov [PR114034]
Iain Sandoe [Sun, 31 Mar 2024 10:22:58 +0000 (11:22 +0100)] 
testsuite: Remove duplicate -lgcov [PR114034]

Duplicate library entries now cause linker warnings with newer linker
versions on Darwin which leads to these tests regressing.  The library
is already added by the test flags so there is no need to put an extra
one in the options.

PR testsuite/114034

gcc/testsuite/ChangeLog:

* g++.dg/gcov/gcov-dump-1.C: Remove extra -lgcov.
* g++.dg/gcov/gcov-dump-2.C: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 799a056cf804f433ce0050a5a6bf900f7a01ecb1)

7 days agoDarwin, ppc: Add system stubs for all 32b PPC
Iain Sandoe [Wed, 26 Jul 2023 13:31:02 +0000 (14:31 +0100)] 
Darwin, ppc: Add system stubs for all 32b PPC

This is a minor adjustment to make the GCC behaviour better match the
old system tools.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/rs6000/darwin.h (LIB_SPEC): Include libSystemStubs for
all 32b Darwin PowerPC cases.

(cherry picked from commit b3ab28c3e85af7995fffb87eb190ef942b7e9e4a)

7 days agojit, Darwin: Implement library exports list.
Iain Sandoe [Sat, 13 Jan 2024 17:20:47 +0000 (17:20 +0000)] 
jit, Darwin: Implement library exports list.

Currently, we have no exports list for libgccjit, which means that
all symbols are exported, including those from libstdc++ which is
linked statically into the lib.  This causes failures when the
shared libstdc++ is used but some c++ symbols are satisfied from
libgccjit.

This implements an export file for Darwin (which is currently
manually created by cross-checking libgccjit.map).  Ideally we'd
script this, at some point.  Update libtool current and age to
reflect the current ABI version (we are not bumping the SO name
at this stage).

This fixes a number of new failures in jit testing.

gcc/jit/ChangeLog:

* Make-lang.in: Implement exports list, and use a shared
libgcc.
* libgccjit.exports: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit b120e355e59142bd15d6b010461d07236288d843)

7 days agoDarwin: Correct a version check.
Iain Sandoe [Mon, 1 Apr 2024 19:47:25 +0000 (20:47 +0100)] 
Darwin: Correct a version check.

When the version for dsymutil comes from a clang build, it is
of the form NNmm.pp.qq where NN and mm are the major and minor
LLVM version components.  We need to check for a major version
greater than or equal to 7 - so use 700 in the check.

gcc/ChangeLog:

* config/darwin.cc (darwin_override_options): Update the
clang major version value in the dsymutil check.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 451bb0b9262d2f54173937569a29d7f1ad234e30)

7 days agoconfigure, Darwin: Correct a pasto in host-shared processing.
Iain Sandoe [Sun, 26 Jun 2022 08:24:28 +0000 (09:24 +0100)] 
configure, Darwin: Correct a pasto in host-shared processing.

We do, of course, mean $host not $target in this case.  Corrected thus.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
ChangeLog:

* configure: Regenerate.
* configure.ac: Correct use of $host.

(cherry picked from commit 1edfc8f2d3307a3ffa077a605f432832d7715462)

8 days agoDaily bump.
GCC Administrator [Mon, 22 Apr 2024 00:20:27 +0000 (00:20 +0000)] 
Daily bump.

9 days agotestsuite, Darwin: Allow for an undefined symbol [PR114036].
Iain Sandoe [Sun, 31 Mar 2024 10:27:53 +0000 (11:27 +0100)] 
testsuite, Darwin: Allow for an undefined symbol [PR114036].

Darwin's linker defaults to requiring all symbols to be defined at
static link time (unless specifically noted or dynamic lookuo is
enabled).

For this test, we just need to note that the symbol is expected to
be undefined.

PR testsuite/114036

gcc/testsuite/ChangeLog:

* gcc.misc-tests/gcov-14.c: Allow for 'Foo' to be undefined
on Darwin link lines.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit ad8e34eaa870608e2b07b4e7147e6ef2944bb8b5)

9 days agoDarwin: Do not emit .macinfo when dsymutil cannot consume it.
Iain Sandoe [Sun, 31 Mar 2024 22:25:31 +0000 (23:25 +0100)] 
Darwin: Do not emit .macinfo when dsymutil cannot consume it.

Some verions of dsymutil do not ignore .macinfo sections, but instead
ignore the entire debug in the file.

To avoid this total loss of debug, when we detect that the debug level
is g3 and the dsymutil version cannot support it, we reduce the level
to g2 and issue a note.

This behaviour can be overidden by -gstrict-dwarf (although the objects
will contain macinfo; dsymutil will not produce a .dSYM with it).

gcc/ChangeLog:

* config/darwin.cc (darwin_override_options): Reduce the debug
level to 2 if dsymutil cannot handle .macinfo sections.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 3c499f8f6f7d19b21d7047efabbe6396ee1c2cac)

9 days agolibphobos, Darwin: Enable libphobos for most Darwin.
Iain Sandoe [Mon, 1 Apr 2024 12:58:20 +0000 (13:58 +0100)] 
libphobos, Darwin: Enable libphobos for most Darwin.

Earlier Darwin systems can be made to work too - but they need non-
standard 'binutils', so for now these must be enabled specifically.

libphobos/ChangeLog:

* configure.tgt: Enable libphobos for Darwin >= 12.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
9 days agolibstdc++, Darwin: Handle a linker warning [PR112397].
Iain Sandoe [Thu, 8 Feb 2024 17:54:31 +0000 (17:54 +0000)] 
libstdc++, Darwin: Handle a linker warning [PR112397].

Darwin's linker warns when we make a direct branch to code that is
in a weak definition (citing that if a different implementation of
the weak function is chosen by the dynamic linker this would be an
error).

As the analysis in the PR shows, this can happen when we have hot/
cold partitioning and there is an error path that is primarily cold
but makes use of epilogue code in the hot section.  In this simple
case, we can easily deduce that the code is in fact safe; however
that is not something we can realistically implement in the linker.

Since the user-replaceable allocators are implemented using weak
definitions, this is a warning that is frequently flagged up in both
the testsuite and end-user code.

The chosen solution here is to suppress the hot/cold partitioning for
these cases (it is unlikely to impact performance much c.f. the
actual allocation).

PR target/112397

libstdc++-v3/ChangeLog:

* configure: Regenerate.
* configure.ac: Detect if we are building for Darwin.
* libsupc++/Makefile.am: If we are building for Darwin, then
suppress hot/cold partitioning for the array allocators.
* libsupc++/Makefile.in: Regenerated.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 1609fdff16f17ead37666f6d0e801800ee3d04d2)

9 days agotestsuite, Darwin: Use the IOKit framework in framework-1.c [PR114049].
Iain Sandoe [Mon, 18 Mar 2024 10:06:44 +0000 (10:06 +0000)] 
testsuite, Darwin: Use the IOKit framework in framework-1.c [PR114049].

The intent of the test is to show that we find a framework that
is installed in /System/Library/Frameworks when the user has added
a '-F' option.  The trick is to choose some header that is present
for all the Darwin versions we support and that does not contain any
content we cannot parse.  We had been using the Kernel framework for
this, but recent SDK versions have revealed that this is not suitable.

Replacing with a use of IOKit.

PR target/114049

gcc/testsuite/ChangeLog:

* gcc.dg/framework-1.c: Use an IOKit header instead of a
Kernel one.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 4adb1a5839e7a3310a127c1776f1f95d7edaa6ff)

9 days agolibstdc++: Sync the atomic_link_flags implementation with GCC.
Iain Sandoe [Mon, 18 Mar 2024 09:57:33 +0000 (09:57 +0000)] 
libstdc++: Sync the atomic_link_flags implementation with GCC.

For Darwin, in order to allow uninstalled testing, we need to provide
a '-B' option pointing to each path containing an uninstalled library
that we are using (these get appended to the embedded runpaths).

This updates the version of the atomic_link_flags proc in the libstdc++
testsuite to do the same as the one in the GCC testsuite.

libstdc++-v3/ChangeLog:

* testsuite/lib/dg-options.exp (atomic_link_flags): Emit a -B
option for the path to the uninstalled libatomic.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 71a44faa8a4f76d68356c66c6054e6c242df820f)

9 days agolibstdc++, Darwin: Do not use dev/null as the file for executables.
Iain Sandoe [Tue, 19 Mar 2024 10:40:50 +0000 (10:40 +0000)] 
libstdc++, Darwin: Do not use dev/null as the file for executables.

Darwin has a separate debug linker, which is invoked when the command
line contains source files and debug is enabled.

Using /dev/null as the executable name does not, therefore, work when
debug is enabled, since the debug linker does not accept /dev/null as
a valid executable name.

The leads to incorrectly UNSUPPORTED testcases because of the unintended
error result from the test compilation.

The solution here is to use a temporary file that is deleted at the
end of the test (which is the mechanism used elsewhere)

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp (v3_target_compile): Instead of
/dev/null, use a temporary file for test executables on Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit e47330d0742c985fd8d5fe7089aa381d34967d61)

9 days agoDarwin, testsuite: -multiply_defined is obsolete
Francois-Xavier Coudert [Sat, 10 Feb 2024 14:52:44 +0000 (15:52 +0100)] 
Darwin, testsuite: -multiply_defined is obsolete

gcc/testsuite/ChangeLog:

* gcc.dg/ssp-2.c: Ignore warning that
-multiply_defined is obsolete

(cherry picked from commit 6b13e32162adf9e4f552e09c46f1de531ffa8c05)

9 days agoDarwin, testsuite: -bind_at_load is deprecated
Francois-Xavier Coudert [Sat, 10 Feb 2024 11:55:29 +0000 (12:55 +0100)] 
Darwin, testsuite: -bind_at_load is deprecated

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-ld-2.c: Ignore warning
that -bind_at_load is deprecated.

(cherry picked from commit f88219333e85a05a98468f67d2f2190fc330044e)

9 days agoTestsuite: restrict test to nonpic targets
Francois-Xavier Coudert [Mon, 11 Dec 2023 08:26:23 +0000 (09:26 +0100)] 
Testsuite: restrict test to nonpic targets

The test is currently failing on x86_64-apple-darwin.

gcc/testsuite/ChangeLog:

PR testsuite/112297
* gcc.target/i386/pr100936.c: Require nonpic target.

(cherry picked from commit 02f562484c17522d79a482ac702a5fa3c2dfdd10)

9 days agoTestsuite, i386: Mark test as requiring ifunc
Francois-Xavier Coudert [Mon, 30 Oct 2023 14:41:10 +0000 (15:41 +0100)] 
Testsuite, i386: Mark test as requiring ifunc

Test is currently failing on x86_64-apple-darwin.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr105554.c: Require ifunc.

(cherry picked from commit 7666d94db0684f04264712f3e3fdb542518960c5)

9 days agoTestsuite, DWARF2: adjust regexp to match darwin output
Francois-Xavier Coudert [Sun, 20 Aug 2023 10:53:19 +0000 (12:53 +0200)] 
Testsuite, DWARF2: adjust regexp to match darwin output

gcc/testsuite/ChangeLog:

* gcc.dg/debug/dwarf2/inline4.c: Ajdust regexp to match darwin
output.

(cherry picked from commit 94e68ce96c285e479736851f1ad8cc87c8c3ff0c)

9 days agoDaily bump.
GCC Administrator [Sun, 21 Apr 2024 00:19:48 +0000 (00:19 +0000)] 
Daily bump.

9 days agoTestsuite, Darwin: skip PIE test
Francois-Xavier Coudert [Mon, 30 Oct 2023 11:41:17 +0000 (12:41 +0100)] 
Testsuite, Darwin: skip PIE test

gcc/testsuite/ChangeLog:

* gcc.dg/pie-2.c: Skip test on darwin.

(cherry picked from commit a0c557690c8d5327deda6e21f8d1deca8451a4cb)

9 days agotestsuite, Darwin: Skip g++.dg/debug/dwarf2/pr85550.C
Iain Sandoe [Sun, 1 Oct 2023 19:38:44 +0000 (20:38 +0100)] 
testsuite, Darwin: Skip g++.dg/debug/dwarf2/pr85550.C

There are two problems here; first that the emitted asm for
-fdebug-types-section is ELF-specfic leading to assembler errors for
Mach-O.  If we fix this, we get a secondary fail since the debug linker
does not recognise DW_FORM_ref_sig8.  Disable ths test until we get
DWARF-5 support in the external Darwin toolchain components.

gcc/testsuite/ChangeLog:

* g++.dg/debug/dwarf2/pr85550.C: Skip for Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 76547f4c97b1c0744487d624c5e2e5a15d0370a9)

9 days agotestsuite: adjust for darwin linker warning
Francois-Xavier Coudert [Fri, 8 Sep 2023 19:55:56 +0000 (21:55 +0200)] 
testsuite: adjust for darwin linker warning

On recent macOS versions, no_pie is deprecated and the linker complains
about it: "-no_pie is deprecated when targeting new OS versions"

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-segaddr.c: Adjust for darwin linker warning.
* gcc.dg/pie-7.c: Likewise.

(cherry picked from commit d9926c0d974646dc6024d5a881fe1bee2f499139)

9 days agoTestsuite, darwin: account for macOS 13 and 14
Francois-Xavier Coudert [Sun, 20 Aug 2023 22:00:44 +0000 (00:00 +0200)] 
Testsuite, darwin: account for macOS 13 and 14

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-minversion-link.c: Account for macOS 13 and 14.

(cherry picked from commit 6d33602650612c89e7e32201266763b167f62a46)

9 days agoTestsuite: mark IPA test as requiring alias support
Francois-Xavier Coudert [Sun, 20 Aug 2023 12:13:22 +0000 (14:13 +0200)] 
Testsuite: mark IPA test as requiring alias support

This was indicated in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85656
but never committed. Without it, the test fails on darwin.

gcc/testsuite/ChangeLog:
* gcc.dg/ipa/ipa-icf-38.c: Require alias support.

(cherry picked from commit 02393e4b5eabe1c64720b022cb6f819e7b4dc08b)

9 days agoTestsuite: fix analyzer tests on Darwin
Francois-Xavier Coudert [Sat, 19 Aug 2023 21:22:06 +0000 (23:22 +0200)] 
Testsuite: fix analyzer tests on Darwin

On macOS, system headers redefine by default some macros (memcpy,
memmove, etc) to checked versions, which defeats the analyzer. We
want to turn this off.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104042

gcc/testsuite/ChangeLog:

PR analyzer/104042
* gcc.dg/analyzer/analyzer.exp: Pass -D_FORTIFY_SOURCE=0 on Darwin.

(cherry picked from commit ce33bbfcbc7dd3afc6c96fb48a19ed00f0c598ce)

9 days agotestsuite, Darwin: Allow for undefined symbols in shared test.
Iain Sandoe [Mon, 29 Jan 2024 10:09:25 +0000 (10:09 +0000)] 
testsuite, Darwin: Allow for undefined symbols in shared test.

Darwin's linker defaults to error on undefined (which makes it look as
if we do not support shared, leading to tests being marked incorrectly
as unsupported).

This fixes the issue by allowing the symbols used in the target
supports test to be undefined.

includes commit 0ed6e5b4820e01fa86b48a7b1d62f752ec97ea41

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_shared):
Allow the external symbols referenced in the test to be undefined.

(cherry picked from commit 639bd5e9b759a6d733fadbd5f956889d965e9368)

Co-authored-by: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
9 days agotestsuite, jit, Darwin: Handle Mach-O in assembler tests.
Iain Sandoe [Sat, 13 Jan 2024 13:40:51 +0000 (13:40 +0000)] 
testsuite, jit, Darwin: Handle Mach-O in assembler tests.

Several of the jit tests check for assembler-specific output
which differs on Mach-O from ELF.

This patch uses the facility to make the scans target-dependent
and adds handling for darwin.

gcc/testsuite/ChangeLog:

* jit.dg/test-setting-alignment.c:  Handle Darwin in
jit-verify-assemble output.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 283e3a974bf08e4fb64d51d2062e1f7ed7482ff4)

9 days agotestsuite, jit: Allow for target-specific assembler scans.
Iain Sandoe [Sat, 13 Jan 2024 13:30:08 +0000 (13:30 +0000)] 
testsuite, jit: Allow for target-specific assembler scans.

If we want to support multiple object formats and to allow for
scan-assembler tests, we need to make it possible to adjust the
tests on a per-target basis.

This adds similar mechamisms to jit-verify-assembler-output
to those used for the general scan-assembler dg directives.

As an aside; it would, perhaps, be possible to integrate this more
with scanasm.exp (which would also give access to function body
scanning) but I did not attempt that for this patch.

After this, we can accept things like:
... { jit-verify-assembler-output "......" { target *-*-darwin* } } }

gcc/testsuite/ChangeLog:

* jit.dg/jit.exp: Accept target clauses in jit-verify-assembler
handling.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit e0e3ef18a047d54d63be91d82a55448851353260)

9 days agotestsuite, jit: Handle whitespace in test-link-section-assembler.c.
Iain Sandoe [Sat, 13 Jan 2024 12:49:28 +0000 (12:49 +0000)] 
testsuite, jit: Handle whitespace in test-link-section-assembler.c.

Darwin has a different .section directive that has more fields and
uses different whitespace.  Amend the whitespace in the scan-asm to
be more flexible.

gcc/testsuite/ChangeLog:

* jit.dg/test-link-section-assembler.c: Accept any whitespace
between the .section directive and its arguments.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 2b0abfd3f8dbe3e9af79bb6bdc06d727d36f1946)

9 days agoObjective-C/C++: Ensure sufficient setup for the preprocessor.
Iain Sandoe [Tue, 9 Jan 2024 17:31:41 +0000 (17:31 +0000)] 
Objective-C/C++: Ensure sufficient setup for the preprocessor.

The tokenizer makes use of functions that determine if identifiers
are interface or class names, and those functions need a hash map
to be set up.

This ensures that these are initialized before pre-process-only
jobs are run.

gcc/objc/ChangeLog:

* objc-act.cc (objc_init): Initialize interface and class
name hash maps before the preprocessor uses them.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 60f58d0630805e8dce79f5489658fd83e42fa8f1)

10 days agoDaily bump.
GCC Administrator [Sat, 20 Apr 2024 00:19:55 +0000 (00:19 +0000)] 
Daily bump.

10 days agotestsuite,objective-c++: Fix imported NSObjCRuntime.h.
Iain Sandoe [Fri, 23 Jun 2023 14:29:14 +0000 (15:29 +0100)] 
testsuite,objective-c++: Fix imported NSObjCRuntime.h.

We have imported some headers from the GNUStep project to allow us
to maintain the testsuite independent to changing versions of system
headers.

One of these headers has a macro that (now we have support for
__has_feature) expands to a declaration that triggers a warning.

These headers are considered part of the implementation so that, in
this case, we can suppress the warning with the system_header pragma.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h: Make
this header use pragma system_header.

(cherry picked from commit d83e0e3bc375a05844438d28c9a4ab24c5401eb9)

10 days agotestsuite, Objective-C: Fix duplicate libobjc cases.
Iain Sandoe [Thu, 25 Jan 2024 20:17:42 +0000 (20:17 +0000)] 
testsuite, Objective-C: Fix duplicate libobjc cases.

Two of the encode testcases include '-lobjc' as their dg-options.
Since the library is already appended as part of the generic testsuite
handling,  this means that two instances appear on the link line leading
to spurious warnings from Darwin's new linker.

gcc/testsuite/ChangeLog:

* obj-c++.dg/encode-10.mm: Remove unneeded '-lobjc' option addition.
* obj-c++.dg/encode-9.mm: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 30d9e81c19d69e15b2e9c53e4377879cbf9b0b84)

10 days agoDarwin: Handle the fPIE option specially.
Iain Sandoe [Wed, 25 Oct 2023 14:28:52 +0000 (15:28 +0100)] 
Darwin: Handle the fPIE option specially.

For Darwin, PIE requires PIC codegen, but otherwise is only a link-time
change. For almost all Darwin, we do not report __PIE__; the exception is
32bit X86 and from Darwin12 to 17 only (32 bit is no longer supported
after Darwin17).

gcc/ChangeLog:

* config/darwin.cc (darwin_override_options): Handle fPIE.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit da9e72f80f3358bd9586e11aaf03341c1f867318)

11 days agoDarwin: Correct handling of weak crts.
Iain Sandoe [Thu, 21 Mar 2024 14:34:44 +0000 (14:34 +0000)] 
Darwin: Correct handling of weak crts.

Backport part of 506e74f53a5 from trunk.

We need the weak crts to be considered ahead of GCC target libraries
(except libgcc_s) to avoid spurious dependencies on otherwise unused
libs.

gcc/ChangeLog:

* config/darwin.h (LINK_COMMAND_SPEC_A): Handle weak crts
before other objects. (REAL_LIBGCC_SPEC): Remove weak crts
from here.  (DARWIN_WEAK_CRTS): New.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
11 days agoObjective-C, Darwin: Do not overalign CFStrings and Objective-C metadata.
Iain Sandoe [Thu, 25 Jan 2024 20:11:09 +0000 (20:11 +0000)] 
Objective-C, Darwin: Do not overalign CFStrings and Objective-C metadata.

We have reports of regressions in both Objective-C and Objective-C++ on
Darwin23 (macOS 14).  In some cases, these are linker warnings about the
alignment of CFString constants; in other cases the built executables
crash during runtime initialization.  The underlying issue is the same in
both cases; since the objects (CFStrings, Objective-C meta-data) are TU-
local, we are choosing to increase their alignment for efficiency - to
values greater than ABI alignment.

However, although these objects are TU-local, they are also visible to the
linker (since they are placed in specific named sections).  In many cases
the metadata can be regarded as tables of data, and thus it is expected
that these sections can be concatenated from multiple TUs and the data
treated as tabular.  In order for this to work the data cannot be allowed
to exceed ABI alignment - which leads to the crashes.

For GCC-15+ it would be nice to find a more elegant solution to this issue
(perhaps by adjusting the concept of binds-locally to exclude specific
named sections) - but I do not want to do that in stage 4.

The solution here is to force the alignment to be preserved as created by
setting DECL_USER_ALIGN on the relevant objects.

gcc/ChangeLog:

* config/darwin.cc (darwin_build_constant_cfstring): Prevent over-
alignment of CFString constants by setting DECL_USER_ALIGN.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.cc (build_v2_address_table): Prevent
over-alignment of Objective-C metadata by setting DECL_USER_ALIGN
on relevant variables.
(build_v2_protocol_list_address_table): Likewise.
(generate_v2_protocol_list): Likewise.
(generate_v2_meth_descriptor_table): Likewise.
(generate_v2_meth_type_list): Likewise.
(generate_v2_property_table): Likewise.
(generate_v2_dispatch_table): Likewise.
(generate_v2_ivars_list): Likewise.
(generate_v2_class_structs): Likewise.
(build_ehtype): Likewise.
* objc-runtime-shared-support.cc (generate_strings): Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit f74f840d35117bcaf995cee99fb2ab30c60f64f3)

11 days agoDarwin: Fix a typo in Objective-C meta-data.
Iain Sandoe [Mon, 8 Jan 2024 16:17:04 +0000 (16:17 +0000)] 
Darwin: Fix a typo in Objective-C meta-data.

We have a typo in the metadata for assigning NSStrings to a specific
section for the V1 (32b) ABI.  When that is fixed we should never see
the case where the section needs to be deduced from the properties of
the DECLs.

gcc/ChangeLog:

* config/darwin.cc (darwin_objc1_section): Use the correct
meta-data version for constant strings.
(machopic_select_section): Assert if we fail to handle CFString
sections as Obejctive-C meta-data or drectly.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 8d26636f0da31e6c17b57ced52bfc61a45f23cee)

11 days agoDarwin: Fix constant CFString code-gen [PR105522].
Iain Sandoe [Sat, 6 Jan 2024 10:52:38 +0000 (10:52 +0000)] 
Darwin: Fix constant CFString code-gen [PR105522].

Although this only fires for one of the Darwin sub-ports, it is latent
elsewhere, it is also a regression c.f. the Darwin system compiler.

In the code we imported from an earlier branch, CFString objects (which
are constant aggregates) are constructed as CONST_DECLs.  Although our
current documentation suggests that these are reserved for enumeration
values, in fact they are used elsewhere in the compiler for constants.
This includes Objective-C where they are used to form NSString constants.

In the particular case, we take the address of the constant and that
triggers varasm.cc:decode_addr_constant, which does not currently support
CONST_DECL.

If there is a general intent to allow/encourage wider use of CONST_DECL,
then we should fix decode_addr_constant to look through these and evaluate
the initializer (a two-line patch, but I'm not suggesting it for stage-4).

We also need to update the GCC internals documentation to allow for the
additional uses.

This patch is Darwin-local and fixes the problem by making the CFString
constants into regular variable but TREE_CONSTANT+TREE_READONLY. I plan
to back-port this to the open branches once it has baked a while on trunk.

Since, for Darwin, the Objective-C default is to construct constant
NSString objects as CFStrings; this will also cover the majority of cases
there (this patch does not make any changes to Objective-C NSStrings).

PR target/105522

gcc/ChangeLog:

* config/darwin.cc (machopic_select_section): Handle C and C++
CFStrings.
(darwin_rename_builtins): Move this out of the CFString code.
(darwin_libc_has_function): Likewise.
(darwin_build_constant_cfstring): Create an anonymous var to
hold each CFString.
* config/darwin.h (ASM_OUTPUT_LABELREF): Handle constant
CFstrings.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit aecc0d4ba73d0810334b351da1e67232cea450d3)

11 days agoObjective-C, Darwin: Fix a regression in handling bad receivers.
Iain Sandoe [Sat, 6 Jan 2024 19:21:40 +0000 (19:21 +0000)] 
Objective-C, Darwin: Fix a regression in handling bad receivers.

This is seen on 32b hosts with a 64b multilib, and is an ICE when
the build has checking enabled.  The fix is to exit the routine
early if the sender or receiver are already error_mark_node.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.cc
(build_v2_objc_method_fixup_call): Early exit for cases
where the sender or receiver are known to be in error.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 846794ead2982fc85a3b1a83bbb831fa096b2b7c)

11 days agotestsuite, x86: Handle a broken assembler
Iain Sandoe [Sun, 29 Oct 2023 07:19:53 +0000 (07:19 +0000)] 
testsuite, x86: Handle a broken assembler

Earlier assembler support for complex fp16 on x86_64 Darwin is broken.
This adds an additional test to the existing target-supports that fails
for the broken assemblers but works for the newer, fixed, ones.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Test an asm line that fails on broken
Darwin assembler versions.

(cherry picked from commit d65eb8a6bbeae7533dd41cb307b427f3f8585d9b)

11 days agoDarwin: Make metadata symbol lables linker-visible for GNU objc.
Iain Sandoe [Sat, 30 Sep 2023 16:15:16 +0000 (17:15 +0100)] 
Darwin: Make metadata symbol lables linker-visible for GNU objc.

Now we have shifted to using the same relocation mechanism as clang for
objective-c typeinfo the static linker needs to have a linker-visible
symbol for metadata names (this is only needed for GNU objective C, for
NeXT the names are in separate sections).

gcc/ChangeLog:

* config/darwin.h
(darwin_label_is_anonymous_local_objc_name): Make metadata names
linker-visibile for GNU objective C.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 2ae00adb326ed050bd67a67656b20a2cfe789626)

11 days agoDaily bump.
GCC Administrator [Fri, 19 Apr 2024 00:20:34 +0000 (00:20 +0000)] 
Daily bump.

11 days agoDarwin: Check as for .build_version support and use it if available.
Iain Sandoe [Tue, 17 Oct 2023 10:10:27 +0000 (11:10 +0100)] 
Darwin: Check as for .build_version support and use it if available.

This adds support for the minimum OS version data in assembler files.
At present, we have no mechanism to detect the SDK version in use, and
so that is omitted from build_versions.

We follow the implementation in clang, '.build_version' is only emitted
(where supported) for target macOS versions >= 10.14.  For earlier macOS
we fall back to using a '.macosx_version_min' directive.  This latter is
also emitted when the assembler supports it, but not build_version.

gcc/ChangeLog:

* config.in: Regenerate.
* config/darwin.cc (darwin_file_start): Add assembler directives
for the target OS version, where these are supported by the
assembler.
(darwin_override_options): Check for building >= macOS 10.14.
* configure: Regenerate.
* configure.ac: Check for assembler support of .build_version
directives.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit a4184c8a65a00eaf8a8d7f92fb8ad2f8621b39e2)

11 days agoDarwin: Partial reversion of r14-3648 (Inits Section).
Iain Sandoe [Sun, 10 Sep 2023 13:48:42 +0000 (14:48 +0100)] 
Darwin: Partial reversion of r14-3648 (Inits Section).

Although the Darwin ABI places both hot and cold partitions in the same
section (the linker can partition by name), this does not work with the
current dwarf2out implementation.

Since we do see global initialization code getting hot/cold splits, this
patch places the cold parts into text_cold, and keeps the hot part in
the correct Init section per ABI.

TODO: figure out a way to allow us to match the ABI fully.

gcc/ChangeLog:

* config/darwin.cc (darwin_function_section): Place unlikely
executed global init code into the standard cold section.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 5b33b364652866165431aef1810af1e890229c5e)

11 days agoDarwin: Place global inits in the correct section.
Iain Sandoe [Fri, 1 Sep 2023 08:04:13 +0000 (09:04 +0100)] 
Darwin: Place global inits in the correct section.

This handles placement of global initializers into __TEXT,__StaticInit as used
by other platform toolchains.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin-sections.def (static_init_section): Add the
__TEXT,__StaticInit section.
* config/darwin.cc (darwin_function_section): Use the static init
section for global initializers, to match other platform toolchains.

(cherry picked from commit 68dc3e94fd6bd395a8b343533485616dff3fc796)

11 days agoDarwin: Match system sections and relocs for exception tables.
Iain Sandoe [Thu, 31 Aug 2023 18:20:43 +0000 (19:20 +0100)] 
Darwin: Match system sections and relocs for exception tables.

System tools from Darwin10 onwards have moved the exceptions tables from
the __DATA segment to the __TEXT one.  They also revised the relocations
used for typeinfo.  While Darwin9 was not changed at the time, in fact the
tools there are equally happy with the revised scheme - and therefore at
present there seems no reason to special-case it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin-sections.def (darwin_exception_section): Move to
the __TEXT segment.
* config/darwin.cc (darwin_emit_except_table_label): Align before
the exception table label.
* config/darwin.h (ASM_PREFERRED_EH_DATA_FORMAT): Use indirect PC-
relative 4byte relocs.

(cherry picked from commit 0fe7962afc7c01488432b98b6f442b24946a490d)

11 days agobuild: Allow for Xcode 15 ld -v output
Rainer Orth [Thu, 17 Aug 2023 08:14:49 +0000 (10:14 +0200)] 
build: Allow for Xcode 15 ld -v output

Since Xcode 15 beta 6, ld -v output differs from previous versions:

* macOS 13/Xcode 14:

  @(#)PROGRAM:ld  PROJECT:ld64-857.1

* macOS 14/Xcode 15:

  @(#)PROGRAM:ld  PROJECT:dyld-1015.1

configure cannot handle the new form, so LD64_VERSION isn't set.

This patch fixes this.  The autoconf manual states that sed doesn't
portably support alternation, so I'm using two separate expressions to
extract the version number.

Tested on x86_64-apple-darwin23.0.0.

2023-08-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* configure.ac (gcc_cv_ld64_version): Allow for dyld in ld -v
output.
* configure: Regenerate.

(cherry picked from commit 0beac9209f0ae230b34ad31e76e7b0b633a5fb21)

11 days agoconfigure, Darwin: Adjust handing of stdlib option.
Iain Sandoe [Sat, 16 Sep 2023 07:40:49 +0000 (08:40 +0100)] 
configure, Darwin: Adjust handing of stdlib option.

The intent of the configuration choices for -stdlib is that default
setting should choose reasonable options for the target.  This should
enable -stdlib= for Darwin targets where libc++ is the default on the
system (so that it is only necessary to provide the headers).

However, it seems that there are some cases where (external) config
scripts are using -stdlib (incorrectly) to determine if the compiler
in use is GCC or clang.

In order to allow for these cases, this patch refines the setting
like so:

--with-gxx-libcxx-include-dir= is used to configure the path containing
libc++ headers; it also controls the enabling of the -stdlib option.

We are adding a special value for path:
if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option.

Otherwise if the --with-gxx-libcxx-include-dir is set we use the path
provided, and enable the stdlib option.

if --with-gxx-libcxx-include-dir is unset
We decide on the stdlib option based on the OS type and revision being
targeted.  The path is set to a fixed position relative to the compiler
install (similar logic to that used for libstdc++ headers).

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* configure: Regenerate.
* configure.ac: Handle explict disable of stdlib option, set
defaults for Darwin.

(cherry picked from commit ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc)

11 days agoDarwin: Move checking of the 'shared' driver spec.
Iain Sandoe [Sun, 9 Jul 2023 08:02:39 +0000 (09:02 +0100)] 
Darwin: Move checking of the 'shared' driver spec.

This avoids a bunch of irrelevant diagnostics if the user passes '-shared' to
gnatmake.  Currently, we push '-dynamiclib' back onto the command line (since
that is the Darwin spelling of 'shared') but this is not handled by gnat1,
leading to a diagnostic for every character after the '-d'.

'-shared' has no effect on gnatmake (it needs to be passed to gnatbind).

This moves the handling of '-shared' to leaf specs so that we do not need to
push 'dynamiclib' onto the command line.

includes changes in 3b18fd28c83ac90bf408389c003ed25d93438210.

gcc/ChangeLog:

* config/darwin.h:
(SUBTARGET_DRIVER_SELF_SPECS): Move handling of 'shared' into the same
specs as 'dynamiclib'. (STARTFILE_SPEC): Handle 'shared'.

(cherry picked from commit 2e36eedb244badaaf2a70388071115c851b8db9b)

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
11 days agolibstdc++, Darwin: Limit recursive mutex init to OS versions needing it.
Iain Sandoe [Sat, 3 Dec 2022 17:09:35 +0000 (17:09 +0000)] 
libstdc++, Darwin: Limit recursive mutex init to OS versions needing it.

The problem described in pr 51906 was fixed in the next OS release.  Limit the
workaround to systems that need it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libstdc++-v3/ChangeLog:

* config/os/bsd/darwin/os_defines.h
(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC): Limit use of this macro
to OS versions that need it.

(cherry picked from commit a044c9d25972b22c6b4c8ec27f2de5fd622573cc)

12 days agoDaily bump.
GCC Administrator [Thu, 18 Apr 2024 00:20:12 +0000 (00:20 +0000)] 
Daily bump.

13 days agoDaily bump.
GCC Administrator [Wed, 17 Apr 2024 00:20:48 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Tue, 16 Apr 2024 00:20:27 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agomiddle-end/114599 - fix bitmap allocation for check_ifunc_callee_symtab_nodes
Richard Biener [Fri, 5 Apr 2024 08:16:41 +0000 (10:16 +0200)] 
middle-end/114599 - fix bitmap allocation for check_ifunc_callee_symtab_nodes

There's no default bitmap obstack during global CTORs, so allocate the
bitmap locally.

PR middle-end/114599
PR gcov-profile/114115
* symtab.cc (ifunc_ref_map): Do not use auto_bitmap.
(is_caller_ifunc_resolver): Optimize bitmap_bit_p/bitmap_set_bit
pair.
(symtab_node::check_ifunc_callee_symtab_nodes): Properly
allocate ifunc_ref_map here.

(cherry picked from commit 9ab8fdfeef5b1a47b358e08a98177b2fad65fed9)

2 weeks agotree-profile: Disable indirect call profiling for IFUNC resolvers
H.J. Lu [Mon, 26 Feb 2024 16:38:58 +0000 (08:38 -0800)] 
tree-profile: Disable indirect call profiling for IFUNC resolvers

We can't profile indirect calls to IFUNC resolvers nor their callees as
it requires TLS which hasn't been set up yet when the dynamic linker is
resolving IFUNC symbols.

Add an IFUNC resolver caller marker to cgraph_node and set it if the
function is called by an IFUNC resolver.  Disable indirect call profiling
for IFUNC resolvers and their callees.

Tested with profiledbootstrap on Fedora 39/x86-64.

gcc/ChangeLog:

PR tree-optimization/114115
* cgraph.h (symtab_node): Add check_ifunc_callee_symtab_nodes.
(cgraph_node): Add called_by_ifunc_resolver.
* cgraphunit.cc (symbol_table::compile): Call
symtab_node::check_ifunc_callee_symtab_nodes.
* symtab.cc (check_ifunc_resolver): New.
(ifunc_ref_map): Likewise.
(is_caller_ifunc_resolver): Likewise.
(symtab_node::check_ifunc_callee_symtab_nodes): Likewise.
* tree-profile.cc (gimple_gen_ic_func_profiler): Disable indirect
call profiling for IFUNC resolvers and their callees.

gcc/testsuite/ChangeLog:

PR tree-optimization/114115
* gcc.dg/pr114115.c: New test.

(cherry picked from commit cab32bacaea268ec062b1fb4fc662d90c9d1cfce)

2 weeks ago[AArch64]: remove ls64 from being mandatory on armv8.7-a
Tamar Christina [Mon, 15 Apr 2024 11:22:19 +0000 (12:22 +0100)] 
[AArch64]: remove ls64 from being mandatory on armv8.7-a

The Arm Architectural Reference Manual (Version J.a, section A2.9 on FEAT_LS64)
shows that ls64 is an optional extensions and should not be enabled by default
for Armv8.7-a.

This drops it from the mandatory bits for the architecture and brings GCC inline
with LLVM and the achitecture.

Note that we will not be changing binutils to preserve compatibility with older
released compilers.

gcc/ChangeLog:

* config/aarch64/aarch64.h (AARCH64_ARCH): Remove LS64 from
Armv8.7-a.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/acle/ls64.C: Add +ls64.
* g++.target/aarch64/acle/ls64_lto.C: Likewise.
* gcc.target/aarch64/acle/ls64_lto.c: Likewise.
* gcc.target/aarch64/acle/pr110100.c: Likewise.
* gcc.target/aarch64/acle/pr110132.c: Likewise.
* gcc.target/aarch64/pragma_cpp_predefs_2.c: Correct header checks.

2 weeks agoAArch64: Do not allow SIMD clones with simdlen 1 [PR113552]
Tamar Christina [Mon, 15 Apr 2024 11:16:53 +0000 (12:16 +0100)] 
AArch64: Do not allow SIMD clones with simdlen 1 [PR113552]

This is a backport of g:306713c953d509720dc394c43c0890548bb0ae07.

The AArch64 vector PCS does not allow simd calls with simdlen 1,
however due to a bug we currently do allow it for num == 0.

This causes us to emit a symbol that doesn't exist and we fail to link.

gcc/ChangeLog:

PR tree-optimization/113552
* config/aarch64/aarch64.cc
(aarch64_simd_clone_compute_vecsize_and_simdlen): Block simdlen 1.

gcc/testsuite/ChangeLog:

PR tree-optimization/113552
* gcc.target/aarch64/pr113552.c: New test.
* gcc.target/aarch64/simd_pcs_attribute-3.c: Remove bogus check.

2 weeks agoDaily bump.
GCC Administrator [Mon, 15 Apr 2024 00:19:51 +0000 (00:19 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Sun, 14 Apr 2024 00:20:13 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Sat, 13 Apr 2024 00:19:55 +0000 (00:19 +0000)] 
Daily bump.

2 weeks agoDarwin, configure: Allow for an unrecognisable dsymutil [PR111610].
Iain Sandoe [Wed, 27 Sep 2023 10:05:31 +0000 (11:05 +0100)] 
Darwin, configure: Allow for an unrecognisable dsymutil [PR111610].

We had a catch-all configuration case for missing or unrecognised dsymutil
but it was setting the dsymutil source to "UNKNOWN" which is not usable in
this context (since it clashes with an existing enum).  We rename this to
DET_UNKNOWN (for Darwin External Toolchain).

PR target/111610

gcc/ChangeLog:

* configure: Regenerate.
* configure.ac: Rename the missing dsymutil case to "DET_UNKNOWN".

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 2ecab2f32b9e9a75bf563f80752d5b44dcd26b98)

2 weeks agoDarwin,debug : Switch to DWARF 3 or 4 when dsymutil supports it.
Iain Sandoe [Sun, 17 Sep 2023 14:56:07 +0000 (15:56 +0100)] 
Darwin,debug : Switch to DWARF 3 or 4 when dsymutil supports it.

The main reason that Darwin has been using DWARF2 only as debug is that
earlier debug linkers (dsymutil) did not support any extensions to this
so that the default "non-strict" mode used in GCC would cause tool errors.

There are two sources for dsymutil, those based off a closed source base
"dwarfutils" and those based off LLVM.

For dsymutil versions based off LLVM-7+ we can use up to DWARF-4, and for
versions based on dwarfutils 121+ we can use DWARF-3.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin-protos.h (enum darwin_external_toolchain): New.
* config/darwin.cc (DSYMUTIL_VERSION): New.
(darwin_override_options): Choose the default debug DWARF version
depending on the configured dsymutil version.

(cherry picked from commit 47346acb72b50d178dae72393c851d57beec383f)

2 weeks agolibgcc, Darwin: No early install for the compatibility libgcc_s.1.dylib.
Iain Sandoe [Thu, 22 Dec 2022 17:32:06 +0000 (17:32 +0000)] 
libgcc, Darwin: No early install for the compatibility libgcc_s.1.dylib.

On Darwin, GCC now uses a libgcc_s.1.1 for builtins and forwards the system
unwinder.  We do, however, build a backwards compatibility libgcc_s.1.dylib.
However, this is not needed by GCC and can cause incorrect operation when
DYLD_LIBRARY_PATH is in use.

Since we do not need or use it during the build, the solution is to skip the
installation into the $build/gcc directory.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libgcc/ChangeLog:

* config/t-slibgcc-darwin (install-darwin-libgcc-stubs): Skip the
install of libgcc_s.1.dylib when the installation is into the build
gcc directory.

(cherry picked from commit 163f0f2267370575a9950e7e30a2c9cd72f559f0)

2 weeks agoc++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic.
Iain Sandoe [Thu, 6 Jan 2022 08:37:18 +0000 (08:37 +0000)] 
c++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic.

The current implementation for swapping between the static and shared c++
runtimes relies on the static linker supporting Bstatic/dynamic which is
not available for every target (Darwin's linker does not support this).

Specs substitution (%s) is an alternative solution for this (which is what
Darwin uses for Fortran, D and Objective-C).  However, specs substitution
requires that the '-static-libstdc++' be preserved in the driver's command
line.  The patch here arranges for this to be done when the configuration
determines that linker support for Bstatic/dynamic is missing.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/ChangeLog:

* g++spec.cc (lang_specific_driver): Preserve -static-libstdc++ in
the driver command line for targets without -Bstatic/dynamic support
in their static linker.

(cherry picked from commit a846817739c1e7b930d593cd51963d6b46b5dfc6)

2 weeks agoObjective-C, NeXT: Adjust symbol marking to match host tools.
Iain Sandoe [Mon, 2 May 2022 18:42:49 +0000 (19:42 +0100)] 
Objective-C, NeXT: Adjust symbol marking to match host tools.

Current host tools mark some additional symbols as 'no dead strip' and also
expose one additional group to the linker.  This does not affect older Darwin
versions or x86_64, but omitting these changes results in link errors for
aarch64.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin.cc (darwin_label_is_anonymous_local_objc_name): Make
protocol class methods linker-visible.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.cc (next_runtime_abi_02_protocol_decl): Do
not dead-strip the runtime meta-data symbols.
(build_v2_classrefs_table): Likewise.
(build_v2_protocol_list_address_table): Likewise.

(cherry picked from commit ecd5727c0a662a8fea6b5f8eac6f3f15bf5ef851)

2 weeks agoDaily bump.
GCC Administrator [Fri, 12 Apr 2024 00:19:56 +0000 (00:19 +0000)] 
Daily bump.

2 weeks agoRISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64
Kito Cheng [Wed, 28 Feb 2024 08:01:52 +0000 (16:01 +0800)] 
RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

atomic_compare_and_swapsi will use lr.w to do obtain the original value,
which sign extends to DI.  RV64 only has DI comparisons, so we also need
to sign extend the expected value to DI as otherwise the comparison will
fail when the expected value has the 32nd bit set.

gcc/ChangeLog:

PR target/114130
* config/riscv/sync.md (atomic_compare_and_swap<mode>): Sign
extend the expected value if needed.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr114130.c: New.

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
(cherry picked from commit fd07a29e39f5347d6cef3e7042a32306f97a1719)

2 weeks agoDaily bump.
GCC Administrator [Thu, 11 Apr 2024 00:19:51 +0000 (00:19 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Wed, 10 Apr 2024 00:19:35 +0000 (00:19 +0000)] 
Daily bump.

3 weeks agoDaily bump.
GCC Administrator [Tue, 9 Apr 2024 00:20:09 +0000 (00:20 +0000)] 
Daily bump.

3 weeks agoDaily bump.
GCC Administrator [Mon, 8 Apr 2024 12:17:40 +0000 (12:17 +0000)] 
Daily bump.

3 weeks agoFortran: fix DATA and derived types with pointer components [PR114474]
Harald Anlauf [Wed, 27 Mar 2024 20:18:04 +0000 (21:18 +0100)] 
Fortran: fix DATA and derived types with pointer components [PR114474]

When matching actual arguments in match_actual_arg, these are initially
treated as a possible dummy procedure, assuming that the correct type is
determined later.  This resolution could fail when the procedure is a
derived type constructor with a pointer component and appears in a DATA
statement, where the pointer shall be associated with an initial data
target.  Check for those cases where the type obviously has not been
resolved yet, and which were missed because there was no component
reference.

gcc/fortran/ChangeLog:

PR fortran/114474
* primary.cc (gfc_variable_attr): Catch variables used in structure
constructors within DATA statements that are still tagged with a
temporary type BT_PROCEDURE from match_actual_arg and which have the
target attribute, and fix their typespec.

gcc/testsuite/ChangeLog:

PR fortran/114474
* gfortran.dg/data_pointer_3.f90: New test.

(cherry picked from commit bbb7c513dddc5c9b2d5e9b78bc1c2f85a0cfe07e)

3 weeks agoDaily bump.
GCC Administrator [Fri, 5 Apr 2024 00:19:12 +0000 (00:19 +0000)] 
Daily bump.

3 weeks agoDarwin, fixincludes: Handle Apple Blocks in objc/runtime.h.
Iain Sandoe [Wed, 18 Jan 2023 23:25:36 +0000 (23:25 +0000)] 
Darwin, fixincludes: Handle Apple Blocks in objc/runtime.h.

The macOS 13 SDK has unguarded Apple Blocks use in objc/runtime.h which
causes most of the objective-c tests to fail.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
fixincludes/ChangeLog:

* fixincl.x: Regenerate.
* inclhack.def (darwin_objc_runtime_1): New hack.
* tests/base/objc/runtime.h: New file.

(cherry picked from commit 046dc9d0d4683bab99d28983d8841ba3c56ef744)

3 weeks agoDarwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations [PR107568].
Iain Sandoe [Wed, 18 Jan 2023 19:58:33 +0000 (19:58 +0000)] 
Darwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations [PR107568].

The SDK for MacOS13 includes Apple-specific deprecations of some functions that
are not deprecated in Posix, C or C++ and widely used in GCC.

The fix makes the deprecation conditional on __APPLE_LOCAL_DEPRECATIONS so that
end users may still observe them but they are hidden from normal compilations.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR target/107568

fixincludes/ChangeLog:

* fixincl.x: Regenerate.
* inclhack.def: Add a fix for MacOS13 SDK function deprecations
in stdio.h.
* tests/base/stdio.h (__deprecated_msg): New test.

(cherry picked from commit 442d2bdc1d2a98aba0b18aeaa3e87fa946ac8031)

3 weeks agoDarwin: Use -platform_version when available [PR110624].
Iain Sandoe [Thu, 13 Jul 2023 06:36:51 +0000 (07:36 +0100)] 
Darwin: Use -platform_version when available [PR110624].

Later versions of the static linker support a more flexible flag to
describe the OS, OS version and SDK used to build the code.  This
replaces the functionality of '-mmacosx_version_min' (which is now
deprecated, leading to the diagnostic described in the PR).

We now use the platform_version flag when available which avoids the
diagnostic.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR target/110624

gcc/ChangeLog:

* config/darwin.h (DARWIN_PLATFORM_ID): New.
(LINK_COMMAND_A): Use DARWIN_PLATFORM_ID to pass OS, OS version
and SDK data to the static linker.

(cherry picked from commit 032b5da1fc781bd3c23d9caa72fb09439e7f6f3a)

3 weeks agolibphobos, testsuite: Disable forkgc2 on Darwin [PR103944]
Iain Sandoe [Sun, 26 Feb 2023 13:53:52 +0000 (13:53 +0000)] 
libphobos, testsuite: Disable forkgc2 on Darwin [PR103944]

It hangs the testsuite (requiring manual intervention to kill the
spawned processes) which breaks CI.  The reason for the hang id not
clear.  This skips the test for now (xfail does not work).

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR d/103944

libphobos/ChangeLog:

* testsuite/libphobos.gc/forkgc2.d: Skip for Darwin.

(cherry picked from commit fca6d9c12f5bf06469cf9f7db8c42f66ef792fd2)

3 weeks agoDaily bump.
GCC Administrator [Thu, 4 Apr 2024 00:19:29 +0000 (00:19 +0000)] 
Daily bump.

3 weeks agoDaily bump.
GCC Administrator [Wed, 3 Apr 2024 00:19:32 +0000 (00:19 +0000)] 
Daily bump.

3 weeks agoFix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]
Qing Zhao [Thu, 29 Feb 2024 15:07:49 +0000 (15:07 +0000)] 
Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]

This is a bug in tree-ssa-math-opts.cc, when applying the widening mul
optimization, the compiler needs to check whether the operand is in a
ABNORMAL PHI, if YES, we should avoid the transformation.

PR tree-optimization/111407

gcc/ChangeLog:

* tree-ssa-math-opts.cc (convert_mult_to_widen): Avoid the transform
when one of the operands is subject to abnormal coalescing.

gcc/testsuite/ChangeLog:

* gcc.dg/pr111407.c: New test.

(cherry picked from commit 4aca1cfd6235090e48a53dab734437740671bbf3)

4 weeks agofortran: Ignore use statements on error [PR107426]
Mikael Morin [Thu, 21 Mar 2024 16:27:54 +0000 (17:27 +0100)] 
fortran: Ignore use statements on error [PR107426]

This fixes an access to freed memory on the testcase from the PR.
The problem comes from an invalid subroutine statement in an interface,
which is ignored and causes the following statements forming the procedure
body to be rejected.  One of them use-associates the intrinsic ISO_C_BINDING
module, which imports new symbols in a namespace that is freed at the time
the statement is rejected.  However, this creates dangling pointers as
ISO_C_BINDING is special and its import creates a reference to the imported
C_PTR symbol in the return type of the global intrinsic symbol for C_LOC
(see the function create_intrinsic_function).

This change saves and restores the list of use statements, so that rejected
use statements are removed before they have a chance to be applied to the
current namespace and create dangling pointers.

PR fortran/107426

gcc/fortran/ChangeLog:

* gfortran.h (gfc_save_module_list, gfc_restore_old_module_list):
New declarations.
* module.cc (old_module_list_tail): New global variable.
(gfc_save_module_list, gfc_restore_old_module_list): New functions.
(gfc_use_modules): Set module_list and old_module_list_tail.
* parse.cc (next_statement): Save module_list before doing any work.
(reject_statement): Restore module_list to its saved value.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr89943_3.f90: Update error pattern.
* gfortran.dg/pr89943_4.f90: Likewise.
* gfortran.dg/use_31.f90: New test.

(cherry picked from commit a44d7e8a52007c2d45217709ca02947c6600de87)