Commit Graph

179015 Commits

Author SHA1 Message Date
Jonathan Wakely 6b59f8acad libstdc++: Fix test that fails on Solaris [PR104731]
On Solaris the dirent::d_name member is a single char, causing this test
to fail with warnings about buffer overflow. Change the test to use a
union with additional space for writing a string to the d_name member.

libstdc++-v3/ChangeLog:

	PR libstdc++/104731
	* testsuite/27_io/filesystem/iterators/error_reporting.cc:
	Use a trailing char array as storage for dirent::d_name.

(cherry picked from commit aa8bdfee1d)
2022-06-15 09:12:24 +01:00
Jonathan Wakely 401fbbbda2 libstdc++: Do not use dirent::d_type unconditionally
These new tests should not use the d_type member unless it's actually
present on the OS.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
	autoconf macro to check whether d_type is present.
	* testsuite/experimental/filesystem/iterators/error_reporting.cc:
	Likewise.

(cherry picked from commit d98668eb06)
2022-06-15 09:12:23 +01:00
Jonathan Wakely 92d5f0c71e libstdc++: Reset filesystem::recursive_directory_iterator on error
The standard requires directory iterators to become equal to the end
iterator value if they report an error. Some members functions of
filesystem::recursive_directory_iterator fail to do that.

libstdc++-v3/ChangeLog:

	* src/c++17/fs_dir.cc (recursive_directory_iterator::increment):
	Reset state to past-the-end iterator on error.
	(fs::recursive_directory_iterator::pop(error_code&)): Likewise.
	(fs::recursive_directory_iterator::pop()): Check _M_dirs before
	it might get reset.
	* src/filesystem/dir.cc (recursive_directory_iterator): Likewise,
	for the TS implementation.
	* testsuite/27_io/filesystem/iterators/error_reporting.cc: New test.
	* testsuite/experimental/filesystem/iterators/error_reporting.cc: New test.

(cherry picked from commit ec09a5335f)
2022-06-15 09:12:23 +01:00
Jonathan Wakely 884424353e libstdc++: Backport tests for associative container move constructors
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/map/allocator/move_cons.cc: New test.
	* testsuite/23_containers/multimap/allocator/move_cons.cc: New test.
	* testsuite/23_containers/multiset/allocator/move_cons.cc: New test.
	* testsuite/23_containers/set/allocator/move_cons.cc: New test.
2022-06-15 09:12:23 +01:00
Jonathan Wakely d4fdb29300 libstdc++: Clear RB tree after moving elements [PR103501]
If the allocator-extended move constructor move-constructs each element
into the new container, the contents of the old container are left in
moved-from states. We cannot know if those states preserve the
container's ordering and uniqueness guarantees, so just erase all
moved-from elements.

libstdc++-v3/ChangeLog:

	PR libstdc++/103501
	* include/bits/stl_tree.h (_Rb_tree(_Rb_tree&&, false_type)):
	Clear container if elements have been moved-from.
	* testsuite/23_containers/multiset/allocator/103501.cc: New test.
	* testsuite/23_containers/set/allocator/103501.cc: New test.

(cherry picked from commit 056551414a)
2022-06-15 09:12:09 +01:00
GCC Administrator 24551c8642 Daily bump. 2022-06-15 00:17:31 +00:00
Jonathan Wakely 29b676bcf1 libstdc++: Disable failing test [PR97944]
Disable this test on the branch. It's already disabled for gcc-11 and
later.

libstdc++-v3/ChangeLog:

	PR libstdc++/97944
	* testsuite/30_threads/jthread/95989.cc: Mark XFAIL.
2022-06-14 20:25:29 +01:00
Jonathan Wakely 78f3899e5d libstdc++: Run all tests in file
libstdc++-v3/ChangeLog:

	* testsuite/30_threads/jthread/95989.cc: Run all three test
	functions, not just the first one twice.

(cherry picked from commit 7e0078f864)
2022-06-14 20:23:46 +01:00
Jonathan Wakely 43cbff3da5 libstdc++: Fix error reporting in filesystem::copy [PR99290]
The recursive calls to filesystem::copy should stop if any of them
reports an error.

libstdc++-v3/ChangeLog:

	PR libstdc++/99290
	* src/c++17/fs_ops.cc (fs::copy): Pass error_code to
	directory_iterator constructor, and check on each iteration.
	* src/filesystem/ops.cc (fs::copy): Likewise.
	* testsuite/27_io/filesystem/operations/copy.cc: Check for
	errors during recursion.
	* testsuite/experimental/filesystem/operations/copy.cc:
	Likewise.

(cherry picked from commit 4e117418fb)
2022-06-14 20:20:03 +01:00
Jonathan Wakely 1d2336f846 libstdc++: Add xfail to pretty printer tests that fail in C++20
For some reason the type printer for std::string doesn't work in C++20
mode, so std::basic_string<char, char_traits<char>, allocator<char> is
printed out in full rather than being shown as std::string. It's
probably related to the fact that the extern template declarations are
disabled for C++20, but I don't know why that affects GDB.

For now I'm just marking the relevant tests as XFAIL. That requires
adding support for target selectors to individual GDB directives such as
note-test and whatis-regexp-test.

libstdc++-v3/ChangeLog:

	* testsuite/lib/gdb-test.exp: Add target selector support to the
	dg-final directives.
	* testsuite/libstdc++-prettyprinters/80276.cc: Add xfail for
	C++20.
	* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/prettyprinters.exp: Tweak
	comment.

(cherry picked from commit 30b8ec68e2)
2022-06-14 20:20:03 +01:00
Jakub Jelinek 4c6e66a4db testsuite: Fix up pr104637 testcase [PR104637]
This testcase FAILs everywhere for 3 reasons:
1) the testcase can't work on ia32, where sizeof (long double) == 12
   and as it is not a power of 2, we disallow creating vectors with such
   elements, -mx32 and -m64 are fine
2) the testcase emits a lot of -Wdiv-by-zero warnings, I've just added
   -Wno-div-by-zero to dg-options
3) my fault, when tweaking the testcase I've missed 33 initializers of
   a 32 element vector which didn't change anything on the ICE, but is
   still reported

This patch fixes all of it, tested with
RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=pr104637.c'
both without the LRA fix where it ICEs and with it where it passes
everywhere.

2022-03-02  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/104637
	* gcc.target/i386/pr104637.c: Don't run on ia32.  Add -Wno-div-by-zero
	to dg-options.
	(foo): Remove extraneous initializer.
2022-06-14 11:49:38 -04:00
Vladimir N. Makarov 6887035690 [PR104637] LRA: Split hard regs as many as possible on one subpass
LRA hard reg split subpass is a small subpass used as the last
resort for LRA when it can not assign a hard reg to a reload
pseudo by other ways (e.g. by spilling non-reload pseudos).  For
simplicity the subpass works on one split base (as each split
changes pseudo live range info).  In this case it results in
reaching maximal possible number of subpasses.  The patch
implements as many non-overlapping hard reg splits
splits as possible on each subpass.

gcc/ChangeLog:

	PR rtl-optimization/104637
	* lra-assigns.c (lra_split_hard_reg_for): Split hard regs as many
	as possible on one subpass.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/104637
	* gcc.target/i386/pr104637.c: New.
2022-06-14 11:49:24 -04:00
GCC Administrator 2c12aaed1f Daily bump. 2022-06-14 00:17:32 +00:00
Marek Polacek f2851a7cff rtl: ICE with thread_local and inline asm [PR104777]
In r270550, Jakub fixed classify_insn to handle asm goto: if the asm can
jump to a label, the insn should be a JUMP_INSN.

However, as the following testcase shows, non-null ASM_OPERANDS_LABEL_VEC
doesn't guarantee that the rtx has any actual labels it can branch to.
Here, the rtvec has 0 elements because expand_asm_stmt created it:

  rtvec labelvec = rtvec_alloc (nlabels); // nlabels == 0

This causes an ICE in update_br_prob_note: BRANCH_EDGE (bb) crashes
because there's no branch edge.  I think we can fix this by checking
that there is at least one label the asm can jump to before wrapping
the ASM_OPERANDS in a JUMP_INSN.

	PR rtl-optimization/104777

gcc/ChangeLog:

	* rtl.c (classify_insn): For ASM_OPERANDS, return JUMP_INSN only if
	ASM_OPERANDS_LABEL_VEC has at least one element.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/tls/pr104777.c: New test.

(cherry picked from commit e1133c0205)
2022-06-13 12:29:10 -04:00
GCC Administrator 8f0d133879 Daily bump. 2022-06-13 00:17:26 +00:00
GCC Administrator d49d25d86e Daily bump. 2022-06-12 00:17:30 +00:00
GCC Administrator c96c73316b Daily bump. 2022-06-11 00:17:25 +00:00
Jonathan Wakely f2385d1fe9 libstdc++: Partially revert r11-9772-g6f8133689f4397 [PR105915]
The r11-9772-g6f8133689f4397 backport made two changes, but only one was
needed on the gcc-11 branch. The other should not have been backported,
and causes errors with clang. This removes the unwanted part.

libstdc++-v3/ChangeLog:

	PR libstdc++/105915
	* include/experimental/bits/fs_path.h (path::begin, path::end):
	Remove noexcept from declarations.

(cherry picked from commit 60c8470703)
2022-06-10 15:26:28 +01:00
GCC Administrator 44a4c6f5e4 Daily bump. 2022-06-10 00:17:37 +00:00
Iain Sandoe 9f6a1fefe9 Jit, testsuite: Amend expect processing to tolerate more platforms.
The current 'fixed_host_execute' implementation fails on Darwin
platforms for a number of reasons:

1/ If the sub-process spawn fails (e.g. because of missing or mal-
   formed params); rather than reporting the fail output into the
   match stream, as indicated by the expect manual, it terminates
   the script.

 - We fix this by (a) checking that the executable is valid as well
   as existing (b) we put the spawn into a catch block and report
   a failure.

2/ There is no recovery path at all for a buffer-full case (and we
   do see buffer-full events with the default sizes).

 - Added by the patch here, however it is not as sophisticated as
   the methods used by dejagnu internally.  Here we set the process
   to be "nowait" and then close the connection - with the intent
   that this will terminate the spawned process.

3/  The expect logic assumes that 'Totals:' is a valid indicator
    for the end of the spawned process output.  This is not true
    even for the default dejagnu header (there are a number of
    additional reporting lines after).  In addition to this, there
    are some tests that intentionally produce more output after
    the totals report (and there are tests that do not use that
    mechanism at all).

    The effect is the we might arrive at the "wait" for the spawned
    process to finish - but that process might not have completed
    all its output.  For Darwin, at least that causes a deadlock
    between expect and the spawnee - the latter is doing a non-
    cancellable write and the former is waiting for the latter to
    terminate.  For some reason this does not seem to affect Linux
    perhaps the pty implementation allows the write(s) are able to
    proceed even though there is no reader.

 -  This is fixed by modifying the loop termination condition to be
    either EOF (which will be the 'correct' condition) or a timeout
    which would represent an error either in the runtime or in the
    parsing of the output.  As added precautions, we only try to
    wait if there is a correcly-spawned process, and we are also
    specific about which process we are waiting for.

4/  Darwin appears to have a bug in either the tcl or termios
    'cooking' code that ocassionally inserts an additional CR char
    into the stream - thus '\n' => '\r\r\n' instead of '\r\n'. The
    original program output is correct (it only contains a single
    \n) - the additional character is being inserted somewhere in
    the translations applied before the output reaches expect.

    The logic of this expect implementation does not tolerate single
    \r or \n characters (it will fail with a timeout or buffer-full
    if that occurs).

 -  This is fixed by having a line-end match that is adjusted for
    Darwin.

5/  The default buffer size does seem to be too small in some cases
    noting that GCC uses 10000 as the match buffer size and the
    default is 2000.

 -  Fixed by increasing the size to 8192.

6/  There is a somewhat arbitrary dumping of output where we match
    ^$prefix\tSOMETHING... and then process the something.  This
    essentially allows the match to start at any place in the buffer
    following any collection of non-line-end chars.

 -  Fixed by amending the match for 'general' lines to accommodate
    these cases, and reporting such lines to the log.  At least this
    should allow debugging of any cases where output that should be
    recognized is being dropped.

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

gcc/testsuite/ChangeLog:

	* jit.dg/jit.exp (fixed_local_execute): Amend the match and
	exit conditions to cater for more platforms.
	* lib/target-supports.exp: Add support for checking that the
	jit lib is usable on the target.

(cherry picked from commit 124c354ad7)
2022-06-09 20:24:04 +01:00
Iain Sandoe d75b8abc7b JIT, testsuite, Darwin: Initial testsuite fixes.
The testsuite setup for jit is not compatible with Darwin since it
assumes that all targets support --export-dynamic.

 - this is fixed by adding '-rdynamic' conditionally upon target
   support for that (-rdynamic will be converted to the appropriate
   linker option).

There is also an assumption that a suitable version of dejagnu.h
is present in some default include search path that is usable from
the testsuite.  This is not the case for Darwin (dejagnu.h is not
installed, and would not, in general, be found in any default include
search path if installed via one of the main 'distros').  Also the
upstream dejagnu.h has a definition of 'wait()' that clashes with a
libc routines and therefore causes fails in the testsuite.

 - This patch imports the header from dejagnu-1.6.2 and
   * renames it to 'jit-dejagnu.h'
   * patches it to avoid unused variable warnings and the clash
     with the libc definition of wait ()
   * In accordance with the advice in the expect man page, ensures
     that the final output of the 'totals' print is stable.

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

gcc/jit/ChangeLog:

	* docs/examples/tut04-toyvm/toyvm.c: Include jit-dejagnu.h.
	* docs/examples/tut04-toyvm/toyvm.cc: Likewise.
	* jit-dejagnu.h: New file, imported from dejagnu-1.6.2 and
	patched for this application.

gcc/testsuite/ChangeLog:

	* jit.dg/harness.h: Include jit-dejagnu.h.
	* jit.dg/jit.exp: Use -rdynamic conditionally on target
	support, instead of unconditional -Wl,--export-dynamic.

(cherry picked from commit eea1677fd0)
2022-06-09 20:23:05 +01:00
Iain Sandoe e1f99a4b05 Darwin, jit: Fix build [PR100613].
The generic unix build is not completely suitable for Darwin
platforms:

 * It is a convention to encode the library versioning in the
   binary and to have only one level of symlink for the installed
   files. This needs to be applied to the installation too.
 * The library needs to be built with its correct install name
   so that two-level library naming works.
 * The extension for shared libraries should be .dylib

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

PR jit/100613 - libgccjit should produce dylib on macOS

	PR jit/100613

gcc/jit/ChangeLog:

	* Make-lang.in: Provide clauses for Darwin hosts.

(cherry picked from commit 08defd9c4e)
2022-06-09 20:22:38 +01:00
Iain Sandoe 2ac862bf33 configure: Avoid unnecessary constraints on executables for $build.
The executables for GCC's c-family compilers must be built with no-PIE
because they use PCH and the current model for this requires that the
exe is always lauched at the same address.  Since the other language
compilers share code with the c-family this constraint is also applied
to them.

However, the executables that run on $build (generators, and parsers
for md and def files) need not have any such constraint they do not
consume PCH files.

This change simplifies the configuration and Makefile content by
removing the code enforcing no-PIE on these exes.  This also fixes a
bootstrap issue with some Darwin versions and clang as the bootstrap
compiler,  where -no-PIE causes the correct relocation model to be
switched off leading to invalid user-space code.

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

gcc/ChangeLog:

	* Makefile.in: Remove variables related to applying no-PIE
	to the exes on $build.
	* configure: Regenerate.
	* configure.ac: Remove configuration related to applying
	no-PIE to the exes on $build.

(cherry picked from commit fb32372651)
2022-06-09 20:22:11 +01:00
GCC Administrator 78a015199a Daily bump. 2022-06-09 00:17:31 +00:00
GCC Administrator 2330ffebac Daily bump. 2022-06-08 00:17:27 +00:00
GCC Administrator 474060adad Daily bump. 2022-06-07 00:17:29 +00:00
Alan Modra 9ed3943385 [RS6000] altivec style lvx/stvx addresses vs power10
gcc.target/powerpc/fold-vec-st-pixel.c and other testcases fail on
power10, generating
	addi 9,5,12
	rldicr 9,9,0,59
	stxv 34,0(9)
rather than
	addi 5,5,12
	stvx 2,0,5
for an altivec lvx/stvx style address.

The problem starts with fwprop creating
(insn 9 4 0 2 (set (mem:V8HI (and:DI (plus:DI (reg/v/f:DI 121 [ vpp ])
                    (const_int 12 [0xc]))
                (const_int -16 [0xfffffffffffffff0])) [0 MEM <vector(8) short int> [(void *)_4 & -16B]+0 S16 A128])
        (reg/v:V8HI 120 [ vp1 ])) "pixel.c":6:10 1237 {vsx_movv8hi_64bit}
which is finally thrown out as invalid by lra.  lra of course does that
by reloading the entire address.

fwprop creates the invalid address due to rs6000_legitimate_address_p
trimming off the outer AND of altivec style addresses before applying
other predicates.  address_is_prefixed then allows the inner address.

Now at the time the AND stripping was added (git commit 850e8d3d56),
rs6000_legitimate_address looked a lot simpler.  This patch allows
through just those addresses that were legitimate in those simpler
days.

	* config/rs6000/rs6000.c (rs6000_legitimate_address_p): Limit
	AND addressing to just lvx/stvx style addresses.

(cherry picked from commit d0e2ffcca0)
2022-06-06 10:35:18 -05:00
GCC Administrator 2675727046 Daily bump. 2022-06-06 00:17:14 +00:00
GCC Administrator 5ed9acb780 Daily bump. 2022-06-05 00:17:29 +00:00
GCC Administrator 3d50a59ffd Daily bump. 2022-06-04 00:17:15 +00:00
GCC Administrator 2827b5e547 Daily bump. 2022-06-02 00:17:23 +00:00
GCC Administrator cb42926a7c Daily bump. 2022-06-01 00:17:30 +00:00
Patrick Palka 656cd10436 libstdc++: invalid default init in _CachedPosition [PR101231]
The primary template for _CachedPosition is a dummy implementation for
non-forward ranges, the iterators for which generally can't be cached.
Because this implementation doesn't actually cache anything, _M_has_value
is defined to be false and so calls to _M_get (which are always guarded
by _M_has_value) are unreachable.

Still, to suppress a "control reaches end of non-void function" warning
I made _M_get return {}, but after P2325 input iterators are no longer
necessarily default constructible so this workaround now breaks valid
programs.

This patch fixes this by instead using __builtin_unreachable to squelch
the warning.

	PR libstdc++/103904
	PR libstdc++/101231

libstdc++-v3/ChangeLog:

	* include/std/ranges (_CachedPosition::_M_get): For non-forward
	ranges, just call __builtin_unreachable.
	* testsuite/std/ranges/istream_view.cc (test05): New test.

(cherry picked from commit 1af937eb62)
2022-05-31 14:38:14 -04:00
Patrick Palka 22b86cdc4d libstdc++: Implement P2325 changes to default-constructibility of views
NB: This backport of r12-1606 to the 10 branch deliberately omits parts
of P2325R3 so as to maximize backward compatibility with pre-P2325R3 code.
In particular, we don't remove the default ctors for back_insert_iterator,
front_insert_iterator, ostream_iterator, ref_view and basic_istream_view.
And in the 10 branch we we don't have __non_propagating_cache or the
partial specialization of __box, so the changes to them are omitted too.
Finally, we don't update __cpp_lib_ranges to 202106L because many
significant 202106 Ranges changes still aren't implemented in the 10
branch, e.g. P2281R1 and P2210R2.

===

This implements the wording changes of P2325R3 "Views should not be
required to be default constructible".  Changes are relatively
straightforward, besides perhaps those to __box (which now stands
for copyable-box instead of semiregular-box) and __non_propagating_cache.

For __box, this patch implements the recommended practice to also avoid
std::optional when the boxed type is nothrow_move/copy_constructible.

For __non_propagating_cache, now that it's used by split_view::_M_current,
we need to add assignment from a value of the underlying type to the
subset of the std::optional API implemented for the cache (needed by
split_view::begin()).  Hence the new __non_propagating_cache::operator=
overload.

In passing, this fixes the undesirable list-init in the constructors of
the partial specialization of __box as reported in PR100475 comment #7.

	PR libstdc++/103904

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (weakly_incrementable): Remove
	default_initializable requirement.
	* include/bits/stl_iterator.h (common_iterator): Constrain the
	default ctor.
	(counted_iterator): Likewise.
	* include/std/ranges (ranges::view): Remove default_initializable
	requirement.
	(subrange): Constrain the default ctor.
	(__detail::__box::operator=): Handle self-assignment.
	(single_view): Constraint the default ctor.
	(iota_view): Relax semiregular constraint to copyable.
	Constrain the default ctor.
	(iota_view::_Iterator): Constraint the default ctor.
	(filter_view): Likewise.
	(filter_view::_Iterator): Likewise.
	(transform_view): Likewise.
	(transform_view::_Iterator): Likewise.
	(take_view): Likewise.
	(take_view::_Iterator): Likewise.
	(take_while_view): Likewise.
	(take_while_view::_Iterator): Likewise.
	(drop_while_view): Likewise.
	(drop_while_view::_Iterator): Likewise.
	(join_view): Likewise.
	(split_view): Constrain the default ctor.
	(common_view): Likewise.
	(reverse_view): Likewise.
	(elements_view): Likewise.
	(elements_view::_Iterator): Likewise.
	* include/std/span (enable_view<span<_ElementType, _Extent>>):
	Define this partial specialization to true unconditionally.
	* testsuite/std/ranges/p2325.cc: New test.
	* testsuite/std/ranges/single_view.cc (test06): New test.
	* testsuite/std/ranges/view.cc: Adjust now that view doesn't
	require default_initializable.

(cherry picked from commit 4b4f5666b4)
2022-05-31 14:38:11 -04:00
Iain Sandoe 903c18c65c Objective-C, NeXT: Fix messenging non-aggregate return-in-memory.
When a method returns a type that the platform ABI says should be
returned in memory, and that is done by a hidden 'sret' parameter,
the message send calls must be adjusted to inform the runtime that
the sret parameter is present.  As reported in the PR, this is not
working for non-aggregate types that use this mechanism.  The fix
here is to adjust the logic such that all return values that flag
'in memory' are considered to use the mechanism *unless* they
provide a struct_value_rtx *and* the return object is an aggregate.

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

PR objc/101718 - Objective-C frontend emits wrong code to call methods returning scalar types returned in memory

	PR objc/101718

gcc/objc/ChangeLog:

	* objc-next-runtime-abi-02.c (build_v2_build_objc_method_call):
	Revise for cases where scalar objects use an sret parameter.
	(next_runtime_abi_02_build_objc_method_call): Likwise.

(cherry picked from commit 1cef3039b8)
2022-05-31 19:32:31 +01:00
Iain Sandoe 5f75e80ecb [PATCH] Objective-C: NeXT runtime fixes.
The NeXT runtime has changed ABI in detail a number of times over Darwin
revisions from 9 to 21.  For the most part, the tools are tolerant of use
of older ABI revisions - for X86.  However for Arm64 deviations cause
link time errors.  This is small set of updates to match the system tools.

1. Objective-C: Addess a FIXME (NFC).

This removes references to the next runtime from the gnu runtime
implementation.

2. Objective-C, Darwin : Use special string sections for V2 NeXT runtime.

Newer versions of the runtime expect to find strings for class, method
and method types in set-aside sections rather than the general c_strings
one.

3. Ojective-C, Darwin : Adjust category superclass ref names (NFC).

Make the order of the class and superclass match the metadata
order from clang.  Makes it easier to compare produced meta-
data between implementations.

4. Objective-C: Default flag_objc_sjlj_exceptions off for NeXT ABI >= 2.

As per description.

5. Objective-C, NeXT runtime: Correct the default for fobjc-nilcheck.

It is intended that the default for the NeXT runtime at ABI 2 is to
check for nil message receivers.  This updates this to match the
documented behaviour and to match the behaviour of the system tools.

6. Objective-C, NeXT: Reorganise meta-data declarations.

This moves the GTY declaration of the meta-data indentifier
array into the header that enumerates these and provides
shorthand defines for them.  This avoids a problem seen with
a relocatable PCH implementation.

7. 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.

Backported from commits 900c0ca226,
a788c4555c,
1174b08b14,
798666392b,
de0b250b2b,
c9419faef0 and
ecd5727c0a

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Signed-off-by: Matt Jacobson <mhjacobson@me.com>

gcc/c-family/ChangeLog:

	* c-opts.c (c_common_post_options): Default to
	flag_objc_sjlj_exceptions = 1 only when flag_objc_abi < 2.

gcc/ChangeLog:

	* config/darwin-sections.def (objc2_class_names_section,
	objc2_method_names_section, objc2_method_types_section): New
	* config/darwin.c (output_objc_section_asm_op): Output new
	sections.  (darwin_objc2_section): Select new sections where
	used.
	(darwin_label_is_anonymous_local_objc_name): Make
	protocol class methods linker-visible.

gcc/objc/ChangeLog:

	* objc-next-metadata-tags.h (objc_rt_trees): Declare here.
	* objc-next-runtime-abi-01.c: Remove from here.
	(generate_static_references): Likewise.
	* objc-next-runtime-abi-02.c: Likewise.
	(objc_next_runtime_abi_02_init): Warn about and reset
	flag_objc_sjlj_exceptions regardless of flag_objc_exceptions.
	(next_runtime_02_initialize): Use a checking assert that
	flag_objc_sjlj_exceptions is off.
	(next_runtime_abi_02_category_decl): Adjust category
	superclass name ordering.
	(next_runtime_abi_02_init_metadata_attributes): Attach metadata
	for the special string sections to class, method and method type
	string sections.
	(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.
	(objc_next_runtime_abi_02_init): Default receiver nilchecks on.
	* objc-runtime-shared-support.c: Reorder headers, provide
	a GTY declaration the definition of objc_rt_trees.
	* objc-gnu-runtime-abi-01.c
	(build_shared_structure_initializer): Remove references to
	the NeXT runtime.
2022-05-31 19:27:05 +01:00
Iain Sandoe 5dd5507265 C-family : Fix a C++ ODR violation [PR97854].
The changes in r11-4799 introduced a dummy enum rid type with
a different initial member name to the actual version (an ODR
violation).  Fixed by including the header declaring the
actual type.

gcc/c-family/ChangeLog:

	PR objc/97854
	* stub-objc.c: Include c-common.h to declare enum rid.

(cherry picked from commit 814e016318)
2022-05-31 19:13:15 +01:00
GCC Administrator 27621da273 Daily bump. 2022-05-31 00:17:25 +00:00
GCC Administrator 9ef03b0a42 Daily bump. 2022-05-30 00:17:28 +00:00
Iain Sandoe 16db663772 IPA: Provide a mechanism to register static DTORs via cxa_atexit.
For at least one target (Darwin) the platform convention is to
register static destructors (i.e. __attribute__((destructor)))
with __cxa_atexit rather than placing them into a list that is
run by some other mechanism.

This patch provides a target hook that allows a target to opt
into this and handling for the process in ipa_cdtor_merge ().

When the mode is enabled (dtors_from_cxa_atexit is set) we:

 * Generate new CTORs to register static destructors with
   __cxa_atexit and add them to the existing list of CTORs;
   we then process the revised CTORs list.

 * We sort the DTORs into priority and then TU order, this
   means that they are registered in that order with
   __cxa_atexit () and therefore will be run in the reverse
   order.

 * Likewise, CTORs are sorted into priority and then TU order,
   which means that they will run in that order.

This matches the behavior of using init/fini (or
mod_init_func/mod_term_func) sections.

This also fixes a bug where Fortran needs a DTOR to be run to
close IO.

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

	PR fortran/102992

gcc/ChangeLog:

	* config/darwin.h (TARGET_DTORS_FROM_CXA_ATEXIT): New.
	* doc/tm.texi: Regenerated.
	* doc/tm.texi.in: Add TARGET_DTORS_FROM_CXA_ATEXIT hook.
	* ipa.c (cgraph_build_static_cdtor_1): Return the built
	function decl.
	(build_cxa_atexit_decl): New.
	(build_dso_handle_decl): New.
	(build_cxa_dtor_registrations): New.
	(compare_cdtor_tu_order): New.
	(build_cxa_atexit_fns): New.
	(ipa_cdtor_merge): If dtors_from_cxa_atexit is set,
	process the DTORs/CTORs accordingly.
	(pass_ipa_cdtor_merge::gate): Also run if
	dtors_from_cxa_atexit is set.
	* target.def (dtors_from_cxa_atexit): New hook.

(cherry picked from commit fabe8cc41e)
2022-05-29 20:15:08 +01:00
Iain Sandoe 3b0ee45cf6 libstdc++, testsuite, Darwin : Adjust for names used in system headers.
For all current Darwin SDKs inttypes.h has:
extern intmax_t imaxabs(intmax_t j);

So we need to exclude j from the defined test symbols.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Exclude j from the list
	of test symbols for Darwin.

(cherry picked from commit 6f4b0ff2b1)
2022-05-29 20:14:28 +01:00
Richard Biener 1badc4b94e add missing dg-require alias to gcc.dg/torture/pr100786.c
2022-03-28  Richard Biener  <rguenther@suse.de>

	* gcc.dg/torture/pr100786.c: Add dg-require alias.

(cherry picked from commit f6819b7fea)
2022-05-29 20:14:07 +01:00
Iain Sandoe dac09c7290 Darwin, testsuite : Prune 'object file not found for object'.
This is not a GCC problem, but a fault in the static linker where,
when a source file is used multiple times, with conditional compilation
the source file is only referenced by the linker for the first object.
Then, when dsymutil tries to find the source file for next object based
off that source there is no record for it.

gcc/testsuite/ChangeLog:

	* lib/prune.exp: Prune useless output caused by a linker bug.

(cherry picked from commit 0d737ed217)
2022-05-29 20:13:48 +01:00
Iain Sandoe acd300cfdc Objective-C: fix crash with -fobjc-nilcheck
When -fobjc-nilcheck is enabled, messages that result in a struct type should
yield a zero-initialized struct when sent to nil.  Currently, the frontend
crashes when it encounters this situation.  This patch fixes the crash by
generating the tree for the `{}` initializer.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Matt Jacobson  <mhjacobson@me.com>

	PR objc/101666

gcc/objc/ChangeLog:

	* objc-act.c (objc_build_constructor): Handle empty constructor
	lists.
	* objc-next-runtime-abi-02.c (build_v2_objc_method_fixup_call):
	Handle nil receivers.
	(build_v2_build_objc_method_call): Likewise.

gcc/testsuite/ChangeLog:

	* obj-c++.dg/pr101666-0.mm: New test.
	* obj-c++.dg/pr101666-1.mm: New test.
	* obj-c++.dg/pr101666.inc: New.
	* objc.dg/pr101666-0.m: New test.
	* objc.dg/pr101666-1.m: New test.
	* objc.dg/pr101666.inc: New.

(cherry picked from commit d2aa4e0b3b)
2022-05-29 20:13:27 +01:00
Iain Sandoe b6a762bf46 Darwin, X86: Adjust call clobbers to allow for lazy-binding [PR 100152].
We allow public functions defined in a TU to bind locally for PIC
code (the default) on 64bit Mach-O.

If such functions are not inlined, we cannot tell at compile-time if
they might be called via the lazy symbol resolver (this can depend on
options given at link-time).  Therefore, we must assume that the lazy
resolver could be used which clobbers R11 and R10.

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

gcc/ChangeLog:

	PR target/100152
	* config/i386/i386-expand.c (ix86_expand_call): If a call is
	to a non-local-binding, or local but to a public symbol, then
	assume that it might be indirected via the lazy symbol binder.
	Mark R10 and R10 as clobbered in that case.

(cherry picked from commit 41bd1b1903)
2022-05-29 20:13:08 +01:00
Iain Sandoe cfad91385a Darwin, rs6000: Amend lo_sum use for forced constants [PR104117].
Two issues resulted in this PR, which manifests when we force a constant into
memory in LRA (in PIC code on Darwin).  The presence of such forced constants
is quite dependent on other RTL optimisations, and it is easy for the issue to
become latent for a specific case.

First, in the Darwin-specific rs6000 backend code, we were not being careful
enough in rejecting invalid symbolic addresses.  Specifically, when generating
PIC code, we require a SYMBOL_REF to be wrapped in an UNSPEC_MACHOPIC_OFFSET.

We now split the Darwin high/low selectors into two:
 1. One that handles non-PIC addresses (kernel mode, mdynamic-no-pic).
 2. One that handles PIC addresses and rejects SYMBOL_REFs unless they are
    suitably wrapped in the MACHOPIC_OFFSET unspec.

The second case is handled by providing a new predicate (macho_pic_address)
that checks the requirements.

Backported from 4c3792d448 and
f1b3e38533

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Vladimir Makarov <vmakarov@redhat.com>

	PR target/104117

gcc/ChangeLog:

	* config/rs6000/rs6000.c (darwin_rs6000_legitimate_lo_sum_const_p):
	Check for UNSPEC_MACHOPIC_OFFSET wrappers on symbolic addresses when
	emitting PIC code.
	(legitimate_lo_sum_address_p): Likewise.
	(rs6000_legitimize_address): Do not apply the TLS processing to
	Darwin.
	* config/rs6000/darwin.md (@machopic_high_<mode>): New.
	(@machopic_low_<mode>): New.
	* config/rs6000/predicates.md (macho_pic_address): New.
2022-05-29 20:12:47 +01:00
Iain Sandoe bf41b26f58 Darwin: Rework handling for unwinder code in libgcc_s and specs [PR80556].
This addresses a long-standing problem where a work-around for an unwinder
issue (also a regression) regresses other functionality.  The patch replaces
several work-arounds with a fix for PR80556 and a work-around for PR88590.

* The fix for PR80556 requires a bump to the SO name for libgcc_s, since we
need to remove the unwinder symbols from it.  This would trigger PR88590
hence the work-around for that.

* We weaken the symbols for emulated TLS support so that it is possible
for a DSO linked with static-libgcc to interoperate with a DSO linked with
libgcc_s.  Likewise main exes.

* We remove all the gcc-4.2.1 era stubs machinery and workarounds.

* libgcc is always now linked ahead of libc, which avoids fails where the
libc (libSystem) builtins implementations are not up to date.

* The unwinder now always comes from the system
 - for Darwin9 from /usr/lib/libgcc_s.1.dylib
 - for Darwin10 from /usr/lib/libSystem.dylib
 - for Darwin11+ from /usr/lib/system/libunwind.dylib.

 We still insert a shim on Darwin10 to fix an omitted unwind function, but
 the underlying unwinder remains the system one.

* The work-around for PR88590 has two parts (1) we always link libgcc from
its convenience lib on affected system versions (avoiding the need to find
the DSO path); (2) we add and export the emutls functions from DSOs - this
makes a relatively small (20k) addition to a DSO.  These can be backed out
when a proper fix for PR88590 is committed.

For distributions that wish to install a libgcc_s.1.dylib to satisfy linkage
from exes that linked against the stubs can use a reexported libgcc_s.1.1
(since that contains all the symbols that were previously exported via the
 stubs).

The replacement libgcc_s.1 forwards the symbols from the new SO.
In order to support DYLD_LIBRARY_PATH on systems (where it works)
we forward the libSystem unwinder symbols from 10.7+ and a
compiler-local version of the libgcc unwinder on earlier.

For macOS 10.4 to 10.6 this is 'bug-compatible' with existing uses.
For 10.7+ the behaviour will now actually be correct.

Backported from commits d4943ce939,
7add7f7bb3,
b504917e43,
32731fa5b0,
574c09da48 and
c18ddb05b0

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

gcc/ChangeLog:

	PR target/80556
	* config/darwin-driver.c (darwin_driver_init): Handle exported
	symbols and symbol lists (suppress automatic export of the TLS
	symbols).
	* config/darwin.c (darwin_rename_builtins): Remove workaround.
	* config/darwin.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise.
	(REAL_LIBGCC_SPEC): Handle revised library uses.
	* config/darwin.opt (nodefaultexport): New.
	* config/i386/darwin.h (PR80556_WORKAROUND): Remove.
	* config/i386/darwin32-biarch.h (PR80556_WORKAROUND): Likewise.
	* config/i386/darwin64-biarch.h (PR80556_WORKAROUND): Likewise.

libgcc/ChangeLog:

	* config.host: Add weak emutls crt to the extra_parts.
	(*-*-darwin*): Add logic to build a shared unwinder library for
	Darwin8-10.  Add shim declaration header to powerpc*-darwin builds.
	* config/i386/darwin-lib.h (DECLARE_LIBRARY_RENAMES): Remove
	workaround.
	* config/libgcc-libsystem.ver: Add exclude list for the system-
	provided unwinder.
	* config/t-slibgcc-darwin: Bump SO version, remove stubs code.
	Build a legacy libgcc_s.1 and the supporting pieces (all FAT libs).
	* config/t-darwin-ehs: Add dependencies to the shared unwinder
	objects.  Add dependency on unwind.h.
	* config/t-darwin: Reorganise the EH fragments to place them for
	inclusion in a shared EH lib.  Add libgcc_tm.h to the dependencies
	for darwin10-unwind-find-enc-func.
	* config/i386/libgcc-darwin.10.4.ver: Removed.
	* config/i386/libgcc-darwin.10.5.ver: Removed.
	* config/rs6000/libgcc-darwin.10.4.ver: Removed.
	* config/rs6000/libgcc-darwin.10.5.ver: Removed.
	* config/i386/t-darwin: Build legacy libgcc_s.1.
	* config/rs6000/t-darwin: Likewise.
	* config/rs6000/t-darwin-ehs: Remove dependency on the powerpc end
	file.  Add darwin-fallback.o.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/fp-int-convert-timode-3.c: Remove XFAIL.
	* gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.
2022-05-29 20:12:12 +01:00
Iain Sandoe dbdaf3fa2d libgcc, emutls: Allow building weak definitions of the emutls functions.
In order to better support use of the emulated TLS between objects with
DSO dependencies and static-linked libgcc, allow a target to make weak
definitions.

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

libgcc/ChangeLog:

	* config/t-darwin: Build weak-defined emutls objects.
	* emutls.c (__emutls_get_address): Add optional attributes.
	(__emutls_register_common): Likewise.
	(EMUTLS_ATTR): New.

(cherry picked from commit b9873b4e2c)
2022-05-29 20:11:49 +01:00
Iain Sandoe ded0a33b1a Darwin: Revise handling of some driver opts.
[Fixes a regression in driver output with empty comand lines, also a pre-
 requisite for fixes in PR80556]

Darwin has a user convenience feature where some linker options are exposed
at the driver level (so one can type '-all_load' instead of '-Wl,-all_load'
or '-Xlinker -all_load').  We retain this feature, but now these options are
all marked as 'Driver' and we process them as early as possible so that they
get allocated to the right toolchain command.  There are a couple of special
cases where these driver opts are used multiple times, or to control
operations on more than one command (e.g. dynamiclib).  These are handled
specially and we then add %<xxxx specs for the commands that _do not_ need
them.  NOTE: the ordering of 'shared' and 'dynamiclib' is significant, hence
they are placed out of alphabetical order at the start.  Likewise, we keep
a couple of cases where a negative option originally appeared after the
positive alternate, potentially overriding it.

When we report an error with %e, it seems necessary to strip the option
before doing so, otherwise it survives to the cc1 command line (%e does not
appear to abort the program before this).

Right now there is no mechanism to split up the 'variable portion' (%*) of
the matched spec string, so where we have some driver specs that take 2 or
3 arguments, these cannot be processed here, but are deferred until the
LINK_SPEC, where they are copied verbatim.

We have a 'safe' version of the macOS version string, that has been sanity-
checked and truncated to minor version.  If the 'tiny' (3rd) portion of the
value is not significant, it is better to use the safe one in version-compare().

We were not wrapping all the default libraries in checks for whether
they should be used.  We were also wasting a process launch calling
dsymutil for 'r' link lines (a NOP in practice).  Order the checks
that exclude linking from most likely to occur, downwards.

We were pushing a spec value for weak_reference_mismatches unconditionally
which is not needed (the value was the default) and the side-effect of
this was that we appeared to need to drive a link command; leading to
unexpected diagnostics for cases where gcc was invoked with an empty
command line.

Also we were pushing flags for sysroot, os minimum version and controls
even if the command line was empty.

Backported from 353cb291a4,
4aef14b095 and
ff56eea24e

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

gcc/ChangeLog:

	* config/darwin-driver.c (darwin_driver_init): Revise comments, handle
	filelist and framework options in specs instead of code. Exit from the
	option handling early if the command line is definitely enpty.
	* config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Update to handle link
	specs that are really driver ones. Remove setting for the default content
	of weak_reference_mismatches
	(DARWIN_CC1_SPEC): Likewise.
	(CPP_SPEC): Likewise.
	(SYSROOT_SPEC): Append space.
	(LINK_SYSROOT_SPEC): Remove most driver link specs.
	(STANDARD_STARTFILE_PREFIX_2): Update link-related specs.
	(STARTFILE_SPEC): Likewise.
	(ASM_MMACOSX_VERSION_MIN_SPEC): Fix line wrap.
	(ASM_SPEC): Update driver-related specs.
	(ASM_FINAL_SPEC): Likewise.
	(LINK_COMMAND_SPEC_A): Update 'r' handling to skip gomp and itm when r
	or nodefaultlibs is given.
	(DSYMUTIL_SPEC): Do not call dsymutil for '-r' link lines.
	Update ordering of exclusions, remove duplicate 'v' addition
	(collect2 will add this from the main command line).
	* config/darwin.opt: Remove now unused option aliases.
	* config/i386/darwin.h (EXTRA_ASM_OPTS): Ensure space after opt.
	(ASM_SPEC): Update driver-related specs.
2022-05-29 20:11:35 +01:00
Iain Sandoe f7351aae82 libstdc++, testsuite: Add a prune expression for external tool bug.
Depending on the permutation of CPU, OS version and shared/non-
shared library inclusion, we get can get warnings from the external
tools (ld64, dsymutil) which are not actually libstdc++ issues but
relate to the external tools themselves.  This is already pruned
in the main testsuite, this adds it to the library.

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

libstdc++-v3/ChangeLog:

	* testsuite/lib/prune.exp: Prune dsymutil (ld64) warning.

(cherry picked from commit c7b782d847)
2022-05-29 20:11:16 +01:00