[gcc r12-10548] Include safe-ctype.h after C++ standard headers, to avoid over-poisoning

2024-06-11 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a995fded34fe488153b06bb41e026277f01efded

commit r12-10548-ga995fded34fe488153b06bb41e026277f01efded
Author: Francois-Xavier Coudert 
Date:   Thu Mar 7 14:36:03 2024 +0100

Include safe-ctype.h after C++ standard headers, to avoid over-poisoning

When building gcc's C++ sources against recent libc++, the poisoning of
the ctype macros due to including safe-ctype.h before including C++
standard headers such as , , etc, causes many compilation
errors, similar to:

  In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
  In file included from /home/dim/src/gcc/master/gcc/system.h:233:
  In file included from /usr/include/c++/v1/vector:321:
  In file included from
  /usr/include/c++/v1/__format/formatter_bool.h:20:
  In file included from
  /usr/include/c++/v1/__format/formatter_integral.h:32:
  In file included from /usr/include/c++/v1/locale:202:
  /usr/include/c++/v1/__locale:546:5: error: '__abi_tag__' attribute
  only applies to structs, variables, functions, and namespaces
546 | _LIBCPP_INLINE_VISIBILITY
| ^
  /usr/include/c++/v1/__config:813:37: note: expanded from macro
  '_LIBCPP_INLINE_VISIBILITY'
813 | #  define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
| ^
  /usr/include/c++/v1/__config:792:26: note: expanded from macro
  '_LIBCPP_HIDE_FROM_ABI'
792 |
__attribute__((__abi_tag__(_LIBCPP_TOSTRING(
  _LIBCPP_VERSIONED_IDENTIFIER
|  ^
  In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
  In file included from /home/dim/src/gcc/master/gcc/system.h:233:
  In file included from /usr/include/c++/v1/vector:321:
  In file included from
  /usr/include/c++/v1/__format/formatter_bool.h:20:
  In file included from
  /usr/include/c++/v1/__format/formatter_integral.h:32:
  In file included from /usr/include/c++/v1/locale:202:
  /usr/include/c++/v1/__locale:547:37: error: expected ';' at end of
  declaration list
547 | char_type toupper(char_type __c) const
| ^
  /usr/include/c++/v1/__locale:553:48: error: too many arguments
  provided to function-like macro invocation
553 | const char_type* toupper(char_type* __low, const
char_type* __high) const
|^
  /home/dim/src/gcc/master/gcc/../include/safe-ctype.h:146:9: note:
  macro 'toupper' defined here
146 | #define toupper(c) do_not_use_toupper_with_safe_ctype
| ^

This is because libc++ uses different transitive includes than
libstdc++, and some of those transitive includes pull in various ctype
declarations (typically via ).

There was already a special case for including  before
safe-ctype.h, so move the rest of the C++ standard header includes to
the same location, to fix the problem.

PR middle-end/111632

gcc/ChangeLog:

* system.h: Include safe-ctype.h after C++ standard headers.

Signed-off-by: Dimitry Andric 
(cherry picked from commit 9970b576b7e4ae337af1268395ff221348c4b34a)

Diff:
---
 gcc/system.h | 39 ++-
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/gcc/system.h b/gcc/system.h
index e10c34f70eca..38733dd81a6e 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -194,27 +194,8 @@ extern int fprintf_unlocked (FILE *, const char *, ...);
 #undef fread_unlocked
 #undef fwrite_unlocked
 
-/* Include  before "safe-ctype.h" to avoid GCC poisoning
-   the ctype macros through safe-ctype.h */
-
-#ifdef __cplusplus
-#ifdef INCLUDE_STRING
-# include 
-#endif
-#endif
-
-/* There are an extraordinary number of issues with .
-   The last straw is that it varies with the locale.  Use libiberty's
-   replacement instead.  */
-#include "safe-ctype.h"
-
-#include 
-
-#include 
-
-#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
-extern int errno;
-#endif
+/* Include C++ standard headers before "safe-ctype.h" to avoid GCC
+   poisoning the ctype macros through safe-ctype.h */
 
 #ifdef __cplusplus
 #if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY)
@@ -229,6 +210,9 @@ extern int errno;
 #ifdef INCLUDE_SET
 # include 
 #endif
+#ifdef INCLUDE_STRING
+# include 
+#endif
 #ifdef INCLUDE_VECTOR
 # include 
 #endif
@@ -245,6 +229,19 @@ extern int errno;
 # include 
 #endif
 
+/* There are an extraordinary number of issues with .
+   The last straw is that it varies with the locale.  Use libiberty's
+   replacement instead.  */
+#include "safe-ctype.h"
+
+#include 
+
+#include 
+
+#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
+extern int errno;
+#endif
+
 /* Some of glibc's string 

[gcc r12-10547] libcc1: fix include

2024-06-11 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:8f11ed1c58e14421ba4be1652764fc47fdce8dc7

commit r12-10547-g8f11ed1c58e14421ba4be1652764fc47fdce8dc7
Author: Francois-Xavier Coudert 
Date:   Sat Mar 16 09:50:00 2024 +0100

libcc1: fix  include

Use INCLUDE_VECTOR before including system.h, instead of directly
including , to avoid running into poisoned identifiers.

Signed-off-by: Dimitry Andric 

PR middle-end/111632

libcc1/ChangeLog:

* libcc1plugin.cc: Fix include.
* libcp1plugin.cc: Fix include.

(cherry picked from commit 5213047b1d50af63dfabb5e5649821a6cb157e33)

Diff:
---
 libcc1/libcc1plugin.cc | 3 +--
 libcc1/libcp1plugin.cc | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc
index bdd0bdabe77f..8d96667e33bd 100644
--- a/libcc1/libcc1plugin.cc
+++ b/libcc1/libcc1plugin.cc
@@ -32,6 +32,7 @@
 #undef PACKAGE_VERSION
 
 #define INCLUDE_MEMORY
+#define INCLUDE_VECTOR
 #include "gcc-plugin.h"
 #include "system.h"
 #include "coretypes.h"
@@ -69,8 +70,6 @@
 #include "gcc-c-interface.h"
 #include "context.hh"
 
-#include 
-
 using namespace cc1_plugin;
 
 
diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc
index e2d5039a0a1f..6c93e9121343 100644
--- a/libcc1/libcp1plugin.cc
+++ b/libcc1/libcp1plugin.cc
@@ -33,6 +33,7 @@
 #undef PACKAGE_VERSION
 
 #define INCLUDE_MEMORY
+#define INCLUDE_VECTOR
 #include "gcc-plugin.h"
 #include "system.h"
 #include "coretypes.h"
@@ -71,8 +72,6 @@
 #include "rpc.hh"
 #include "context.hh"
 
-#include 
-
 using namespace cc1_plugin;


[gcc r15-651] testsuite, C++, Darwin: Skip cxa_atexit-6, which is not applicable.

2024-05-19 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:1073469074ff132478ec8d923ed8635c672f7d9b

commit r15-651-g1073469074ff132478ec8d923ed8635c672f7d9b
Author: Iain Sandoe 
Date:   Sat May 11 09:24:33 2024 +0100

testsuite, C++, Darwin: Skip cxa_atexit-6, which is not applicable.

For Darwin, non-weak functions defined in a TU always bind locally
and so cxa_atexit-6.C is not applicable here.

PR testsuite/114982

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/cxa_atexit-6.C: Skip for Darwin.

Signed-off-by: Iain Sandoe 

Diff:
---
 gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C 
b/gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C
index f6599a3c9f45..e22036067dd4 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C
@@ -2,10 +2,14 @@
 /* { dg-require-effective-target fpic } */
 /* { dg-options "-O2 -fdump-tree-cddce1-details -fdump-tree-optimized -fPIC" } 
*/
 // { dg-require-effective-target cxa_atexit }
+/* This test is not appropriate for targets where non-weak functions defined
+   in the TU always bind locally; see PR114982.  */
+/* { dg-skip-if "PR114982" { *-*-darwin* } } */
 /* PR tree-optimization/19661 */
 
 /* The call to axexit should not be removed as A::~A() cannot be figured if it
-   is a pure/const function call as the function call g does not bind locally. 
*/
+   is a pure/const function call for platforms where the function call g does
+   not bind locally. */
 
 __attribute__((noinline))
 void g() {}


[gcc r15-650] testsuite, darwin: Compile a test without unwind frames.

2024-05-19 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:0aa709ff9d4ca2f9794c4072d81bb68d784dd86c

commit r15-650-g0aa709ff9d4ca2f9794c4072d81bb68d784dd86c
Author: Iain Sandoe 
Date:   Sun May 5 14:13:37 2024 +0100

testsuite, darwin: Compile a test without unwind frames.

In the current Darwin implementation, we do not use .cfi_ insns
and emitted EH frames contain 'coalesced' section designations
which interfere with the scan asm.

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-weakimport-3.c: Suppress unwind frames.

Signed-off-by: Iain Sandoe 

Diff:
---
 gcc/testsuite/gcc.dg/darwin-weakimport-3.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/darwin-weakimport-3.c 
b/gcc/testsuite/gcc.dg/darwin-weakimport-3.c
index a15b5b0e7cb9..7e83987bad5e 100644
--- a/gcc/testsuite/gcc.dg/darwin-weakimport-3.c
+++ b/gcc/testsuite/gcc.dg/darwin-weakimport-3.c
@@ -10,11 +10,12 @@
With modern linkers this is moot, since even weak symbols
are emitted into the regular sections.
 
-   To avoid the unwind tables -fno-asynchronous-unwind-tables.
+   To avoid the unwind tables -fno-asynchronous-unwind-tables
+   and fno-unwind-tables (since EH contains coalesced data).
To ensure that we emit code for an older linker -mtarget-linker
To avoid the get_pc thunk optimise at least O1.  */
 
-/* { dg-options "-fno-asynchronous-unwind-tables -O1 -mtarget-linker 85.2" } */
+/* { dg-options "-fno-asynchronous-unwind-tables -fno-unwind-tables -O1 
-mtarget-linker 85.2" } */
 /* { dg-require-weak "" } */
 
 /* { dg-final { scan-assembler-not "coalesced" } } */


[gcc r11-11425] Objective-C, NeXT, v2: Correct a regression in code-gen.

2024-05-10 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:48400d6c95c836d43532bb00a3a57f3c458e0778

commit r11-11425-g48400d6c95c836d43532bb00a3a57f3c458e0778
Author: Iain Sandoe 
Date:   Tue Apr 30 15:11:56 2024 +0100

Objective-C, NeXT, v2: Correct a regression in code-gen.

There have been several changes in the ABI of Objective-C which
depend on the OS version targetted.  In this case Protocols and
LabelProtocols should be made weak/hidden/extern from macOS 10.7
however there was a mistake in the code causing this to occur
from macOS 10.6.  Fixed thus.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (WEAK_PROTOCOLS_AFTER): New.
(next_runtime_abi_02_protocol_decl): Use WEAK_PROTOCOLS_AFTER
to determine this ABI change.
(build_v2_protocol_list_address_table): Likewise.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 9b5c0be59d0f94df0517820f00b4520b5abddd8c)

Diff:
---
 gcc/objc/objc-next-runtime-abi-02.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index cb22a773fcb2..2f79f99c7319 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3.  If not see
 #define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper2_stret"
 
 #define USE_FIXUP_BEFORE   100600
+#define WEAK_PROTOCOLS_AFTER   100700
 #define TAG_FIXUP  "_fixup"
 
 
@@ -1031,7 +1032,7 @@ next_runtime_abi_02_protocol_decl (tree p)
   /* static struct _objc_protocol _OBJC_Protocol_; */
   snprintf (buf, BUFSIZE, "_OBJC_Protocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
 {
   decl = create_hidden_decl (objc_v2_protocol_template, buf);
   DECL_WEAK (decl) = true;
@@ -2317,7 +2318,7 @@ build_v2_protocol_list_address_table (void)
   gcc_assert (ref->id && TREE_CODE (ref->id) == PROTOCOL_INTERFACE_TYPE);
   snprintf (buf, BUFSIZE, "_OBJC_LabelProtocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (ref->id)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
{
  decl = create_hidden_decl (objc_protocol_type, buf, /*is def=*/true);
  DECL_WEAK (decl) = true;


[gcc r12-10437] Objective-C, NeXT, v2: Correct a regression in code-gen.

2024-05-10 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:587596d8b882da898469dfc08d56368ba31f14b2

commit r12-10437-g587596d8b882da898469dfc08d56368ba31f14b2
Author: Iain Sandoe 
Date:   Tue Apr 30 15:11:56 2024 +0100

Objective-C, NeXT, v2: Correct a regression in code-gen.

There have been several changes in the ABI of Objective-C which
depend on the OS version targetted.  In this case Protocols and
LabelProtocols should be made weak/hidden/extern from macOS 10.7
however there was a mistake in the code causing this to occur
from macOS 10.6.  Fixed thus.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.cc (WEAK_PROTOCOLS_AFTER): New.
(next_runtime_abi_02_protocol_decl): Use WEAK_PROTOCOLS_AFTER
to determine this ABI change.
(build_v2_protocol_list_address_table): Likewise.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 9b5c0be59d0f94df0517820f00b4520b5abddd8c)

Diff:
---
 gcc/objc/objc-next-runtime-abi-02.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/objc/objc-next-runtime-abi-02.cc 
b/gcc/objc/objc-next-runtime-abi-02.cc
index 1dee05df7691..baf419d3350f 100644
--- a/gcc/objc/objc-next-runtime-abi-02.cc
+++ b/gcc/objc/objc-next-runtime-abi-02.cc
@@ -72,6 +72,7 @@ along with GCC; see the file COPYING3.  If not see
 #define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper2_stret"
 
 #define USE_FIXUP_BEFORE   100600
+#define WEAK_PROTOCOLS_AFTER   100700
 #define TAG_FIXUP  "_fixup"
 
 
@@ -1025,7 +1026,7 @@ next_runtime_abi_02_protocol_decl (tree p)
   /* static struct _objc_protocol _OBJC_Protocol_; */
   snprintf (buf, BUFSIZE, "_OBJC_Protocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
 {
   decl = create_hidden_decl (objc_v2_protocol_template, buf);
   DECL_WEAK (decl) = true;
@@ -2312,7 +2313,7 @@ build_v2_protocol_list_address_table (void)
   gcc_assert (ref->id && TREE_CODE (ref->id) == PROTOCOL_INTERFACE_TYPE);
   snprintf (buf, BUFSIZE, "_OBJC_LabelProtocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (ref->id)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
{
  decl = create_hidden_decl (objc_protocol_type, buf, /*is def=*/true);
  DECL_WEAK (decl) = true;


[gcc r14-10185] Objective-C, NeXT, v2: Correct a regression in code-gen.

2024-05-08 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:7e8fae89f356bad9c62c8625a36b631cf0a74568

commit r14-10185-g7e8fae89f356bad9c62c8625a36b631cf0a74568
Author: Iain Sandoe 
Date:   Tue Apr 30 15:11:56 2024 +0100

Objective-C, NeXT, v2: Correct a regression in code-gen.

There have been several changes in the ABI of Objective-C which
depend on the OS version targetted.  In this case Protocols and
LabelProtocols should be made weak/hidden/extern from macOS 10.7
however there was a mistake in the code causing this to occur
from macOS 10.6.  Fixed thus.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.cc (WEAK_PROTOCOLS_AFTER): New.
(next_runtime_abi_02_protocol_decl): Use WEAK_PROTOCOLS_AFTER
to determine this ABI change.
(build_v2_protocol_list_address_table): Likewise.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 9b5c0be59d0f94df0517820f00b4520b5abddd8c)

Diff:
---
 gcc/objc/objc-next-runtime-abi-02.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/objc/objc-next-runtime-abi-02.cc 
b/gcc/objc/objc-next-runtime-abi-02.cc
index cdf559b9bea8..248ef641281f 100644
--- a/gcc/objc/objc-next-runtime-abi-02.cc
+++ b/gcc/objc/objc-next-runtime-abi-02.cc
@@ -72,6 +72,7 @@ along with GCC; see the file COPYING3.  If not see
 #define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper2_stret"
 
 #define USE_FIXUP_BEFORE   100600
+#define WEAK_PROTOCOLS_AFTER   100700
 #define TAG_FIXUP  "_fixup"
 
 
@@ -1025,7 +1026,7 @@ next_runtime_abi_02_protocol_decl (tree p)
   /* static struct _objc_protocol _OBJC_Protocol_; */
   snprintf (buf, BUFSIZE, "_OBJC_Protocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
 {
   decl = create_hidden_decl (objc_v2_protocol_template, buf);
   DECL_WEAK (decl) = true;
@@ -2315,7 +2316,7 @@ build_v2_protocol_list_address_table (void)
   gcc_assert (ref->id && TREE_CODE (ref->id) == PROTOCOL_INTERFACE_TYPE);
   snprintf (buf, BUFSIZE, "_OBJC_LabelProtocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (ref->id)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
{
  decl = create_hidden_decl (objc_protocol_type, buf, /*is def=*/true);
  DECL_WEAK (decl) = true;


[gcc r13-8686] Objective-C, NeXT, v2: Correct a regression in code-gen.

2024-05-04 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:b6ead0978b0513c0efa040b8bda21a67a454dd27

commit r13-8686-gb6ead0978b0513c0efa040b8bda21a67a454dd27
Author: Iain Sandoe 
Date:   Tue Apr 30 15:11:56 2024 +0100

Objective-C, NeXT, v2: Correct a regression in code-gen.

There have been several changes in the ABI of Objective-C which
depend on the OS version targetted.  In this case Protocols and
LabelProtocols should be made weak/hidden/extern from macOS 10.7
however there was a mistake in the code causing this to occur
from macOS 10.6.  Fixed thus.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.cc (WEAK_PROTOCOLS_AFTER): New.
(next_runtime_abi_02_protocol_decl): Use WEAK_PROTOCOLS_AFTER
to determine this ABI change.
(build_v2_protocol_list_address_table): Likewise.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 9b5c0be59d0f94df0517820f00b4520b5abddd8c)

Diff:
---
 gcc/objc/objc-next-runtime-abi-02.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/objc/objc-next-runtime-abi-02.cc 
b/gcc/objc/objc-next-runtime-abi-02.cc
index 7a674a0e45e..012f7538fc9 100644
--- a/gcc/objc/objc-next-runtime-abi-02.cc
+++ b/gcc/objc/objc-next-runtime-abi-02.cc
@@ -72,6 +72,7 @@ along with GCC; see the file COPYING3.  If not see
 #define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper2_stret"
 
 #define USE_FIXUP_BEFORE   100600
+#define WEAK_PROTOCOLS_AFTER   100700
 #define TAG_FIXUP  "_fixup"
 
 
@@ -1025,7 +1026,7 @@ next_runtime_abi_02_protocol_decl (tree p)
   /* static struct _objc_protocol _OBJC_Protocol_; */
   snprintf (buf, BUFSIZE, "_OBJC_Protocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
 {
   decl = create_hidden_decl (objc_v2_protocol_template, buf);
   DECL_WEAK (decl) = true;
@@ -2312,7 +2313,7 @@ build_v2_protocol_list_address_table (void)
   gcc_assert (ref->id && TREE_CODE (ref->id) == PROTOCOL_INTERFACE_TYPE);
   snprintf (buf, BUFSIZE, "_OBJC_LabelProtocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (ref->id)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
{
  decl = create_hidden_decl (objc_protocol_type, buf, /*is def=*/true);
  DECL_WEAK (decl) = true;


[gcc r15-111] Objective-C, NeXT, v2: Correct a regression in code-gen.

2024-05-02 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:9b5c0be59d0f94df0517820f00b4520b5abddd8c

commit r15-111-g9b5c0be59d0f94df0517820f00b4520b5abddd8c
Author: Iain Sandoe 
Date:   Tue Apr 30 15:11:56 2024 +0100

Objective-C, NeXT, v2: Correct a regression in code-gen.

There have been several changes in the ABI of Objective-C which
depend on the OS version targetted.  In this case Protocols and
LabelProtocols should be made weak/hidden/extern from macOS 10.7
however there was a mistake in the code causing this to occur
from macOS 10.6.  Fixed thus.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.cc (WEAK_PROTOCOLS_AFTER): New.
(next_runtime_abi_02_protocol_decl): Use WEAK_PROTOCOLS_AFTER
to determine this ABI change.
(build_v2_protocol_list_address_table): Likewise.

Signed-off-by: Iain Sandoe 

Diff:
---
 gcc/objc/objc-next-runtime-abi-02.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/objc/objc-next-runtime-abi-02.cc 
b/gcc/objc/objc-next-runtime-abi-02.cc
index cdf559b9bea..248ef641281 100644
--- a/gcc/objc/objc-next-runtime-abi-02.cc
+++ b/gcc/objc/objc-next-runtime-abi-02.cc
@@ -72,6 +72,7 @@ along with GCC; see the file COPYING3.  If not see
 #define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper2_stret"
 
 #define USE_FIXUP_BEFORE   100600
+#define WEAK_PROTOCOLS_AFTER   100700
 #define TAG_FIXUP  "_fixup"
 
 
@@ -1025,7 +1026,7 @@ next_runtime_abi_02_protocol_decl (tree p)
   /* static struct _objc_protocol _OBJC_Protocol_; */
   snprintf (buf, BUFSIZE, "_OBJC_Protocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
 {
   decl = create_hidden_decl (objc_v2_protocol_template, buf);
   DECL_WEAK (decl) = true;
@@ -2315,7 +2316,7 @@ build_v2_protocol_list_address_table (void)
   gcc_assert (ref->id && TREE_CODE (ref->id) == PROTOCOL_INTERFACE_TYPE);
   snprintf (buf, BUFSIZE, "_OBJC_LabelProtocol_%s",
IDENTIFIER_POINTER (PROTOCOL_NAME (ref->id)));
-  if (flag_next_runtime >= USE_FIXUP_BEFORE)
+  if (flag_next_runtime >= WEAK_PROTOCOLS_AFTER)
{
  decl = create_hidden_decl (objc_protocol_type, buf, /*is def=*/true);
  DECL_WEAK (decl) = true;


[gcc r11-11406] testsuite: Remove duplicate -lgcov [PR114034]

2024-04-29 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:241e10972c916540a085054a1a858c5b2ce82a5a

commit r11-11406-g241e10972c916540a085054a1a858c5b2ce82a5a
Author: Iain Sandoe 
Date:   Sun Mar 31 11:22:58 2024 +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 
(cherry picked from commit 799a056cf804f433ce0050a5a6bf900f7a01ecb1)

Diff:
---
 gcc/testsuite/g++.dg/gcov/gcov-dump-1.C | 2 +-
 gcc/testsuite/g++.dg/gcov/gcov-dump-2.C | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C 
b/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C
index f0e81e9b042..774a7269ff2 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C
@@ -1,4 +1,4 @@
-/* { dg-options "-fprofile-generate -ftest-coverage -lgcov" } */
+/* { dg-options "-fprofile-generate -ftest-coverage " } */
 /* { dg-do run { target native } } */
 
 int value;
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C 
b/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C
index 6234a81a586..e748989d2c0 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C
@@ -1,4 +1,4 @@
-/* { dg-options "-fprofile-generate -ftest-coverage -lgcov" } */
+/* { dg-options "-fprofile-generate -ftest-coverage " } */
 /* { dg-do run { target native } } */
 
 int value;


[gcc r11-11405] testsuite, Darwin: Allow for an undefined symbol [PR114036].

2024-04-29 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:5feeb2ddc93de85dffd7d52119189cd63bccd40f

commit r11-11405-g5feeb2ddc93de85dffd7d52119189cd63bccd40f
Author: Iain Sandoe 
Date:   Sun Mar 31 11:27:53 2024 +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 
(cherry picked from commit ad8e34eaa870608e2b07b4e7147e6ef2944bb8b5)

Diff:
---
 gcc/testsuite/gcc.misc-tests/gcov-14.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.misc-tests/gcov-14.c 
b/gcc/testsuite/gcc.misc-tests/gcov-14.c
index 2bebf7e4a93..61a9191c068 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov-14.c
+++ b/gcc/testsuite/gcc.misc-tests/gcov-14.c
@@ -3,7 +3,7 @@
 /* { dg-do run { target native } } */
 /* { dg-options "-O2 -fprofile-arcs -ftest-coverage -fgnu89-inline" } */
 /* The following line arranges that Darwin has behavior like elf weak import.  
*/
-/* { dg-additional-options "-flat_namespace -undefined suppress" { target 
*-*-darwin* }  } */
+/* { dg-additional-options "-Wl,-U,_Foo" { target *-*-darwin* }  } */
 /* { dg-require-weak "" } */
 /* { dg-skip-if "undefined weak not supported" { { hppa*-*-hpux* } && { ! lp64 
} } } */
 /* { dg-skip-if "undefined weak not supported" { powerpc-ibm-aix* } } */


[gcc r11-11407] jit, Darwin: Implement library exports list.

2024-04-29 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:30d20d6f14ffdc4c078bc11048bb157b5929

commit r11-11407-g30d20d6f14ffdc4c078bc11048bb157b5929
Author: Iain Sandoe 
Date:   Sat Jan 13 17:20:47 2024 +

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 
(cherry picked from commit b120e355e59142bd15d6b010461d07236288d843)

Diff:
---
 gcc/jit/Make-lang.in  |  47 -
 gcc/jit/libgccjit.exports | 171 ++
 2 files changed, 201 insertions(+), 17 deletions(-)

diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
index 2a774d7feb1..7030ab51d4a 100644
--- a/gcc/jit/Make-lang.in
+++ b/gcc/jit/Make-lang.in
@@ -55,7 +55,17 @@ else
 
 ifneq (,$(findstring darwin,$(host)))
 
-LIBGCCJIT_AGE = 1
+# NOTE that we are building here for the host, and so tests for target-
+# specific functionality will only work when host == target.  This causes
+# fails when building cross-compilers with different object formats (at
+# least when the respective linkers do not accept the same command line
+# options).  Fortunately, for Darwin we can safely hard-code the relevant
+# host options, since all usable linkers support them).
+
+LIBGCCJIT_CURRENT = 15
+LIBGCCJIT_REVISION = 0
+LIBGCCJIT_AGE = 15
+LIBGCCJIT_COMPAT = 0
 LIBGCCJIT_BASENAME = libgccjit
 
 LIBGCCJIT_SONAME = \
@@ -63,18 +73,18 @@ LIBGCCJIT_SONAME = \
 LIBGCCJIT_FILENAME = $(LIBGCCJIT_BASENAME).$(LIBGCCJIT_VERSION_NUM).dylib
 LIBGCCJIT_LINKER_NAME = $(LIBGCCJIT_BASENAME).dylib
 
-# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
-# LD_SONAME_OPTION depending if configure found them, using $(if)
-# We have to define a COMMA here, otherwise the commas in the "true"
-# result are treated as separators by the $(if).
+# Darwin does not have a version script option. Exported symbols are controlled
+# by the following, and library versioning is done using libtool.
+# We have to define a COMMA here, otherwise the commas are treated as
+# separators.
 COMMA := ,
 LIBGCCJIT_VERSION_SCRIPT_OPTION = \
-   $(if $(LD_VERSION_SCRIPT_OPTION),\
- 
-Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map)
+  -Wl$(COMMA)-exported_symbols_list$(COMMA)$(srcdir)/jit/libgccjit.exports
 
+# For Darwin host, we need a l64 or ld64-compatible linker, that uses
+# -install_name to introduce this.
 LIBGCCJIT_SONAME_OPTION = \
-   $(if $(LD_SONAME_OPTION), \
--Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))
+  -Wl$(COMMA)-install_name$(COMMA)$(LIBGCCJIT_SONAME)
 
 LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_FILENAME)
 LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
@@ -143,15 +153,18 @@ ifneq (,$(findstring mingw,$(target)))
 # Create import library
 LIBGCCJIT_EXTRA_OPTS = -Wl,--out-implib,$(LIBGCCJIT_IMPORT_LIB)
 else
-
 ifneq (,$(findstring darwin,$(host)))
-# TODO : Construct a Darwin-style symbol export file.
-LIBGCCJIT_EXTRA_OPTS = -Wl,-compatibility_version,$(LIBGCCJIT_VERSION_NUM) \
-   
-Wl,-current_version,$(LIBGCCJIT_VERSION_NUM).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_AGE)
 \
-   $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
-   $(LIBGCCJIT_SONAME_OPTION)
+LIBGCCJIT_VERS = $(LIBGCCJIT_CURRENT).$(LIBGCCJIT_REVISION).$(LIBGCCJIT_AGE)
+LIBGCCJIT_EXTRA_OPTS = -Wl,-current_version,$(LIBGCCJIT_VERS) \
+ -Wl,-compatibility_version,$(LIBGCCJIT_COMPAT) \
+  $(LIBGCCJIT_VERSION_SCRIPT_OPTION) $(LIBGCCJIT_SONAME_OPTION)
+# Use the default (shared) libgcc.
+JIT_LDFLAGS = $(filter-out -static-libgcc, $(LDFLAGS))
+ifeq (,$(findstring darwin8,$(host)))
+JIT_LDFLAGS += -Wl,-rpath,@loader_path
+endif
 else
-
+JIT_LDFLAGS = $(LDFLAGS)
 LIBGCCJIT_EXTRA_OPTS = $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
$(LIBGCCJIT_SONAME_OPTION)
 endif
@@ -165,7 +178,7 @@ $(LIBGCCJIT_FILENAME): $(jit_OBJS) \
$(LIBDEPS) $(srcdir)/jit/libgccjit.map \
$(EXTRA_GCC_OBJS) $(jit.prev)
@$(call LINK_PROGRESS,$(INDEX.jit),start)
-   +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ -shared \
+   +$(LLINKER) $(ALL_LINKERFLAGS) $(JIT_LDFLAGS) -o $@ -shared \
 $(jit_OBJS) libbackend.a libcommon-target.a libcommon.a \
 $(CPPLIB) 

[gcc r11-11404] Darwin: Do not emit .macinfo when dsymutil cannot consume it.

2024-04-29 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:97a19770f657d88c24a5b1a0afd9ebaa5a61647a

commit r11-11404-g97a19770f657d88c24a5b1a0afd9ebaa5a61647a
Author: Iain Sandoe 
Date:   Sun Mar 31 23:25:31 2024 +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.c (darwin_override_options): Reduce the debug
level to 2 if dsymutil cannot handle .macinfo sections.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 3c499f8f6f7d19b21d7047efabbe6396ee1c2cac)

Diff:
---
 gcc/config/darwin.c | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index a473ea79b1b..465e8075dfd 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3374,11 +3374,6 @@ darwin_override_options (void)
  global_options.x_flag_objc_abi);
 }
 
-  /* Limit DWARF to the chosen version, the linker and debug linker might not
- be able to consume newer structures.  */
-  if (!global_options_set.x_dwarf_strict)
-dwarf_strict = 1;
-
   if (!global_options_set.x_dwarf_version)
 {
   /* External toolchains based on LLVM or clang 7+ have support for
@@ -3401,6 +3396,24 @@ darwin_override_options (void)
   global_options_set.x_dwarf_split_debug_info = 0;
 }
 
+  /* Cases where dsymutil will exclude files with .macinfo sections; we are
+ better off forcing the debug level to 2 than completely excluding the
+ files.  If strict dwarf is set, then emit the macinfo anyway.  */
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+  && (!global_options_set.x_dwarf_strict || dwarf_strict == 0)
+  && ((dsymutil_version.kind == CLANG && dsymutil_version.major >= 1500)
+ || (dsymutil_version.kind == LLVM && dsymutil_version.major >= 15)))
+{
+  inform (input_location,
+ "%<-g3%> is not supported by the debug linker in use (set to 2)");
+  debug_info_level = DINFO_LEVEL_NORMAL;
+}
+
+  /* Limit DWARF to the chosen version, the linker and debug linker might not
+ be able to consume newer structures.  */
+  if (!global_options_set.x_dwarf_strict)
+dwarf_strict = 1;
+
   /* Do not allow unwind tables to be generated by default for m32.
  fnon-call-exceptions will override this, regardless of what we do.  */
   if (generating_for_darwin_version < 10


[gcc r11-11402] testsuite, Darwin: Use the IOKit framework in framework-1.c [PR114049].

2024-04-29 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:729170a45040e96d567be79bda00604a7645a23d

commit r11-11402-g729170a45040e96d567be79bda00604a7645a23d
Author: Iain Sandoe 
Date:   Mon Mar 18 10:06:44 2024 +

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 
(cherry picked from commit 4adb1a5839e7a3310a127c1776f1f95d7edaa6ff)

Diff:
---
 gcc/testsuite/gcc.dg/framework-1.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/framework-1.c 
b/gcc/testsuite/gcc.dg/framework-1.c
index de4adc39868..fdec129a8fb 100644
--- a/gcc/testsuite/gcc.dg/framework-1.c
+++ b/gcc/testsuite/gcc.dg/framework-1.c
@@ -1,4 +1,10 @@
 /* { dg-do compile { target *-*-darwin* } } */
 /* { dg-options "-F." } */
 
-#include 
+/* 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.  */
+
+#include 


[gcc r11-11401] libstdc++: Sync the atomic_link_flags implementation with GCC.

2024-04-29 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:1efe5c06d85c982ffe489bbb7a6b95dc10f7bfde

commit r11-11401-g1efe5c06d85c982ffe489bbb7a6b95dc10f7bfde
Author: Iain Sandoe 
Date:   Mon Mar 18 09:57:33 2024 +

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 
(cherry picked from commit 71a44faa8a4f76d68356c66c6054e6c242df820f)

Diff:
---
 libstdc++-v3/testsuite/lib/dg-options.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp 
b/libstdc++-v3/testsuite/lib/dg-options.exp
index 872768f2620..6e27bd04be7 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -274,7 +274,7 @@ proc atomic_link_flags { paths } {
   if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"]
|| [file exists 
"${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } {
   append flags " -B${gccpath}/libatomic/ "
-  append flags " -L${gccpath}/libatomic/.libs"
+  append flags " -B${gccpath}/libatomic/.libs"
   append ld_library_path ":${gccpath}/libatomic/.libs"
   }
 } else {


[gcc r11-11399] testsuite, Darwin: Allow for undefined symbols in shared test.

2024-04-29 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:8f29a712c404ab272050335c74b2d551c3bd23d3

commit r11-11399-g8f29a712c404ab272050335c74b2d551c3bd23d3
Author: Iain Sandoe 
Date:   Mon Jan 29 10:09:25 2024 +

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

Diff:
---
 gcc/testsuite/lib/target-supports.exp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 876b972a433..a059a800298 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1265,13 +1265,20 @@ proc check_effective_target_aarch64_tlsle32 { } {
 # emitted, 0 otherwise.
 
 proc check_effective_target_shared { } {
+# Darwin's linker defaults to error on undefined (which makes it look as
+# if we do not support shared) but we can tell it to allow the symbols used
+# here to be undefined.
+set extra_flags ""
+if { [istarget *-*-darwin\[912\]*] } {
+  set extra_flags "-Wl,-U,_foo,-U,_bar,-U,__Z3foov"
+}
 # Note that M68K has a multilib that supports -fpic but not
 # -fPIC, so we need to check both.  We test with a program that
 # requires GOT references.
 return [check_no_compiler_messages shared executable {
extern int foo (void); extern int bar;
int baz (void) { return foo () + bar; }
-} "-shared -fpic"]
+} "-shared -fpic $extra_flags"]
 }
 
 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.


[gcc r11-11397] Darwin, testsuite: -multiply_defined is obsolete

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:f6c1f80fd9a9ba6f891514171d0236f366b373aa

commit r11-11397-gf6c1f80fd9a9ba6f891514171d0236f366b373aa
Author: Francois-Xavier Coudert 
Date:   Sat Feb 10 15:52:44 2024 +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)

Diff:
---
 gcc/testsuite/gcc.dg/ssp-2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/ssp-2.c b/gcc/testsuite/gcc.dg/ssp-2.c
index 752fe5393f4..608ca300032 100644
--- a/gcc/testsuite/gcc.dg/ssp-2.c
+++ b/gcc/testsuite/gcc.dg/ssp-2.c
@@ -1,6 +1,7 @@
 /* { dg-do run { target native } } */
 /* { dg-options "-fstack-protector" } */
 /* { dg-options "-fstack-protector -Wl,-multiply_defined,suppress" { target 
*-*-darwin* } } */
+/* { dg-prune-output "-multiply_defined is obsolete" } */
 /* { dg-require-effective-target fstack_protector } */
 
 #include 


[gcc r11-11396] Darwin, testsuite: -bind_at_load is deprecated

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:1ac65249cb9553bda683b3b1a2f85fccb2562bb8

commit r11-11396-g1ac65249cb9553bda683b3b1a2f85fccb2562bb8
Author: Francois-Xavier Coudert 
Date:   Sat Feb 10 12:55:29 2024 +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)

Diff:
---
 gcc/testsuite/gcc.dg/darwin-ld-2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/darwin-ld-2.c 
b/gcc/testsuite/gcc.dg/darwin-ld-2.c
index 5de19524f0b..2a6b491da5b 100644
--- a/gcc/testsuite/gcc.dg/darwin-ld-2.c
+++ b/gcc/testsuite/gcc.dg/darwin-ld-2.c
@@ -3,6 +3,7 @@
 
 /* { dg-options "-bind_at_load" } */
 /* { dg-do link { target *-*-darwin* } } */
+/* { dg-prune-output "-bind_at_load is deprecated" } */
 
 int main()
 {


[gcc r11-11395] Darwin: Correct a merge error.

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:b54b43396c9c716c43d58a60efafb21419d2fbb5

commit r11-11395-gb54b43396c9c716c43d58a60efafb21419d2fbb5
Author: Iain Sandoe 
Date:   Sun Apr 28 17:05:06 2024 +0100

Darwin: Correct a merge error.

For this branch the default_libc_has_function () is not available.

Signed-off-by: Iain Sandoe 

gcc/ChangeLog:

* config/darwin.c: Return true as the default libc avaiability.

Diff:
---
 gcc/config/darwin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 6e887a9ba5a..a473ea79b1b 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3603,7 +3603,7 @@ darwin_libc_has_function (enum function_class fn_class,
|| (darwin_macosx_version_min &&
strverscmp (darwin_macosx_version_min, "10.3") >= 0));
 #endif
-  return default_libc_has_function (fn_class, type);
+  return true;
 }
 
 /*  CFStrings implementation.  */


[gcc r11-11394] Testsuite, i386: Mark test as requiring ifunc

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:35b198ed957d089f095724e91165cf082e9be1bc

commit r11-11394-g35b198ed957d089f095724e91165cf082e9be1bc
Author: Francois-Xavier Coudert 
Date:   Mon Oct 30 15:41:10 2023 +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)

Diff:
---
 gcc/testsuite/gcc.target/i386/pr105554.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.target/i386/pr105554.c 
b/gcc/testsuite/gcc.target/i386/pr105554.c
index 08e90bb3368..e9ef494270a 100644
--- a/gcc/testsuite/gcc.target/i386/pr105554.c
+++ b/gcc/testsuite/gcc.target/i386/pr105554.c
@@ -1,5 +1,6 @@
 /* PR target/105554 */
 /* { dg-do compile } */
+/* { dg-require-ifunc "" } */
 /* { dg-options "-O2 -Wno-psabi -mno-sse3" } */
 
 typedef long long v4di __attribute__((__vector_size__(32)));


[gcc r11-11393] Testsuite: fix analyzer tests on Darwin

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:ee2f7a02371aba24f6db6231ae862cd2248bf45f

commit r11-11393-gee2f7a02371aba24f6db6231ae862cd2248bf45f
Author: Francois-Xavier Coudert 
Date:   Sat Aug 19 23:22:06 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/analyzer/analyzer.exp | 8 
 1 file changed, 8 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/analyzer/analyzer.exp 
b/gcc/testsuite/gcc.dg/analyzer/analyzer.exp
index e4b198bee87..7a2f7e906e9 100644
--- a/gcc/testsuite/gcc.dg/analyzer/analyzer.exp
+++ b/gcc/testsuite/gcc.dg/analyzer/analyzer.exp
@@ -32,6 +32,14 @@ if [info exists DEFAULT_CFLAGS] then {
 # If a testcase doesn't have special options, use these.
 set DEFAULT_CFLAGS "-fanalyzer -Wanalyzer-too-complex 
-fanalyzer-call-summaries"
 
+if { [istarget "*-*-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
+  set DEFAULT_CFLAGS "$DEFAULT_CFLAGS -D_FORTIFY_SOURCE=0"
+}
+
 # Initialize `dg'.
 dg-init


[gcc r11-11392] testsuite, asan: Avoid color in asan test output.

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:57596bb82e31d2dfdba2eb41c16e45a9bbeb38a7

commit r11-11392-g57596bb82e31d2dfdba2eb41c16e45a9bbeb38a7
Author: Iain Sandoe 
Date:   Sun Jun 19 10:31:01 2022 +0100

testsuite, asan: Avoid color in asan test output.

The presence of the color markers in the some of the asan tests
appears to confuse the dg-output matching (possibly a platform
TCL or termios bug) on some Darwin platforms.

Since the color is not being tested, switch it off (makes the log
files easier to read too).  This fixes a large number of spurious
test fails on AVX512 Darwin19.

Signed-off-by: Iain Sandoe 

gcc/testsuite/ChangeLog:

* lib/asan-dg.exp: Do not apply color to asan output when
under test.

(cherry picked from commit 607118dfa47a1865dc59f98e7d161da98471d688)

Diff:
---
 gcc/testsuite/lib/asan-dg.exp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/lib/asan-dg.exp b/gcc/testsuite/lib/asan-dg.exp
index e926dc3ad03..954b0ae22d4 100644
--- a/gcc/testsuite/lib/asan-dg.exp
+++ b/gcc/testsuite/lib/asan-dg.exp
@@ -111,6 +111,8 @@ proc asan_init { args } {
 global asan_saved_TEST_ALWAYS_FLAGS
 global asan_saved_ALWAYS_CXXFLAGS
 
+setenv ASAN_OPTIONS "color=never"
+
 set link_flags ""
 if ![is_remote host] {
if [info exists TOOL_OPTIONS] {


[gcc r11-11391] Testsuite: mark IPA test as requiring alias support

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:f80d7cf40f986bc6983008cd2fb24853a3b87ab1

commit r11-11391-gf80d7cf40f986bc6983008cd2fb24853a3b87ab1
Author: Francois-Xavier Coudert 
Date:   Sun Aug 20 14:13:22 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c 
b/gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c
index 452e1b88514..57c5262dd4a 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c
@@ -1,4 +1,5 @@
 /* { dg-do link } */
+/* { dg-require-alias "" } */
 /* { dg-options "-O2 -fdump-ipa-icf-optimized -flto -fdump-tree-optimized" } */
 /* { dg-require-effective-target lto } */
 /* { dg-additional-sources "ipa-icf-38a.c" }*/


[gcc r11-11390] testsuite, Objective-C: Fix duplicate libobjc cases.

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:e07bed1e7f67aebc288e8e220402b6d628d4b443

commit r11-11390-ge07bed1e7f67aebc288e8e220402b6d628d4b443
Author: Iain Sandoe 
Date:   Thu Jan 25 20:17:42 2024 +

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 
(cherry picked from commit 30d9e81c19d69e15b2e9c53e4377879cbf9b0b84)

Diff:
---
 gcc/testsuite/obj-c++.dg/encode-10.mm | 1 -
 gcc/testsuite/obj-c++.dg/encode-9.mm  | 1 -
 2 files changed, 2 deletions(-)

diff --git a/gcc/testsuite/obj-c++.dg/encode-10.mm 
b/gcc/testsuite/obj-c++.dg/encode-10.mm
index 2b3af88dcb1..2477400b7f3 100644
--- a/gcc/testsuite/obj-c++.dg/encode-10.mm
+++ b/gcc/testsuite/obj-c++.dg/encode-10.mm
@@ -1,5 +1,4 @@
 /* Test for @encode in templates.  */
-/* { dg-options "-lobjc" } */
 /* { dg-do run } */
 #include
 #include 
diff --git a/gcc/testsuite/obj-c++.dg/encode-9.mm 
b/gcc/testsuite/obj-c++.dg/encode-9.mm
index 6b064dfdc09..4fdb5fa50fb 100644
--- a/gcc/testsuite/obj-c++.dg/encode-9.mm
+++ b/gcc/testsuite/obj-c++.dg/encode-9.mm
@@ -1,5 +1,4 @@
 /* Test than @encode is properly instantiated. */
-/* { dg-options "-lobjc" } */
 /* { dg-do run } */
 
 #include 


[gcc r11-11389] Darwin: Correct handling of weak crts.

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:61d0cd29f9f107bee1d193b75b87d0ebe0766ede

commit r11-11389-g61d0cd29f9f107bee1d193b75b87d0ebe0766ede
Author: Iain Sandoe 
Date:   Thu Mar 21 14:34:44 2024 +

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 

Diff:
---
 gcc/config/darwin.h | 37 ++---
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index e2aa6b745d0..1fded756c60 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -351,7 +351,9 @@ extern GTY(()) int darwin_ms_struct;
 %{e*} %{r} \
 %{o*}%{!o:-o a.out} \
 %{!r:%{!nostdlib:%{!nostartfiles:%S}}} \
-%{L*} %(link_libgcc) %o \
+%{L*} %(link_libgcc) \
+%{!r:%{!nostdlib:%{!nodefaultlibs: " DARWIN_WEAK_CRTS "}}} \
+%o \
 %{!r:%{!nostdlib:%{!nodefaultlibs:\
   %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
   %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \
@@ -365,15 +367,15 @@ extern GTY(()) int darwin_ms_struct;
   %(link_ssp) \
   %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \
   %(link_gcc_c_sequence) \
-  %{!nodefaultexport:%{dylib|dynamiclib|bundle: \
-   %:version-compare(>= 10.11 asm_macosx_version_min= -U) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= 
___emutls_get_address) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= 
___emutls_get_address) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= -U) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= 
___emutls_register_common) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= 
___emutls_register_common) \
+  %{!nodefaultexport: \
+   %{%:version-compare(>= 10.11 asm_macosx_version_min= -U): \
+  ___emutls_get_address -exported_symbol ___emutls_get_address \
+ -U ___emutls_register_common \
+ -exported_symbol ___emutls_register_common \
+ -U ___gcc_nested_func_ptr_created \
+ -exported_symbol ___gcc_nested_func_ptr_created \
+ -U ___gcc_nested_func_ptr_deleted \
+ -exported_symbol ___gcc_nested_func_ptr_deleted \
   }} \
 }}}\
 %{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\
@@ -500,17 +502,22 @@ extern GTY(()) int darwin_ms_struct;
 #undef REAL_LIBGCC_SPEC
 #define REAL_LIBGCC_SPEC \
 "%{static-libgcc|static: \
-%:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh) \
-%:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w);
  \
+%:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh);\
shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime:  \
 %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \
-%:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w)
  \
 %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh)   \
 %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4)   \
-%:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5);   \
-   : -lemutls_w
  \
+%:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)\
   } -lgcc "
 
+#define DARWIN_WEAK_CRTS \
+"%{static-libgcc|static: \
+   %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w) ; \
+   shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \
+ %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) ; \
+   : -lemutls_w \
+  }"
+
 /* We specify crt0.o as -lcrt0.o so that ld will search the library path.  */
 
 #undef  STARTFILE_SPEC


[gcc r11-11388] Objective-C, Darwin: Do not overalign CFStrings and Objective-C metadata.

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:88d9c5bfb17ef5c5288eb58ddc64dee7d52ecdf4

commit r11-11388-g88d9c5bfb17ef5c5288eb58ddc64dee7d52ecdf4
Author: Iain Sandoe 
Date:   Thu Jan 25 20:11:09 2024 +

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.c (darwin_build_constant_cfstring): Prevent over-
alignment of CFString constants by setting DECL_USER_ALIGN.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (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.c (generate_strings): Likewise.

Signed-off-by: Iain Sandoe 
(cherry picked from commit f74f840d35117bcaf995cee99fb2ab30c60f64f3)

Diff:
---
 gcc/config/darwin.c|  1 +
 gcc/objc/objc-next-runtime-abi-02.c| 18 +++---
 gcc/objc/objc-runtime-shared-support.c |  4 
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index ec779332544..6e887a9ba5a 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3867,6 +3867,7 @@ darwin_build_constant_cfstring (tree str)
   /* global namespace.  */
   DECL_CONTEXT (var) = NULL_TREE;
   DECL_INITIAL (var) = constructor;
+  DECL_USER_ALIGN (var) = 1;
   lang_hooks.decls.pushdecl (var);
   rest_of_decl_compilation (var, 1, 0);
   desc->ccf_str = var;
diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index 0c59299db05..cb22a773fcb 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -2251,6 +2251,7 @@ build_v2_address_table (vec *src, const char 
*nam, tree attr)
   DECL_PRESERVE_P (decl) = 1;
   expr = objc_build_constructor (type, initlist);
   OBJCMETA (decl, objc_meta, attr);
+  DECL_USER_ALIGN (decl) = 1;
   finish_var_decl (decl, expr);
 }
 
@@ -2325,8 +2326,9 @@ build_v2_protocol_list_address_table (void)
decl = create_global_decl (objc_protocol_type, buf, /*is def=*/true);
   expr = convert (objc_protocol_type, build_fold_addr_expr (ref->refdecl));
   OBJCMETA (decl, objc_meta, meta_label_protocollist);
-  finish_var_decl (decl, expr);
   DECL_PRESERVE_P (decl) = 1;
+  DECL_USER_ALIGN (decl) = 1;
+  finish_var_decl (decl, expr);
 }
 
 /* TODO: delete the vec.  */
@@ -2404,6 +2406,7 @@ generate_v2_protocol_list (tree i_or_p, tree klass_ctxt)
   /* ObjC2 puts all these in the base section.  */
   OBJCMETA (refs_decl, objc_meta, meta_base);
   DECL_PRESERVE_P (refs_decl) = 1;
+  DECL_USER_ALIGN (refs_decl) = 1;
   finish_var_decl (refs_decl,
   objc_build_constructor (TREE_TYPE (refs_decl),initlist));
   return refs_decl;
@@ -2512,6 +2515,7 @@ generate_v2_meth_descriptor_table (tree chain, tree 
protocol,
   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, initlist);
   /* Get into the right section.  */
   OBJCMETA (decl, objc_meta, attr);
+  DECL_USER_ALIGN (decl) = 1;
   finish_var_decl (decl, objc_build_constructor (method_list_template, v));
   return decl;
 }
@@ -2530,13 

[gcc r11-11387] Objective-C/C++: Ensure sufficient setup for the preprocessor.

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:acfa562eaa440bf2bd5bd09035bd8bbde5d37d60

commit r11-11387-gacfa562eaa440bf2bd5bd09035bd8bbde5d37d60
Author: Iain Sandoe 
Date:   Tue Jan 9 17:31:41 2024 +

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.c (objc_init): Initialize interface and class
name hash maps before the preprocessor uses them.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 60f58d0630805e8dce79f5489658fd83e42fa8f1)

Diff:
---
 gcc/objc/objc-act.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 536ec028dbd..cb1fcbb2086 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -347,6 +347,11 @@ bool
 objc_init (void)
 {
   bool ok;
+
+  /* Set up stuff used by the preprocessor as well as FE parser.  */
+  interface_hash_init ();
+  hash_init ();
+
 #ifdef OBJCPLUS
   if (cxx_init () == false)
 #else
@@ -376,8 +381,6 @@ objc_init (void)
 
   /* Set up stuff used by FE parser and all runtimes.  */
   errbuf = XNEWVEC (char, 1024 * 10);
-  interface_hash_init ();
-  hash_init ();
   objc_encoding_init ();
   /* ... and then check flags and set-up for the selected runtime ... */
   if (flag_next_runtime && flag_objc_abi >= 2)


[gcc r11-11386] Darwin: Fix a typo in Objective-C meta-data.

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:310b047f4b723e0dd21a212c8ba051c380030cf4

commit r11-11386-g310b047f4b723e0dd21a212c8ba051c380030cf4
Author: Iain Sandoe 
Date:   Mon Jan 8 16:17:04 2024 +

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.c (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 
(cherry picked from commit 8d26636f0da31e6c17b57ced52bfc61a45f23cee)

Diff:
---
 gcc/config/darwin.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 4f1221d636c..ec779332544 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -1596,7 +1596,7 @@ darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree 
meta, section * base)
   else if (!strncmp (p, "V1_CEXT", 7))
 return darwin_sections[objc1_class_ext_section];
 
-  else if (!strncmp (p, "V2_CSTR", 7))
+  else if (!strncmp (p, "V1_CSTR", 7))
 return darwin_sections[objc_constant_string_object_section];
 
   return base;
@@ -1740,7 +1740,7 @@ machopic_select_section (tree decl,
return base_section; /* GNU runtime is happy with it all in one pot.  */
 }
 
-  /* b) Constant string objects.  */
+  /* b) Constructors for constant NSstring [but not CFString] objects.  */
   if (TREE_CODE (decl) == CONSTRUCTOR
   && TREE_TYPE (decl)
   && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
@@ -1762,6 +1762,12 @@ machopic_select_section (tree decl,
  else
return darwin_sections[objc_string_object_section];
}
+  else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString"))
+   {
+ /* We should have handled __anon_cfstrings above.  */
+ gcc_checking_assert (0);
+ return darwin_sections[cfstring_constant_object_section];
+   }
   else
return base_section;
 }


[gcc r11-11385] Darwin: Fix constant CFString code-gen [PR105522].

2024-04-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a1b0ace9737a40957bfb298de22066d8ee9a6603

commit r11-11385-ga1b0ace9737a40957bfb298de22066d8ee9a6603
Author: Iain Sandoe 
Date:   Sat Jan 6 10:52:38 2024 +

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.c (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 
(cherry picked from commit aecc0d4ba73d0810334b351da1e67232cea450d3)

Diff:
---
 gcc/config/darwin.c | 97 -
 gcc/config/darwin.h |  2 +
 gcc/testsuite/gcc.dg/pr105522.c | 17 
 3 files changed, 76 insertions(+), 40 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 2a3de33ee95..4f1221d636c 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -1689,7 +1689,16 @@ machopic_select_section (tree decl,
base_section = darwin_sections[zobj_data_section];
}
   else if (ro)
-   base_section = darwin_sections[const_data_section];
+   {
+ if (VAR_P (decl) && TREE_TYPE (decl)
+ && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
+ && DECL_NAME (decl)
+ && strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)),
+ "__anon_cfstring", 15) == 0)
+  base_section = darwin_sections[cfstring_constant_object_section];
+ else
+   base_section = darwin_sections[const_data_section];
+   }
   else
base_section = data_section;
   break;
@@ -1753,8 +1762,6 @@ machopic_select_section (tree decl,
  else
return darwin_sections[objc_string_object_section];
}
-  else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString"))
-   return darwin_sections[cfstring_constant_object_section];
   else
return base_section;
 }
@@ -3570,6 +3577,29 @@ darwin_patch_builtins (void)
 }
 #endif
 
+void
+darwin_rename_builtins (void)
+{
+}
+
+/* Implementation for the TARGET_LIBC_HAS_FUNCTION hook.  */
+
+bool
+darwin_libc_has_function (enum function_class fn_class,
+ tree type ATTRIBUTE_UNUSED)
+{
+  if (fn_class == function_sincos && darwin_macosx_version_min)
+return (strverscmp (darwin_macosx_version_min, "10.9") >= 0);
+#if DARWIN_PPC && SUPPORT_DARWIN_LEGACY
+  if (fn_class == function_c99_math_complex
+  || fn_class == function_c99_misc)
+return (TARGET_64BIT
+   || (darwin_macosx_version_min &&
+   strverscmp (darwin_macosx_version_min, "10.3") >= 0));
+#endif
+  return default_libc_has_function (fn_class, type);
+}
+
 /*  CFStrings implementation.  */
 static GTY(()) tree cfstring_class_reference = NULL_TREE;
 static GTY(()) tree cfstring_type_node = NULL_TREE;
@@ -3587,7 +3617,7 @@ typedef struct GTY ((for_user)) cfstring_descriptor {
   /* The string literal.  */
   tree literal;
   /* The resulting constant CFString.  */
-  tree constructor;
+  tree ccf_str;
 } cfstring_descriptor;
 
 struct cfstring_hasher : ggc_ptr_hash
@@ -3662,7 +3692,7 @@ 

[gcc r11-11383] Objective-C, Darwin: Fix a regression in handling bad receivers.

2024-04-27 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:c01efafd7fc6d3ff58db930fd785a8bcd991ac54

commit r11-11383-gc01efafd7fc6d3ff58db930fd785a8bcd991ac54
Author: Iain Sandoe 
Date:   Sat Jan 6 19:21:40 2024 +

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.c
(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 
(cherry picked from commit 846794ead2982fc85a3b1a83bbb831fa096b2b7c)

Diff:
---
 gcc/objc/objc-next-runtime-abi-02.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index 2a4f87cc726..0c59299db05 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -1663,6 +1663,8 @@ build_v2_objc_method_fixup_call (int super_flag, tree 
method_prototype,
   rcv_p = (super_flag ? objc_super_type : objc_object_type);
 
   lookup_object = build_c_cast (input_location, rcv_p, lookup_object);
+  if (sender == error_mark_node || lookup_object == error_mark_node)
+return error_mark_node;
 
   /* Use SAVE_EXPR to avoid evaluating the receiver twice.  */
   lookup_object = save_expr (lookup_object);


[gcc r11-11382] Testsuite, Darwin: Adjust handling of PIE test

2024-04-27 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:293140dfc6dbe7ab70c1f031f0dac6939bb084d6

commit r11-11382-g293140dfc6dbe7ab70c1f031f0dac6939bb084d6
Author: Francois-Xavier Coudert 
Date:   Mon Oct 30 12:41:17 2023 +0100

Testsuite, Darwin: Adjust handling of PIE test

gcc/ChangeLog:

* config/darwin.c (darwin_override_options): Cannot use
OPTION_SET_P here.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit a0c557690c8d5327deda6e21f8d1deca8451a4cb)

Co-authored-by: Iain Sandoe 

Diff:
---
 gcc/config/darwin.c  | 2 +-
 gcc/testsuite/gcc.dg/pie-2.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 61f04a1b209..2a3de33ee95 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3455,7 +3455,7 @@ darwin_override_options (void)
   && write_symbols == DWARF2_DEBUG)
 flag_var_tracking_uninit = flag_var_tracking;
 
-  if (OPTION_SET_P (flag_pie) && flag_pie)
+  if (global_options_set.x_flag_pie && flag_pie)
 {
   /* This is a little complicated, to match Xcode tools.
 For Darwin, PIE requires PIC codegen, but otherwise is only a link-
diff --git a/gcc/testsuite/gcc.dg/pie-2.c b/gcc/testsuite/gcc.dg/pie-2.c
index 1838745a11a..0a1cc27a503 100644
--- a/gcc/testsuite/gcc.dg/pie-2.c
+++ b/gcc/testsuite/gcc.dg/pie-2.c
@@ -2,6 +2,7 @@
 /* { dg-options "-fPIE" } */
 /* { dg-require-effective-target pie } */
 /* { dg-skip-if "__PIC__ is always 1 for MIPS" { mips*-*-* } } */
+/* { dg-skip-if "__PIE__ is often not defined on darwin" { *-*-darwin* } } */
 
 #if __PIC__ != 2
 # error __PIC__ is not 2!


[gcc r11-11381] Darwin: Handle the fPIE option specially.

2024-04-27 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:65f028e25fd0239b0b2ba6485653fd4dce131da8

commit r11-11381-g65f028e25fd0239b0b2ba6485653fd4dce131da8
Author: Iain Sandoe 
Date:   Wed Oct 25 15:28:52 2023 +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.c (darwin_override_options): Handle fPIE.

Signed-off-by: Iain Sandoe 
(cherry picked from commit da9e72f80f3358bd9586e11aaf03341c1f867318)

Diff:
---
 gcc/config/darwin.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 574424ac11c..61f04a1b209 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3284,6 +3284,8 @@ darwin_override_options (void)
 {
   if (strverscmp (darwin_macosx_version_min, "10.14") >= 0)
generating_for_darwin_version = 18;
+  else if (strverscmp (darwin_macosx_version_min, "10.8") >= 0)
+   generating_for_darwin_version = 12;
   else if (strverscmp (darwin_macosx_version_min, "10.7") >= 0)
generating_for_darwin_version = 11;
   else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0)
@@ -3453,8 +3455,17 @@ darwin_override_options (void)
   && write_symbols == DWARF2_DEBUG)
 flag_var_tracking_uninit = flag_var_tracking;
 
-  /* Final check on PCI options; for Darwin these are not dependent on the PIE
- ones, although PIE does require PIC to support it.  */
+  if (OPTION_SET_P (flag_pie) && flag_pie)
+{
+  /* This is a little complicated, to match Xcode tools.
+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 Darwin12-17 and for 32b only.  */
+  flag_pie = generating_for_darwin_version >= 12 && !TARGET_64BIT ? 2 : 0;
+  flag_pic = 2; /* We always set this.  */
+}
+
+  /* Final check on PIC options.  */
   if (MACHO_DYNAMIC_NO_PIC_P)
 {
   if (flag_pic)


[gcc r11-11380] Darwin: Make metadata symbol lables linker-visible for GNU objc.

2024-04-27 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:441effdb320d4939a1d09246ba1370d733c3218a

commit r11-11380-g441effdb320d4939a1d09246ba1370d733c3218a
Author: Iain Sandoe 
Date:   Sat Sep 30 17:15:16 2023 +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 seaprate 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 
(cherry picked from commit 24709788e40bc26dfb49585e752fad503fdced71)

Diff:
---
 gcc/config/darwin.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index ef598f10c90..2dfdf8546e6 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -839,7 +839,7 @@ int darwin_label_is_anonymous_local_objc_name (const char 
*name);
else if (xname[0] == '+' || xname[0] == '-') \
  fprintf (FILE, "\"%s\"", xname);   \
else if (darwin_label_is_anonymous_local_objc_name (xname))  \
- fprintf (FILE, "L%s", xname);  \
+   fprintf (FILE, "%c%s", flag_next_runtime ? 'L' : 'l', xname);\
else if (xname[0] != '"' && name_needs_quotes (xname))   \
 asm_fprintf (FILE, "\"%U%s\"", xname);  \
else \


[gcc r11-11379] testsuite, Darwin: Skip g++.dg/debug/dwarf2/pr85550.C

2024-04-27 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:b7c784f58fa7b4afe4cd8546a698df03b88b6fed

commit r11-11379-gb7c784f58fa7b4afe4cd8546a698df03b88b6fed
Author: Iain Sandoe 
Date:   Sun Oct 1 20:38:44 2023 +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 
(cherry picked from commit 76547f4c97b1c0744487d624c5e2e5a15d0370a9)

Diff:
---
 gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C 
b/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C
index 35b0f56e959..c95f75255d4 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C
@@ -2,6 +2,7 @@
 // { dg-do link }
 // { dg-options "-O2 -g -fdebug-types-section" }
 // { dg-skip-if "AIX DWARF5" { powerpc-ibm-aix* } }
+// { dg-skip-if "No debug linker support" { *-*-darwin* } }
 
 struct A {
   int bar () const { return 0; }


[gcc r11-11378] Testsuite, DWARF2: adjust regexp to match darwin output

2024-04-27 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:248b70a39b361ec425a5ba1131bc54f1a319f121

commit r11-11378-g248b70a39b361ec425a5ba1131bc54f1a319f121
Author: Francois-Xavier Coudert 
Date:   Sun Aug 20 12:53:19 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c 
b/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
index 2faef6e2a4f..22eb35fcf09 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
@@ -2,7 +2,7 @@
the DW_TAG_inlined_subroutine and the DW_TAG_variable for the local.  */
 /* { dg-options "-O -gdwarf -dA" } */
 /* { dg-do compile } */
-/* { dg-final { scan-assembler 
"DW_TAG_inlined_subroutine\[^\\(\]*\\(\[^\\)\]*\\)\[^\\(\]*\\(DIE 
\\(0x\[0-9a-f\]*\\) DW_TAG_formal_parameter\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) 
DW_TAG_variable" } } */
+/* { dg-final { scan-assembler 
"DW_TAG_inlined_subroutine\[^\\(\]*\(\|\\(\[^\\)\]*\\)\)\[^\\(\]*\\(DIE 
\\(0x\[0-9a-f\]*\\) DW_TAG_formal_parameter\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) 
DW_TAG_variable" } } */
 /* { dg-final { scan-assembler-times "DW_TAG_inlined_subroutine" 2 } } */
 
 static int foo (int i)


[gcc r11-11377] Darwin: Handle -dynamiclib on cc1 lines.

2024-04-27 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a68f243ec78b96bce9f10ad4c2c86c1b2e6015b7

commit r11-11377-ga68f243ec78b96bce9f10ad4c2c86c1b2e6015b7
Author: Iain Sandoe 
Date:   Tue Sep 26 09:47:46 2023 +0100

Darwin: Handle -dynamiclib on cc1 lines.

The changes of r14-4172 missed a case where we accept -dynamiclib on the
command line and then pass it to cc1 (which does not accept it).

This prunes the -dynamiclib from cc1 lines.

gcc/ChangeLog:

* config/darwin.h (DARWIN_CC1_SPEC): Remove -dynamiclib.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 3b18fd28c83ac90bf408389c003ed25d93438210)

Diff:
---
 gcc/config/darwin.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 430f12662e9..ef598f10c90 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -288,7 +288,7 @@ extern GTY(()) int darwin_ms_struct;
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) }"
 
 #define DARWIN_CC1_SPEC
\
-  "%

[gcc r11-11376] Darwin: Move checking of the 'shared' driver spec.

2024-04-27 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a0121359733b2c476131ea34534b53bd3ce92521

commit r11-11376-ga0121359733b2c476131ea34534b53bd3ce92521
Author: Iain Sandoe 
Date:   Sun Jul 9 09:02:39 2023 +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.

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)

Diff:
---
 gcc/config/darwin.h | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 9cae0165ae9..430f12662e9 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -131,10 +131,9 @@ extern GTY(()) int darwin_ms_struct;
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 %= 10.7 mmacosx-version-min= -no_pie) }"
 
 #define DARWIN_CC1_SPEC
\
-  "%

[gcc r11-11373] Darwin: Correct a version check.

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:dca9066e7deda6182b722ee4373f08909b8236d9

commit r11-11373-gdca9066e7deda6182b722ee4373f08909b8236d9
Author: Iain Sandoe 
Date:   Mon Apr 1 20:47:25 2024 +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.c (darwin_override_options): Update the
clang major version value in the dsymutil check.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 451bb0b9262d2f54173937569a29d7f1ad234e30)

Diff:
---
 gcc/config/darwin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 0564e6f0218..574424ac11c 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3369,7 +3369,7 @@ darwin_override_options (void)
   /* External toolchains based on LLVM or clang 7+ have support for
 dwarf-4.  */
   if ((dsymutil_version.kind == LLVM && dsymutil_version.major >= 7)
- || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 7))
+ || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 700))
dwarf_version = 4;
   else if (dsymutil_version.kind == DWARFUTILS
   && dsymutil_version.major >= 121)


[gcc r11-11372] Darwin: Check as for .build_version support and use it if available.

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:9702d54788021b1f48a2fd1fe9f13607d37f491f

commit r11-11372-g9702d54788021b1f48a2fd1fe9f13607d37f491f
Author: Iain Sandoe 
Date:   Tue Oct 17 11:10:27 2023 +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.c (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 
(cherry picked from commit a4184c8a65a00eaf8a8d7f92fb8ad2f8621b39e2)

Diff:
---
 gcc/config.in   |  6 ++
 gcc/config/darwin.c | 34 --
 gcc/configure   | 49 +++--
 gcc/configure.ac| 12 ++--
 4 files changed, 91 insertions(+), 10 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index 982c453ca36..6dd0ff010ce 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -598,6 +598,12 @@
 #endif
 
 
+/* Define if your macOS assembler supports .build_version directives */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_MACOS_BUILD_VERSION
+#endif
+
+
 /* Define if the assembler understands -march=rv*_zifencei. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_MARCH_ZIFENCEI
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index e01460a996f..0564e6f0218 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3032,7 +3032,35 @@ darwin_asm_output_dwarf_offset (FILE *file, int size, 
const char * lab,
 void
 darwin_file_start (void)
 {
-  /* Nothing to do.  */
+#ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION
+  /* This should not happen with a well-formed command line, but the user could
+ invoke cc1* directly without it.  */
+  if (!darwin_macosx_version_min)
+return;
+  /* This assumes that the version passed has been validated in the driver.  */
+  unsigned maj, min, tiny;
+  int count = sscanf (darwin_macosx_version_min, "%u.%u.%u", , , 
);
+  if (count < 0)
+return;
+  if (count < 3)
+tiny = 0;
+  if (count < 2)
+min = 0;
+  const char *directive;
+#ifdef HAVE_AS_MACOS_BUILD_VERSION
+  /* We only handle macos, so far.  */
+  if (generating_for_darwin_version >= 18)
+directive = "build_version macos, ";
+  else
+#endif
+directive = "macosx_version_min ";
+  if (count > 2 && tiny != 0)
+fprintf (asm_out_file, "\t.%s %u, %u, %u\n", directive, maj, min, tiny);
+  else if (count > 1)
+fprintf (asm_out_file, "\t.%s %u, %u\n", directive, maj, min);
+  else
+ fprintf (asm_out_file, "\t.%s %u, 0\n", directive, maj);
+#endif
 }
 
 /* Called for the TARGET_ASM_FILE_END hook.
@@ -3254,7 +3282,9 @@ darwin_override_options (void)
   /* Keep track of which (major) version we're generating code for.  */
   if (darwin_macosx_version_min)
 {
-  if (strverscmp (darwin_macosx_version_min, "10.7") >= 0)
+  if (strverscmp (darwin_macosx_version_min, "10.14") >= 0)
+   generating_for_darwin_version = 18;
+  else if (strverscmp (darwin_macosx_version_min, "10.7") >= 0)
generating_for_darwin_version = 11;
   else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0)
generating_for_darwin_version = 10;
diff --git a/gcc/configure b/gcc/configure
index d2ad1628edd..86f44a35f42 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -26007,16 +26007,22 @@ if ${gcc_cv_as_mmacosx_version_min+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   gcc_cv_as_mmacosx_version_min=no
-  if test x$gcc_cv_as != x; then
-$as_echo '.text' > conftest.s
-if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mmacosx-version-min=10.1 -o 
conftest.o conftest.s >&5'
+if test $in_tree_gas = yes; then
+if test $gcc_cv_gas_vers -ge `expr \( \( -mmacosx-version-min=10.1 \* 1000 
\) + gcc_cv_as_mmacosx_version_min=yes \) \* 1000 + `
+  then :
+fi
+  elif test x$gcc_cv_as != x; then
+$as_echo '' > conftest.s
+if { ac_try='$gcc_cv_as $gcc_cv_as_flags .text -o conftest.o conftest.s 
>&5'
   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; }
 then
-   gcc_cv_as_mmacosx_version_min=yes
+
+$as_echo "#define 

[gcc r11-11371] Darwin, configure: Allow for an unrecognisable dsymutil [PR111610].

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:1fd4db58480a518b05dd835157e59b2ed9fd2bc1

commit r11-11371-g1fd4db58480a518b05dd835157e59b2ed9fd2bc1
Author: Iain Sandoe 
Date:   Wed Sep 27 11:05:31 2023 +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 
(cherry picked from commit 2ecab2f32b9e9a75bf563f80752d5b44dcd26b98)

Diff:
---
 gcc/configure| 2 +-
 gcc/configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index bf0bd5f428d..d2ad1628edd 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -30804,7 +30804,7 @@ $as_echo_n "checking dsymutil version 
\"$dsymutil_temp\"... " >&6; }
   dsymutil_kind=LLVM
   dsymutil_vers=`echo $dsymutil_temp | sed 's/.*LLVM\ version\ 
\([0-9\.]*\).*/\1/'`
 else
-  dsymutil_kind=UNKNOWN
+  dsymutil_kind=DET_UNKNOWN
   dsymutil_vers="0.0"
 fi
 dsymutil_major=`expr "$dsymutil_vers" : '\([0-9]*\)'`
diff --git a/gcc/configure.ac b/gcc/configure.ac
index d52104fbd41..7ea5c6fe51b 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -6438,7 +6438,7 @@ if test x"$dsymutil_flag" = x"yes"; then
   dsymutil_kind=LLVM
   dsymutil_vers=`echo $dsymutil_temp | sed 's/.*LLVM\ version\ 
\([[0-9\.]]*\).*/\1/'`
 else
-  dsymutil_kind=UNKNOWN
+  dsymutil_kind=DET_UNKNOWN
   dsymutil_vers="0.0"
 fi
 dsymutil_major=`expr "$dsymutil_vers" : '\([[0-9]]*\)'`


[gcc r11-11370] Darwin, debug : Switch to DWARF 3 or 4 when dsymutil supports it.

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:4805205720c5a3cd3997fb3d670f290856dba18d

commit r11-11370-g4805205720c5a3cd3997fb3d670f290856dba18d
Author: Iain Sandoe 
Date:   Sun Sep 17 15:56:07 2023 +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 

gcc/ChangeLog:

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

(cherry picked from commit 47346acb72b50d178dae72393c851d57beec383f)

Diff:
---
 gcc/config/darwin-protos.h | 11 +++
 gcc/config/darwin.c| 33 +
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h
index f5ef82456aa..440e76ead42 100644
--- a/gcc/config/darwin-protos.h
+++ b/gcc/config/darwin-protos.h
@@ -129,4 +129,15 @@ extern void darwin_patch_builtins (void);
 extern void darwin_rename_builtins (void);
 extern bool darwin_libc_has_function (enum function_class fn_class, tree);
 
+/* For this port, there are several possible sources for external toolchain
+   components (e.g. as, ld, dsymutil) and we have to alter the allowable
+   output in response to which version and source is in use.  */
+enum darwin_external_toolchain {
+  DET_UNKNOWN=0,
+  CCTOOLS,
+  DWARFUTILS,
+  LLVM,
+  CLANG
+};
+
 #endif /* CONFIG_DARWIN_PROTOS_H */
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index db0e80889ab..e01460a996f 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -111,6 +111,19 @@ static bool ld_needs_eh_markers = false;
 /* Emit a section-start symbol for mod init and term sections.  */
 static bool ld_init_term_start_labels = false;
 
+/* The source and version of dsymutil in use.  */
+#ifndef DSYMUTIL_VERSION
+# warning Darwin toolchain without a defined dsymutil.
+# define DSYMUTIL_VERSION DET_UNKNOWN,0,0,0
+#endif
+
+struct {
+  darwin_external_toolchain kind; /* cctools, llvm, clang etc.  */
+  int major; /* version number.  */
+  int minor;
+  int tiny;
+} dsymutil_version = {DSYMUTIL_VERSION};
+
 /* Section names.  */
 section * darwin_sections[NUM_DARWIN_SECTIONS];
 
@@ -3316,14 +3329,26 @@ darwin_override_options (void)
  global_options.x_flag_objc_abi);
 }
 
-  /* Don't emit DWARF3/4 unless specifically selected.  This is a
- workaround for tool bugs.  */
+  /* Limit DWARF to the chosen version, the linker and debug linker might not
+ be able to consume newer structures.  */
   if (!global_options_set.x_dwarf_strict)
 dwarf_strict = 1;
+
   if (!global_options_set.x_dwarf_version)
-dwarf_version = 2;
+{
+  /* External toolchains based on LLVM or clang 7+ have support for
+dwarf-4.  */
+  if ((dsymutil_version.kind == LLVM && dsymutil_version.major >= 7)
+ || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 7))
+   dwarf_version = 4;
+  else if (dsymutil_version.kind == DWARFUTILS
+  && dsymutil_version.major >= 121)
+   dwarf_version = 3;  /* From XC 6.4.  */
+  else
+   dwarf_version = 2;  /* Older cannot safely exceed dwarf-2.  */
+}
 
-  if (global_options_set.x_dwarf_split_debug_info)
+  if (global_options_set.x_dwarf_split_debug_info && dwarf_split_debug_info)
 {
   inform (input_location,
  "%<-gsplit-dwarf%> is not supported on this platform, ignored");


[gcc r11-11369] testsuite: adjust for darwin linker warning

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:12ce016bc52f88ebaa085f2af14854247570cca7

commit r11-11369-g12ce016bc52f88ebaa085f2af14854247570cca7
Author: Francois-Xavier Coudert 
Date:   Fri Sep 8 21:55:56 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/darwin-segaddr.c | 1 +
 gcc/testsuite/gcc.dg/pie-7.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/darwin-segaddr.c 
b/gcc/testsuite/gcc.dg/darwin-segaddr.c
index 526db77bd9c..77112ddb484 100644
--- a/gcc/testsuite/gcc.dg/darwin-segaddr.c
+++ b/gcc/testsuite/gcc.dg/darwin-segaddr.c
@@ -2,6 +2,7 @@
 /* { dg-do run { target *-*-darwin* } } */
 /* { dg-options "-O0 -segaddr __TEST 0x20 -fno-pie" { target { *-*-darwin* 
&& { ! lp64 } } } } */
 /* { dg-options "-O0 -segaddr __TEST 0x11000 -fno-pie" { target { 
*-*-darwin* && lp64 } } } */
+/* { dg-prune-output "-no_pie is deprecated when targeting new OS versions" } 
*/
 
 extern void abort ();
 
diff --git a/gcc/testsuite/gcc.dg/pie-7.c b/gcc/testsuite/gcc.dg/pie-7.c
index e118a98bafd..3879a6cc120 100644
--- a/gcc/testsuite/gcc.dg/pie-7.c
+++ b/gcc/testsuite/gcc.dg/pie-7.c
@@ -1,5 +1,6 @@
 /* { dg-do run { target pie } } */
 /* { dg-options "-fno-pie -no-pie" } */
+/* { dg-prune-output "-no_pie is deprecated when targeting new OS versions" } 
*/
 
 int main(void)
 {


[gcc r11-11368] Darwin, ppc: Add system stubs for all 32b PPC

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:7f93f55272b127257011f25937d4a39196322d2c

commit r11-11368-g7f93f55272b127257011f25937d4a39196322d2c
Author: Iain Sandoe 
Date:   Wed Jul 26 14:31:02 2023 +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 

gcc/ChangeLog:

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

(cherry picked from commit b3ab28c3e85af7995fffb87eb190ef942b7e9e4a)

Diff:
---
 gcc/config/rs6000/darwin.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h
index 566794af706..e80dd7c77b6 100644
--- a/gcc/config/rs6000/darwin.h
+++ b/gcc/config/rs6000/darwin.h
@@ -98,7 +98,7 @@
Include libmx when targeting Darwin 7.0 and above, but before libSystem,
since the functions are actually in libSystem but for 7.x compatibility
we want them to be looked for in libmx first.
-   Include libSystemStubs when compiling against 10.3 - 10.5 SDKs (we assume
+   Include libSystemStubs when compiling against 10.3 - 10.6 SDKs (we assume
this is the case when targetting these) - but not for 64-bit long double.
Don't do either for m64, the library is either a dummy or non-existent.
 */
@@ -107,8 +107,8 @@
 #define LIB_SPEC \
 "%{!static:\
   %{!m64:%{!mlong-double-64:   \
-%{pg:%:version-compare(>< 10.3 10.5 mmacosx-version-min= 
-lSystemStubs_profile)} \
-%{!pg:%:version-compare(>< 10.3 10.5 mmacosx-version-min= -lSystemStubs)} \
+%{pg:%:version-compare(>< 10.3 10.7 mmacosx-version-min= 
-lSystemStubs_profile)} \
+%{!pg:%:version-compare(>< 10.3 10.7 mmacosx-version-min= -lSystemStubs)} \
  %:version-compare(>< 10.3 10.4 mmacosx-version-min= -lmx)}}   \
   -lSystem \
 }"


[gcc r11-11367] Darwin: Partial reversion of r14-3648 (Inits Section).

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:960ca4144ebb61d125f28fab17b57cd3b09b49fd

commit r11-11367-g960ca4144ebb61d125f28fab17b57cd3b09b49fd
Author: Iain Sandoe 
Date:   Sun Sep 10 14:48:42 2023 +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.c (darwin_function_section): Place unlikely
executed global init code into the standard cold section.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 5b33b364652866165431aef1810af1e890229c5e)

Diff:
---
 gcc/config/darwin.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index a3a7c509e36..db0e80889ab 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3848,19 +3848,22 @@ darwin_function_section (tree decl, enum node_frequency 
freq,
   if (decl && DECL_SECTION_NAME (decl) != NULL)
 return get_named_section (decl, NULL, 0);
 
+  /* We always put unlikely executed stuff in the cold section; we have to put
+ this ahead of the global init section, since partitioning within a section
+ breaks some assumptions made in the DWARF handling.  */
+  if (freq == NODE_FREQUENCY_UNLIKELY_EXECUTED)
+return (use_coal) ? darwin_sections[text_cold_coal_section]
+ : darwin_sections[text_cold_section];
+
   /* Intercept functions in global init; these are placed in separate sections.
- FIXME: there should be some neater way to do this.  */
+ FIXME: there should be some neater way to do this, FIXME we should be able
+ to partition within a section.  */
   if (DECL_NAME (decl)
   && (strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "_GLOBAL__sub_I", 
14) == 0
  || strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)),
 "__static_initialization_and_destruction", 39) == 0))
 return  darwin_sections[static_init_section];
 
-  /* We always put unlikely executed stuff in the cold section.  */
-  if (freq == NODE_FREQUENCY_UNLIKELY_EXECUTED)
-return (use_coal) ? darwin_sections[text_cold_coal_section]
- : darwin_sections[text_cold_section];
-
   /* If we have LTO *and* feedback information, then let LTO handle
  the function ordering, it makes a better job (for normal, hot,
  startup and exit - hence the bailout for cold above).  */


[gcc r11-11366] Darwin: Place global inits in the correct section.

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:084d0c427433d592e29247164b199c1f232f5c68

commit r11-11366-g084d0c427433d592e29247164b199c1f232f5c68
Author: Iain Sandoe 
Date:   Fri Sep 1 09:04:13 2023 +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 

gcc/ChangeLog:

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

(cherry picked from commit 68dc3e94fd6bd395a8b343533485616dff3fc796)

Diff:
---
 gcc/config/darwin-sections.def | 2 ++
 gcc/config/darwin.c| 8 
 2 files changed, 10 insertions(+)

diff --git a/gcc/config/darwin-sections.def b/gcc/config/darwin-sections.def
index ed9e058d1d1..dc4d0408a85 100644
--- a/gcc/config/darwin-sections.def
+++ b/gcc/config/darwin-sections.def
@@ -98,6 +98,8 @@ DEF_SECTION (mod_init_section, 0, ".mod_init_func", 0)
 DEF_SECTION (mod_term_section, 0, ".mod_term_func", 0)
 DEF_SECTION (constructor_section, 0, ".constructor", 0)
 DEF_SECTION (destructor_section, 0, ".destructor", 0)
+DEF_SECTION (static_init_section, SECTION_CODE,
+".section\t__TEXT,__StaticInit,regular,pure_instructions", 0)
 
 /* Objective-C ABI=0 (Original version) sections.  */
 DEF_SECTION (objc_class_section, 0, ".objc_class", 1)
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index ddbd3943a1d..a3a7c509e36 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3848,6 +3848,14 @@ darwin_function_section (tree decl, enum node_frequency 
freq,
   if (decl && DECL_SECTION_NAME (decl) != NULL)
 return get_named_section (decl, NULL, 0);
 
+  /* Intercept functions in global init; these are placed in separate sections.
+ FIXME: there should be some neater way to do this.  */
+  if (DECL_NAME (decl)
+  && (strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "_GLOBAL__sub_I", 
14) == 0
+ || strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)),
+"__static_initialization_and_destruction", 39) == 0))
+return  darwin_sections[static_init_section];
+
   /* We always put unlikely executed stuff in the cold section.  */
   if (freq == NODE_FREQUENCY_UNLIKELY_EXECUTED)
 return (use_coal) ? darwin_sections[text_cold_coal_section]


[gcc r11-11365] Darwin: Match system sections and relocs for exception tables.

2024-04-25 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:9488ad0d780fae91afa910410cb4e6da8d607fd9

commit r11-11365-g9488ad0d780fae91afa910410cb4e6da8d607fd9
Author: Iain Sandoe 
Date:   Thu Aug 31 19:20:43 2023 +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 

gcc/ChangeLog:

* config/darwin-sections.def (darwin_exception_section): Move to
the __TEXT segment.
* config/darwin.c (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)

Diff:
---
 gcc/config/darwin-sections.def | 2 +-
 gcc/config/darwin.c| 1 +
 gcc/config/darwin.h| 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-sections.def b/gcc/config/darwin-sections.def
index 8be89624c9c..ed9e058d1d1 100644
--- a/gcc/config/darwin-sections.def
+++ b/gcc/config/darwin-sections.def
@@ -157,7 +157,7 @@ DEF_SECTION (machopic_picsymbol_stub3_section, 
SECTION_NO_ANCHOR,
 
 /* Exception-related.  */
 DEF_SECTION (darwin_exception_section, SECTION_NO_ANCHOR,
-".section __DATA,__gcc_except_tab", 0)
+".section __TEXT,__gcc_except_tab", 0)
 DEF_SECTION (darwin_eh_frame_section, SECTION_NO_ANCHOR,
 ".section " EH_FRAME_SECTION_NAME ",__eh_frame"
 EH_FRAME_SECTION_ATTR, 0)
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 2371816e251..ddbd3943a1d 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -2230,6 +2230,7 @@ darwin_emit_except_table_label (FILE *file)
 {
   char section_start_label[30];
 
+  fputs ("\t.p2align\t2\n", file);
   ASM_GENERATE_INTERNAL_LABEL (section_start_label, "GCC_except_table",
   except_table_label_num++);
   ASM_OUTPUT_LABEL (file, section_start_label);
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 5be13293319..9cae0165ae9 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -1098,7 +1098,7 @@ enum machopic_addr_class {
 
 #undef ASM_PREFERRED_EH_DATA_FORMAT
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  \
-  (((CODE) == 2 && (GLOBAL) == 1) \
+  (((CODE) == 2 && (GLOBAL) == 1) || ((CODE) == 0 && (GLOBAL) == 1) \
? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \
  ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)


[gcc r11-11361] Testsuite, darwin: account for macOS 13 and 14

2024-04-24 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:dbedcc5e0b6189e51060d69d442a610a0db82ac7

commit r11-11361-gdbedcc5e0b6189e51060d69d442a610a0db82ac7
Author: Francois-Xavier Coudert 
Date:   Mon Aug 21 00:00:44 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/darwin-minversion-link.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-link.c 
b/gcc/testsuite/gcc.dg/darwin-minversion-link.c
index b6ede31c985..a835e9d4648 100644
--- a/gcc/testsuite/gcc.dg/darwin-minversion-link.c
+++ b/gcc/testsuite/gcc.dg/darwin-minversion-link.c
@@ -17,6 +17,8 @@
 /* { dg-additional-options "-mmacosx-version-min=010.015.06 -DCHECK=101506" { 
target *-*-darwin19* } } */
 /* { dg-additional-options "-mmacosx-version-min=011.000.00 -DCHECK=11" { 
target *-*-darwin20* } } */
 /* { dg-additional-options "-mmacosx-version-min=012.000.00 -DCHECK=12" { 
target *-*-darwin21* } } */
+/* { dg-additional-options "-mmacosx-version-min=013.000.00 -DCHECK=13" { 
target *-*-darwin22* } } */
+/* { dg-additional-options "-mmacosx-version-min=014.000.00 -DCHECK=14" { 
target *-*-darwin23* } } */
 
 int
 main ()


[gcc r11-11360] fixincludes: Update darwin_flt_eval_method for macOS 14

2024-04-24 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:cb1e6094f3711897615c58ad6b0e53ec69ea9e39

commit r11-11360-gcb1e6094f3711897615c58ad6b0e53ec69ea9e39
Author: Rainer Orth 
Date:   Thu Aug 17 10:16:57 2023 +0200

fixincludes: Update darwin_flt_eval_method for macOS 14

On macOS 14, a guard in  changed:

-- MacOSX13.3.sdk/usr/include/math.h2023-04-19 01:54:44
+++ MacOSX14.0.sdk/usr/include/math.h   2023-08-01 08:42:43
@@ -22,0 +23 @@
+
@@ -43 +44 @@
-#if __FLT_EVAL_METHOD__ == 0
+#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1
@@ -49 +50 @@
-#elif __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ == -1
+#elif __FLT_EVAL_METHOD__ == 2

Therefore the darwin_flt_eval_method fixincludes fix doesn't match any
longer, leading to a large number of testsuite failures like


/private/var/gcc/regression/master/14-gcc/build/gcc/include-fixed/math.h:69:5:
error: #error "Unsupported value of __FLT_EVAL_METHOD__."

where __FLT_EVAL_METHOD__ = 16.

This patch adjusts the fix to allow for both forms.

Tested with make check in fixincludes on x86_64-apple-darwin23.0.0 and
verifying that  has indeed been fixed as expected.

2023-08-16  Rainer Orth  

fixincludes:
* inclhack.def (darwin_flt_eval_method): Handle macOS 14 guard
variant.
* fixincl.x: Regenerate.
* tests/base/math.h [DARWIN_FLT_EVAL_METHOD_CHECK]: Update test.

(cherry picked from commit 93f803d53b5ccaabded9d7b4512b54da81c1c616)

Diff:
---
 fixincludes/fixincl.x | 8 
 fixincludes/inclhack.def  | 7 ---
 fixincludes/tests/base/math.h | 1 +
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index 442de9226b5..055a9a03f85 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  April 12, 2024 at 12:46:40 PM by AutoGen 5.18.7
+ * It has been AutoGen-ed  April 12, 2024 at 01:20:56 PM by AutoGen 5.18.7
  * From the definitionsinclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Apr 12 12:46:40 BST 2024
+/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Apr 12 13:20:56 BST 2024
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -3674,7 +3674,7 @@ tSCC* apzDarwin_Flt_Eval_MethodMachs[] = {
  *  content selection pattern - do fix if pattern found
  */
 tSCC zDarwin_Flt_Eval_MethodSelect0[] =
-   "^#if __FLT_EVAL_METHOD__ == 0$";
+   "^#if __FLT_EVAL_METHOD__ == 0( \\|\\| __FLT_EVAL_METHOD__ == -1)?$";
 
 #defineDARWIN_FLT_EVAL_METHOD_TEST_CT  1
 static tTestDesc aDarwin_Flt_Eval_MethodTests[] = {
@@ -3685,7 +3685,7 @@ static tTestDesc aDarwin_Flt_Eval_MethodTests[] = {
  */
 static const char* apzDarwin_Flt_Eval_MethodPatch[] = {
 "format",
-"#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16",
+"%0 || __FLT_EVAL_METHOD__ == 16",
 (char*)NULL };
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 6478ca19932..0782fb05c85 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1819,10 +1819,11 @@ fix = {
 hackname  = darwin_flt_eval_method;
 mach  = "*-*-darwin*";
 files = math.h;
-select= "^#if __FLT_EVAL_METHOD__ == 0$";
+select= "^#if __FLT_EVAL_METHOD__ == 0( \\|\\| __FLT_EVAL_METHOD__ == 
-1)?$";
 c_fix = format;
-c_fix_arg = "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16";
-test_text = "#if __FLT_EVAL_METHOD__ == 0";
+c_fix_arg = "%0 || __FLT_EVAL_METHOD__ == 16";
+test_text = "#if __FLT_EVAL_METHOD__ == 0\n"
+   "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1";
 };
 
 /*
diff --git a/fixincludes/tests/base/math.h b/fixincludes/tests/base/math.h
index 58f695f9adf..8005e39bc32 100644
--- a/fixincludes/tests/base/math.h
+++ b/fixincludes/tests/base/math.h
@@ -32,6 +32,7 @@
 
 #if defined( DARWIN_FLT_EVAL_METHOD_CHECK )
 #if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16
+#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1 || 
__FLT_EVAL_METHOD__ == 16
 #endif  /* DARWIN_FLT_EVAL_METHOD_CHECK */


[gcc r11-11359] build: Allow for Xcode 15 ld -v output

2024-04-24 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:6e01c09e6bb841a31165e3a793628c847a0652c0

commit r11-11359-g6e01c09e6bb841a31165e3a793628c847a0652c0
Author: Rainer Orth 
Date:   Thu Aug 17 10:14:49 2023 +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  

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

(cherry picked from commit 0beac9209f0ae230b34ad31e76e7b0b633a5fb21)

Diff:
---
 gcc/configure| 3 ++-
 gcc/configure.ac | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index 0b9c7451231..bf0bd5f428d 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -30733,7 +30733,8 @@ $as_echo "$gcc_cv_ld64_major" >&6; }
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker version" >&5
 $as_echo_n "checking linker version... " >&6; }
 if test x"${gcc_cv_ld64_version}" = x; then
-  gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | grep ld64 | sed s/.*ld64-// | 
awk '{print $1}'`
+  gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | $EGREP 'ld64|dyld' \
+  | sed -e 's/.*ld64-//' -e 's/.*dyld-//'| awk '{print $1}'`
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_version" >&5
 $as_echo "$gcc_cv_ld64_version" >&6; }
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 2bf0e8a12b7..d52104fbd41 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -6383,7 +6383,8 @@ if test x"$ld64_flag" = x"yes"; then
 # If the version was not specified, try to find it.
 AC_MSG_CHECKING(linker version)
 if test x"${gcc_cv_ld64_version}" = x; then
-  gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | grep ld64 | sed s/.*ld64-// | 
awk '{print $1}'`
+  gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | $EGREP 'ld64|dyld' \
+  | sed -e 's/.*ld64-//' -e 's/.*dyld-//'| awk '{print $1}'`
 fi
 AC_MSG_RESULT($gcc_cv_ld64_version)


[gcc r11-11358] testsuite, objective-c++: Fix imported NSObjCRuntime.h.

2024-04-24 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:c2a39d977605e554177236bf524c97ff14196f95

commit r11-11358-gc2a39d977605e554177236bf524c97ff14196f95
Author: Iain Sandoe 
Date:   Fri Jun 23 15:29:14 2023 +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 

gcc/testsuite/ChangeLog:

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

(cherry picked from commit d83e0e3bc375a05844438d28c9a4ab24c5401eb9)

Diff:
---
 gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h 
b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h
index 189af80436a..62556f9ac88 100644
--- a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h
+++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h
@@ -29,6 +29,9 @@
 #ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
 #define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
 
+/* Allow the elaborated enum use in _GS_NAMED_ENUM. */
+#pragma GCC system_header
+
 #ifdef __cplusplus
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS 1


[gcc r11-11357] testsuite, objective-c: Cater for Windows intptr type.

2024-04-24 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:e3a4a568f4ac08ca981b41360aeab005cf6e41cf

commit r11-11357-ge3a4a568f4ac08ca981b41360aeab005cf6e41cf
Author: Iain Sandoe 
Date:   Thu Feb 16 16:18:11 2023 +

testsuite, objective-c: Cater for Windows intptr type.

This adjusts the diagnostic output matches to cater for the differences
in intptr types on Windows.

Patch from 'nightstrike'.

Signed-off-by: Iain Sandoe 

gcc/testsuite/ChangeLog:

* objc.dg/proto-lossage-4.m: Amendn diagnostic matches for Windows.

(cherry picked from commit 07f497c2da3600cc99cd7d1b5c6726972fb2b5a1)

Diff:
---
 gcc/testsuite/objc.dg/proto-lossage-4.m | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/objc.dg/proto-lossage-4.m 
b/gcc/testsuite/objc.dg/proto-lossage-4.m
index 9d1def5f9de..9b2367a568a 100644
--- a/gcc/testsuite/objc.dg/proto-lossage-4.m
+++ b/gcc/testsuite/objc.dg/proto-lossage-4.m
@@ -28,13 +28,13 @@ long foo(void) {
   receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type 
.intptr_t." } */
 
   receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not 
respond to .\\-someValue." } */
-/* { dg-warning "assignment to 'intptr_t' {aka '(long )?int'} from 'id' makes 
integer from pointer without a cast" "" { target *-*-* } .-1 } */
+/* { dg-warning "assignment to 'intptr_t' {aka '(long )*int'} from 'id' makes 
integer from pointer without a cast" "" { target *-*-* } .-1 } */
 
   receiver += [(Obj *)receiver anotherValue];
   receiver += [(Obj  *)receiver someValue];
   receiver += [(Obj  *)receiver anotherValue];
   receiver += [objrcvr someValue]; /* { dg-warning ".Obj. may not respond to 
.\\-someValue." } */
-/* { dg-warning "assignment to 'intptr_t' {aka '(long )?int'} from 'id' makes 
integer from pointer without a cast" "" { target *-*-* } .-1 } */
+/* { dg-warning "assignment to 'intptr_t' {aka '(long )*int'} from 'id' makes 
integer from pointer without a cast" "" { target *-*-* } .-1 } */
 
   receiver += [objrcvr anotherValue];
   receiver += [(Obj  *)objrcvr someValue];
@@ -42,7 +42,7 @@ long foo(void) {
   receiver += [objrcvr2 someValue];
   receiver += [objrcvr2 anotherValue];
   receiver += [(Obj *)objrcvr2 someValue]; /* { dg-warning ".Obj. may not 
respond to .\\-someValue." } */
-/* { dg-warning "assignment to 'intptr_t' {aka '(long )?int'} from 'id' makes 
integer from pointer without a cast" "" { target *-*-* } .-1 } */
+/* { dg-warning "assignment to 'intptr_t' {aka '(long )*int'} from 'id' makes 
integer from pointer without a cast" "" { target *-*-* } .-1 } */
 
   receiver += [(Obj *)objrcvr2 anotherValue];


[gcc r11-11355] testsuite: Add target requires for ifuncs to mv31.C.

2024-04-24 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:61e6a6d2aa139781de9b6b94206f6a526c0addaa

commit r11-11355-g61e6a6d2aa139781de9b6b94206f6a526c0addaa
Author: Iain Sandoe 
Date:   Thu Apr 28 08:51:48 2022 +0100

testsuite: Add target requires for ifuncs to mv31.C.

g++.target/i386/mv31.C fails on targets without ifuncs support so add
the necessary target supports guard.

Signed-off-by: Iain Sandoe 

gcc/testsuite/ChangeLog:

* g++.target/i386/mv31.C: Add target supports guard for ifuncs.

(cherry picked from commit 350fcc7884ba80f38dd1476ae41029c648a5f8b9)

Diff:
---
 gcc/testsuite/g++.target/i386/mv31.C | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/g++.target/i386/mv31.C 
b/gcc/testsuite/g++.target/i386/mv31.C
index 5d8fd1ddf75..70a40f1e28a 100644
--- a/gcc/testsuite/g++.target/i386/mv31.C
+++ b/gcc/testsuite/g++.target/i386/mv31.C
@@ -1,4 +1,5 @@
 // PR c++/104669
+// { dg-require-ifunc "" }
 
 void bar()
 {


[gcc r11-11354] Fixincludes: Handle __FLT_EVAL_METHOD__ == 16 on darwin

2024-04-24 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a58d68924cadd62021e248bf2c6f5af638f7e0f1

commit r11-11354-ga58d68924cadd62021e248bf2c6f5af638f7e0f1
Author: Francois-Xavier Coudert 
Date:   Sat Jan 1 12:22:00 2022 +0100

Fixincludes: Handle __FLT_EVAL_METHOD__ == 16 on darwin

The darwin system headers error out on __FLT_EVAL_METHOD__ == 16, which
occurs when the compiler is called with -mavx512fp16 on i386. Allow this
value to proceed past the check (nothing else depends on it in the
system headers).

fixincludes/ChangeLog:

* inclhack.def: Add new fix on darwin.
* fixincl.x: Regenerate.
* tests/base/math.h: Regenerate.

(cherry picked from commit 4f3b1a09d3109f03299a2ac15cfa3059596fcb1d)

Diff:
---
 fixincludes/fixincl.x | 53 +++
 fixincludes/inclhack.def  | 11 +
 fixincludes/tests/base/math.h |  5 
 3 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index 57bc3fa5489..442de9226b5 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  May 15, 2023 at 11:55:05 PM by AutoGen 5.18.7
+ * It has been AutoGen-ed  April 12, 2024 at 12:46:40 PM by AutoGen 5.18.7
  * From the definitionsinclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Mon May 15 23:55:05 BST 2023
+/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Apr 12 12:46:40 BST 2024
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 262 fixup descriptions.
+ * This file contains 263 fixup descriptions.
  *
  * See README for more information.
  *
@@ -3651,6 +3651,43 @@ static const char* apzDarwin_Ucred__AtomicPatch[] = {
 #endif\n",
 (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Darwin_Flt_Eval_Method fix
+ */
+tSCC zDarwin_Flt_Eval_MethodName[] =
+ "darwin_flt_eval_method";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zDarwin_Flt_Eval_MethodList[] =
+  "math.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzDarwin_Flt_Eval_MethodMachs[] = {
+"*-*-darwin*",
+(const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zDarwin_Flt_Eval_MethodSelect0[] =
+   "^#if __FLT_EVAL_METHOD__ == 0$";
+
+#defineDARWIN_FLT_EVAL_METHOD_TEST_CT  1
+static tTestDesc aDarwin_Flt_Eval_MethodTests[] = {
+  { TT_EGREP,zDarwin_Flt_Eval_MethodSelect0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Darwin_Flt_Eval_Method
+ */
+static const char* apzDarwin_Flt_Eval_MethodPatch[] = {
+"format",
+"#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16",
+(char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Dec_Intern_Asm fix
@@ -10647,9 +10684,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT  300
+#define REGEX_COUNT  301
 #define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT262
+#define FIX_COUNT263
 
 /*
  *  Enumerate the fixes
@@ -10741,6 +10778,7 @@ typedef enum {
 DARWIN_STDINT_6_FIXIDX,
 DARWIN_STDINT_7_FIXIDX,
 DARWIN_UCRED__ATOMIC_FIXIDX,
+DARWIN_FLT_EVAL_METHOD_FIXIDX,
 DEC_INTERN_ASM_FIXIDX,
 DJGPP_WCHAR_H_FIXIDX,
 ECD_CURSOR_FIXIDX,
@@ -11350,6 +11388,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
  DARWIN_UCRED__ATOMIC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
  aDarwin_Ucred__AtomicTests,   apzDarwin_Ucred__AtomicPatch, 0 },
 
+  {  zDarwin_Flt_Eval_MethodName,zDarwin_Flt_Eval_MethodList,
+ apzDarwin_Flt_Eval_MethodMachs,
+ DARWIN_FLT_EVAL_METHOD_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aDarwin_Flt_Eval_MethodTests,   apzDarwin_Flt_Eval_MethodPatch, 0 },
+
   {  zDec_Intern_AsmName,zDec_Intern_AsmList,
  apzDec_Intern_AsmMachs,
  DEC_INTERN_ASM_TEST_CT, FD_MACH_ONLY,
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index c2f54d1189a..6478ca19932 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1814,6 +1814,17 @@ fix = {
 test_text = ""; /* Don't provide this for wrap fixes.  */
 };
 
+/*  The darwin headers don't accept __FLT_EVAL_METHOD__ == 16.  */
+fix = {
+hackname  = darwin_flt_eval_method;
+mach  = "*-*-darwin*";
+files = math.h;
+select= "^#if __FLT_EVAL_METHOD__ == 0$";
+c_fix = format;
+c_fix_arg = "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16";
+test_text = "#if __FLT_EVAL_METHOD__ == 0";
+};
+
 /*
  *  Fix  on Digital UNIX V4.0:
  *  It contains a prototype for a DEC C internal asm() 

[gcc r11-11353] Darwin: Fix empty g++ command lines [PR105599].

2024-04-24 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:3bb14f6ed5bc70e25381c67963c90eaab91eca22

commit r11-11353-g3bb14f6ed5bc70e25381c67963c90eaab91eca22
Author: Iain Sandoe 
Date:   Sun May 29 16:14:32 2022 +0100

Darwin: Fix empty g++ command lines [PR105599].

An empty g++ command line should produce a diagnostic that there are no
inputs.  The PR is that currently Darwin produces a dignostic about missing
link items instead - this is because (errnoeously), for this driver, we are
creating a link job for empty command lines.

The problem occurs in four stages:

 The g++ driver appends -shared-libgcc to the command line.

 The Darwin driver_init code in the backend does not see this (it sees an
 empty command line).

 When the back end driver code driver sees an empty command line, it does 
not
 add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
 avoid anything being claimed as an input_file and therefore triggering a 
link
 line.

 Since we do not have a value for asm-macosx-version-min when processing the
 driver specs, we unconditionally inject 'multiply_defined suppress' which 
is
 used with shared libgcc (but only intended on very old Darwin).  This then
 causes the generation of a link job.

The solution, for the present, is to move version-specific link params to 
the
LINK_SPEC so that they are only processed when a link job has already been
decided.

Signed-off-by: Iain Sandoe 

PR target/105599

gcc/ChangeLog:

* config/darwin.h: Move versions-specific handling of 
multiply_defined
from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.

(cherry picked from commit 794737976b9a6418eab817f143bb4eb2d0c834d2)

Diff:
---
 gcc/config/darwin.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index b2bd33f8d4a..5be13293319 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -215,7 +215,8 @@ extern GTY(()) int darwin_ms_struct;
   "%{image_base*:-Xlinker -image_base -Xlinker %*} %

[gcc r11-11347] testsuite,X86: Fix missing USER_LABEL_PREFIX cases.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a428bc0c7a019328eefffd9eaa3153550c9a9384

commit r11-11347-ga428bc0c7a019328eefffd9eaa3153550c9a9384
Author: Iain Sandoe 
Date:   Fri Apr 15 15:51:22 2022 +0100

testsuite,X86: Fix missing USER_LABEL_PREFIX cases.

Yet another set of testcases that do not account for targets that
use __USER_LABEL_PREFIX__.

Signed-off-by: Iain Sandoe 

gcc/testsuite/ChangeLog:

* gcc.target/i386/memcpy-strategy-10.c: Account for
__USER_LABEL_PREFIX__.
* gcc.target/i386/memcpy-strategy-5.c: Likewise.
* gcc.target/i386/memset-strategy-5.c: Likewise.
* gcc.target/i386/memset-strategy-7.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c | 4 ++--
 gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c  | 4 ++--
 gcc/testsuite/gcc.target/i386/memset-strategy-5.c  | 4 ++--
 gcc/testsuite/gcc.target/i386/memset-strategy-7.c  | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c 
b/gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c
index 970aa741971..860fcc9f801 100644
--- a/gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c
+++ b/gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -march=skylake -mno-sse" } */
-/* { dg-final { scan-assembler "jmp\tmemcpy" { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler "call\tmemcpy" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\t_?memcpy" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "call\t_?memcpy" { target ia32 } } } */
 /* { dg-final { scan-assembler-not "rep movsb" } } */
 
 void
diff --git a/gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c 
b/gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c
index 83c333b551d..833e37fa325 100644
--- a/gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c
+++ b/gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -march=tigerlake -mno-sse" } */
-/* { dg-final { scan-assembler "jmp\tmemcpy" { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler "call\tmemcpy" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\t_?memcpy" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "call\t_?memcpy" { target ia32 } } } */
 /* { dg-final { scan-assembler-not "rep movsb" } } */
 
 void
diff --git a/gcc/testsuite/gcc.target/i386/memset-strategy-5.c 
b/gcc/testsuite/gcc.target/i386/memset-strategy-5.c
index dc1de8e79c2..73ce2df6060 100644
--- a/gcc/testsuite/gcc.target/i386/memset-strategy-5.c
+++ b/gcc/testsuite/gcc.target/i386/memset-strategy-5.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -march=tigerlake -mno-sse" } */
-/* { dg-final { scan-assembler "jmp\tmemset" { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler "call\tmemset" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\t_?memset" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "call\t_?memset" { target ia32 } } } */
 /* { dg-final { scan-assembler-not "rep stosb" } } */
 
 void
diff --git a/gcc/testsuite/gcc.target/i386/memset-strategy-7.c 
b/gcc/testsuite/gcc.target/i386/memset-strategy-7.c
index 07c2816910c..653829e6fc7 100644
--- a/gcc/testsuite/gcc.target/i386/memset-strategy-7.c
+++ b/gcc/testsuite/gcc.target/i386/memset-strategy-7.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -march=skylake -mno-sse" } */
-/* { dg-final { scan-assembler "jmp\tmemset" { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler "call\tmemset" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\t_?memset" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "call\t_?memset" { target ia32 } } } */
 /* { dg-final { scan-assembler-not "rep stosb" } } */
 
 void


[gcc r11-11346] add missing dg-require alias to gcc.dg/torture/pr100786.c

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:1a2781ba50adf8b384f976553ac6fdeb533119b4

commit r11-11346-g1a2781ba50adf8b384f976553ac6fdeb533119b4
Author: Richard Biener 
Date:   Mon Mar 28 09:48:08 2022 +0200

add missing dg-require alias to gcc.dg/torture/pr100786.c

2022-03-28  Richard Biener  

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

(cherry picked from commit f6819b7fea38f2e5482c71aabab3d44a8bd7d904)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr100786.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr100786.c 
b/gcc/testsuite/gcc.dg/torture/pr100786.c
index 42f4e485593..7c03b08d8cb 100644
--- a/gcc/testsuite/gcc.dg/torture/pr100786.c
+++ b/gcc/testsuite/gcc.dg/torture/pr100786.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-alias "" } */
 
 const double a = 0;
 extern int b __attribute__((alias("a")));


[gcc r11-11345] Darwin: Fix a type mismatch warning for a non-GCC bootstrap compiler.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a73f2d80e909b67bbe3dc0abb48cf422810e1564

commit r11-11345-ga73f2d80e909b67bbe3dc0abb48cf422810e1564
Author: Iain Sandoe 
Date:   Fri Mar 4 12:39:03 2022 +

Darwin: Fix a type mismatch warning for a non-GCC bootstrap compiler.

DECL_MD_FUNCTION_CODE() returns an int, on one particular compiler the
code in darwin_fold_builtin() triggers a warning.

Fixed thus.

Signed-off-by: Iain Sandoe 

gcc/ChangeLog:

* config/darwin.c (darwin_fold_builtin): Make fcode an int to
avoid a mismatch with DECL_MD_FUNCTION_CODE().

(cherry picked from commit 25587472ccd223c861fe77cfeca4ba33c3f6cd99)

Diff:
---
 gcc/config/darwin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index dedf84d6247..2371816e251 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3620,7 +3620,7 @@ tree
 darwin_fold_builtin (tree fndecl, int n_args, tree *argp,
 bool ARG_UNUSED (ignore))
 {
-  unsigned int fcode = DECL_MD_FUNCTION_CODE (fndecl);
+  int fcode = DECL_MD_FUNCTION_CODE (fndecl);
 
   if (fcode == darwin_builtin_cfstring)
 {


[gcc r11-11344] libphobos, testsuite: Add prune clauses for two Darwin cases.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:4a0e4f68a39c19c27456c9925c9dc85a3617ebad

commit r11-11344-g4a0e4f68a39c19c27456c9925c9dc85a3617ebad
Author: Iain Sandoe 
Date:   Fri Nov 19 15:48:53 2021 +

libphobos, testsuite: Add prune clauses for two Darwin cases.

Depending on the permutation of CPU, OS version and shared/non-
shared library inclusion, we get can get two warnings from the
external tools (ld64, dsymutil) which are not actually GCC issues
but relate to the external tools.  These are alrrady pruned in
the main testsuite, this adds them to the library.

Signed-off-by: Iain Sandoe 

libphobos/ChangeLog:

* testsuite/lib/libphobos.exp: Prune warnings from external
tool bugs.

(cherry picked from commit 532fae74c3b1197023a765272892e12e123f0a56)

Diff:
---
 libphobos/testsuite/lib/libphobos.exp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libphobos/testsuite/lib/libphobos.exp 
b/libphobos/testsuite/lib/libphobos.exp
index 3be2092b12e..2af430a0e45 100644
--- a/libphobos/testsuite/lib/libphobos.exp
+++ b/libphobos/testsuite/lib/libphobos.exp
@@ -90,6 +90,13 @@ proc libphobos-dg-test { prog do_what extra_tool_flags } {
 }
 
 proc libphobos-dg-prune { system text } {
+
+# Ignore harmless warnings from Xcode.
+regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind 
for\[^\n\]*" $text "" text
+
+# Ignore dsymutil warning (tool bug is actually linker)
+regsub -all "(^|\n)\[^\n\]*could not find object file symbol for 
symbol\[^\n\]*" $text "" text
+
 return $text
 }


[gcc r11-11343] configure, Darwin: Check ld64 support for -platform-version.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:4b263d5d06494774bc72f85b1206e1dc2c8fbd15

commit r11-11343-g4b263d5d06494774bc72f85b1206e1dc2c8fbd15
Author: Iain Sandoe 
Date:   Fri Nov 12 17:03:09 2021 +

configure, Darwin: Check ld64 support for -platform-version.

Newer versions of ld64 allow specifiying the OS target (e.g.
macos or ios) the version and the SDK version all in a single
command.  This checks the availability of the command for the
current toolchain.

Signed-off-by: Iain Sandoe 

gcc/ChangeLog:

* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Test ld64 for -platform-version support.

(cherry picked from commit d3cc82dc9cc2d4f1021fc5d4c1463c3a14fc6795)

Diff:
---
 gcc/config.in|  6 ++
 gcc/configure| 21 -
 gcc/configure.ac | 16 +++-
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index 048bf52e8c2..982c453ca36 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2207,6 +2207,12 @@
 #endif
 
 
+/* Define to 1 if ld64 supports '-platform_version'. */
+#ifndef USED_FOR_TARGET
+#undef LD64_HAS_PLATFORM_VERSION
+#endif
+
+
 /* Define to ld64 version. */
 #ifndef USED_FOR_TARGET
 #undef LD64_VERSION
diff --git a/gcc/configure b/gcc/configure
index 3a9d5e269d1..0b9c7451231 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -30698,6 +30698,7 @@ if test x"$ld64_flag" = x"yes"; then
 
   # Set defaults for possibly untestable items.
   gcc_cv_ld64_export_dynamic=0
+  gcc_cv_ld64_platform_version=0
 
   if test "$build" = "$host"; then
 darwin_try_test=1
@@ -30721,9 +30722,12 @@ $as_echo_n "checking ld64 specified version... " >&6; }
 gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'`
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_major" >&5
 $as_echo "$gcc_cv_ld64_major" >&6; }
-   if test "$gcc_cv_ld64_major" -ge 236; then
+if test "$gcc_cv_ld64_major" -ge 236; then
   gcc_cv_ld64_export_dynamic=1
 fi
+if test "$gcc_cv_ld64_major" -ge 512; then
+  gcc_cv_ld64_platform_version=1
+fi
   elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
 # If the version was not specified, try to find it.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker version" >&5
@@ -30742,6 +30746,15 @@ $as_echo_n "checking linker for -export_dynamic 
support... " >&6; }
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$gcc_cv_ld64_export_dynamic" >&5
 $as_echo "$gcc_cv_ld64_export_dynamic" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for 
-platform_version support" >&5
+$as_echo_n "checking linker for -platform_version support... " >&6; }
+gcc_cv_ld64_platform_version=1
+if $gcc_cv_ld -platform_version macos 10.5 0.0 < /dev/null 2>&1 | grep 
'unknown option' > /dev/null; then
+  gcc_cv_ld64_platform_version=0
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$gcc_cv_ld64_platform_version" >&5
+$as_echo "$gcc_cv_ld64_platform_version" >&6; }
   fi
 
   if test x"${gcc_cv_ld64_version}" != x; then
@@ -30757,6 +30770,12 @@ cat >>confdefs.h <<_ACEOF
 #define LD64_HAS_EXPORT_DYNAMIC $gcc_cv_ld64_export_dynamic
 _ACEOF
 
+
+
+cat >>confdefs.h <<_ACEOF
+#define LD64_HAS_PLATFORM_VERSION $gcc_cv_ld64_platform_version
+_ACEOF
+
 fi
 
 if test x"$dsymutil_flag" = x"yes"; then
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 1e54494c535..2bf0e8a12b7 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -6351,6 +6351,7 @@ if test x"$ld64_flag" = x"yes"; then
 
   # Set defaults for possibly untestable items.
   gcc_cv_ld64_export_dynamic=0
+  gcc_cv_ld64_platform_version=0
 
   if test "$build" = "$host"; then
 darwin_try_test=1
@@ -6372,9 +6373,12 @@ if test x"$ld64_flag" = x"yes"; then
 AC_MSG_CHECKING(ld64 specified version)
 gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'`
 AC_MSG_RESULT($gcc_cv_ld64_major)
-   if test "$gcc_cv_ld64_major" -ge 236; then
+if test "$gcc_cv_ld64_major" -ge 236; then
   gcc_cv_ld64_export_dynamic=1
 fi
+if test "$gcc_cv_ld64_major" -ge 512; then
+  gcc_cv_ld64_platform_version=1
+fi
   elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
 # If the version was not specified, try to find it.
 AC_MSG_CHECKING(linker version)
@@ -6389,6 +6393,13 @@ if test x"$ld64_flag" = x"yes"; then
   gcc_cv_ld64_export_dynamic=0
 fi
 AC_MSG_RESULT($gcc_cv_ld64_export_dynamic)
+
+AC_MSG_CHECKING(linker for -platform_version support)
+gcc_cv_ld64_platform_version=1
+if $gcc_cv_ld -platform_version macos 10.5 0.0 < /dev/null 2>&1 | grep 
'unknown option' > /dev/null; then
+  gcc_cv_ld64_platform_version=0
+fi
+AC_MSG_RESULT($gcc_cv_ld64_platform_version)
   fi
 
   if test x"${gcc_cv_ld64_version}" != x; then
@@ -6398,6 +6409,9 @@ if test x"$ld64_flag" = x"yes"; then
 
   

[gcc r11-11342] testsuite, Darwin : Do not claim 'GAS' for cctools assembler.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:5568dda5a01cba6925b3fe5a2ae8a56caee539c5

commit r11-11342-g5568dda5a01cba6925b3fe5a2ae8a56caee539c5
Author: Iain Sandoe 
Date:   Mon Mar 15 21:38:31 2021 +

testsuite, Darwin : Do not claim 'GAS' for cctools assembler.

Although the cctools assembler is based of GNU GAS, it is from a
very old version (1.38) which does not support many of the features
that the target supports test is expecting.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Exclude cctools assembler based on
GAS 1.38.

(cherry picked from commit e42ea63bcc12e819c3e1066974a691988e86b724)

Diff:
---
 gcc/testsuite/lib/target-supports.exp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 63a5f5579be..876b972a433 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -9576,7 +9576,14 @@ proc check_effective_target_gas { } {
set status [remote_exec host "$gcc_as" "-v /dev/null"]
set as_output [lindex $status 1]
if { [ string first "GNU" $as_output ] >= 0 } {
-   set use_gas_saved 1
+   # Some Darwin versions have an assembler which is based on an old
+   # version of GAS (and reports GNU assembler in its -v output) but
+   # but doesn't support many of the modern GAS features.
+   if { [ string first "cctools" $as_output ] >= 0 } {
+   set use_gas_saved 0
+   } else {
+   set use_gas_saved 1
+   }
} else {
set use_gas_saved 0
}


[gcc r11-11341] Objective-C: Default flag_objc_sjlj_exceptions off for NeXT ABI >= 2.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:895bb1b2eb82e76d3bfc48bf35a0bbafae82d873

commit r11-11341-g895bb1b2eb82e76d3bfc48bf35a0bbafae82d873
Author: Matt Jacobson 
Date:   Thu Jul 29 09:57:23 2021 +0100

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

Signed-off-by: Matt Jacobson 

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/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(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.

(cherry picked from commit 798666392b512a585f0de2983a5d3423e960959e)

Diff:
---
 gcc/c-family/c-opts.c   | 4 ++--
 gcc/objc/objc-next-runtime-abi-02.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 6f001e0bb6c..5bfa239ec0b 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -852,9 +852,9 @@ c_common_post_options (const char **pfilename)
   else if (!flag_gnu89_inline && !flag_isoc99)
 error ("%<-fno-gnu89-inline%> is only supported in GNU99 or C99 mode");
 
-  /* Default to ObjC sjlj exception handling if NeXT runtime.  */
+  /* Default to ObjC sjlj exception handling if NeXT runtime < v2.  */
   if (flag_objc_sjlj_exceptions < 0)
-flag_objc_sjlj_exceptions = flag_next_runtime;
+flag_objc_sjlj_exceptions = (flag_next_runtime && flag_objc_abi < 2);
   if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
 flag_exceptions = 1;
 
diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index 2f18b04e34a..2a4f87cc726 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -245,7 +245,7 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks)
 {
   extern_names = ggc_cleared_vec_alloc (SIZEHASHTABLE);
 
-  if (flag_objc_exceptions && flag_objc_sjlj_exceptions)
+  if (flag_objc_sjlj_exceptions)
 {
   inform (UNKNOWN_LOCATION,
  "%<-fobjc-sjlj-exceptions%> is ignored for "
@@ -511,7 +511,7 @@ static void next_runtime_02_initialize (void)
   objc_getPropertyStruct_decl = NULL_TREE;
   objc_setPropertyStruct_decl = NULL_TREE;
 
-  gcc_assert (!flag_objc_sjlj_exceptions);
+  gcc_checking_assert (!flag_objc_sjlj_exceptions);
 
   /* Although we warn that fobjc-exceptions is required for exceptions
  code, we carry on and create it anyway.  */


[gcc r11-11340] Objective-C, NeXT runtime: Correct the default for fobjc-nilcheck.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:b907af1ce4966b662ae3d26afa24fa6c3ac468c9

commit r11-11340-gb907af1ce4966b662ae3d26afa24fa6c3ac468c9
Author: Iain Sandoe 
Date:   Sun Aug 15 12:52:30 2021 +0100

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.

Signed-off-by: Iain Sandoe 

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init):
Default receiver nilchecks on.

(cherry picked from commit de0b250b2badb475f8c09f3cd2c57fd3f9127fe3)

Diff:
---
 gcc/objc/objc-next-runtime-abi-02.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index e99c048e3a1..2f18b04e34a 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -254,6 +254,10 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks)
   flag_objc_sjlj_exceptions = 0;
 }
 
+  /* NeXT ABI 2 is intended to default to checking for nil receivers.  */
+  if (! global_options_set.x_flag_objc_nilcheck)
+flag_objc_nilcheck = 1;
+
   rthooks->initialize = next_runtime_02_initialize;
   rthooks->default_constant_string_class_name = DEF_CONSTANT_STRING_CLASS_NAME;
   rthooks->tag_getclass = TAG_GETCLASS;


[gcc r11-11339] Objective-C: fix crash with -fobjc-nilcheck

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:87431b4a81e9dc5988509399704a7352800c6a77

commit r11-11339-g87431b4a81e9dc5988509399704a7352800c6a77
Author: Iain Sandoe 
Date:   Sat Aug 14 12:27:55 2021 +0100

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 
Co-authored-by: Matt Jacobson  

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 d2aa4e0b3b5053df8f5853d9ed29022ff0d3ecf6)

Diff:
---
 gcc/objc/objc-act.c| 16 +---
 gcc/objc/objc-next-runtime-abi-02.c| 22 +++---
 gcc/testsuite/obj-c++.dg/pr101666-0.mm |  7 +++
 gcc/testsuite/obj-c++.dg/pr101666-1.mm | 10 ++
 gcc/testsuite/obj-c++.dg/pr101666.inc  | 29 +
 gcc/testsuite/objc.dg/pr101666-0.m |  7 +++
 gcc/testsuite/objc.dg/pr101666-1.m | 10 ++
 gcc/testsuite/objc.dg/pr101666.inc | 29 +
 8 files changed, 108 insertions(+), 22 deletions(-)

diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 1cbd586b8fb..536ec028dbd 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -3376,8 +3376,10 @@ objc_build_string_object (tree string)
   return addr;
 }
 
-/* Build a static constant CONSTRUCTOR
-   with type TYPE and elements ELTS.  */
+/* Build a static constant CONSTRUCTOR with type TYPE and elements ELTS.
+   We might be presented with a NULL for ELTS, which means 'empty ctor'
+   which will subsequently be converted into a zero initializer in the
+   middle end.  */
 
 tree
 objc_build_constructor (tree type, vec *elts)
@@ -3389,12 +3391,10 @@ objc_build_constructor (tree type, vec *elts)
   TREE_READONLY (constructor) = 1;
 
 #ifdef OBJCPLUS
-  /* Adjust for impedance mismatch.  We should figure out how to build
- CONSTRUCTORs that consistently please both the C and C++ gods.  */
-  if (!(*elts)[0].index)
+  /* If we know the initializer, then set the type to what C++ expects.  */
+  if (elts && !(*elts)[0].index)
 TREE_TYPE (constructor) = init_list_type_node;
 #endif
-
   return constructor;
 }
 
@@ -9663,7 +9663,9 @@ objc_gimplify_property_ref (tree *expr_p)
   call_exp = TREE_OPERAND (getter, 1);
 }
 #endif
-  gcc_assert (TREE_CODE (call_exp) == CALL_EXPR);
+  gcc_checking_assert ((flag_objc_nilcheck
+   && TREE_CODE (call_exp) == COND_EXPR)
+  || TREE_CODE (call_exp) == CALL_EXPR);
 
   *expr_p = call_exp;
 }
diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index f1c858b2cd7..e99c048e3a1 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -1676,13 +1676,8 @@ build_v2_objc_method_fixup_call (int super_flag, tree 
method_prototype,
 
   if (TREE_CODE (ret_type) == RECORD_TYPE
  || TREE_CODE (ret_type) == UNION_TYPE)
-   {
- vec *rtt = NULL;
- /* ??? CHECKME. hmmm. think we need something more
-here.  */
- CONSTRUCTOR_APPEND_ELT (rtt, NULL_TREE, NULL_TREE);
- ftree = objc_build_constructor (ret_type, rtt);
-   }
+   /* An empty constructor is zero-filled by the middle end.  */
+   ftree = objc_build_constructor (ret_type, NULL);
   else
ftree = fold_convert (ret_type, integer_zero_node);
 
@@ -1695,11 +1690,11 @@ build_v2_objc_method_fixup_call (int super_flag, tree 
method_prototype,
ifexp, ret_val, ftree,
tf_warning_or_error);
 #else
- /* ??? CHECKME.   */
   ret_val = build_conditional_expr (input_location,
-   ifexp, 1,
+   ifexp, 0,
ret_val, NULL_TREE, input_location,
ftree, NULL_TREE, input_location);
+  ret_val = fold_convert (ret_type, ret_val);
 #endif
 }
   return ret_val;
@@ -1792,11 +1787,8 @@ build_v2_build_objc_method_call (int super, tree 
method_prototype,
   if (TREE_CODE (ret_type) == 

[gcc r12-10385] testsuite: Remove duplicate -lgcov [PR114034]

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:6a4824a8bc86fcbcb8f51bab4c24d72ffd00715e

commit r12-10385-g6a4824a8bc86fcbcb8f51bab4c24d72ffd00715e
Author: Iain Sandoe 
Date:   Sun Mar 31 11:22:58 2024 +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 
(cherry picked from commit 799a056cf804f433ce0050a5a6bf900f7a01ecb1)

Diff:
---
 gcc/testsuite/g++.dg/gcov/gcov-dump-1.C | 2 +-
 gcc/testsuite/g++.dg/gcov/gcov-dump-2.C | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C 
b/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C
index f0e81e9b042..774a7269ff2 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C
@@ -1,4 +1,4 @@
-/* { dg-options "-fprofile-generate -ftest-coverage -lgcov" } */
+/* { dg-options "-fprofile-generate -ftest-coverage " } */
 /* { dg-do run { target native } } */
 
 int value;
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C 
b/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C
index 6234a81a586..e748989d2c0 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C
@@ -1,4 +1,4 @@
-/* { dg-options "-fprofile-generate -ftest-coverage -lgcov" } */
+/* { dg-options "-fprofile-generate -ftest-coverage " } */
 /* { dg-do run { target native } } */
 
 int value;


[gcc r12-10384] Darwin, ppc: Add system stubs for all 32b PPC

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:be44511b14d14e1e3d7230a7a64db5a3a0ed0129

commit r12-10384-gbe44511b14d14e1e3d7230a7a64db5a3a0ed0129
Author: Iain Sandoe 
Date:   Wed Jul 26 14:31:02 2023 +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 

gcc/ChangeLog:

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

(cherry picked from commit b3ab28c3e85af7995fffb87eb190ef942b7e9e4a)

Diff:
---
 gcc/config/rs6000/darwin.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h
index b5cef42610f..626b40dab29 100644
--- a/gcc/config/rs6000/darwin.h
+++ b/gcc/config/rs6000/darwin.h
@@ -98,7 +98,7 @@
Include libmx when targeting Darwin 7.0 and above, but before libSystem,
since the functions are actually in libSystem but for 7.x compatibility
we want them to be looked for in libmx first.
-   Include libSystemStubs when compiling against 10.3 - 10.5 SDKs (we assume
+   Include libSystemStubs when compiling against 10.3 - 10.6 SDKs (we assume
this is the case when targetting these) - but not for 64-bit long double.
Don't do either for m64, the library is either a dummy or non-existent.
 */
@@ -107,8 +107,8 @@
 #define LIB_SPEC \
 "%{!static:\
   %{!m64:%{!mlong-double-64:   \
-%{pg:%:version-compare(>< 10.3 10.5 mmacosx-version-min= 
-lSystemStubs_profile)} \
-%{!pg:%:version-compare(>< 10.3 10.5 mmacosx-version-min= -lSystemStubs)} \
+%{pg:%:version-compare(>< 10.3 10.7 mmacosx-version-min= 
-lSystemStubs_profile)} \
+%{!pg:%:version-compare(>< 10.3 10.7 mmacosx-version-min= -lSystemStubs)} \
  %:version-compare(>< 10.3 10.4 mmacosx-version-min= -lmx)}}   \
   -lSystem \
 }"


[gcc r12-10383] jit, Darwin: Implement library exports list.

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:22203bd7cfe463fce6f3a84118f9479d37e48570

commit r12-10383-g22203bd7cfe463fce6f3a84118f9479d37e48570
Author: Iain Sandoe 
Date:   Sat Jan 13 17:20:47 2024 +

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 
(cherry picked from commit b120e355e59142bd15d6b010461d07236288d843)

Diff:
---
 gcc/jit/Make-lang.in  |  47 ++
 gcc/jit/libgccjit.exports | 219 ++
 2 files changed, 249 insertions(+), 17 deletions(-)

diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
index 6e10abfd0ac..33ed7e357a2 100644
--- a/gcc/jit/Make-lang.in
+++ b/gcc/jit/Make-lang.in
@@ -55,7 +55,17 @@ else
 
 ifneq (,$(findstring darwin,$(host)))
 
-LIBGCCJIT_AGE = 1
+# NOTE that we are building here for the host, and so tests for target-
+# specific functionality will only work when host == target.  This causes
+# fails when building cross-compilers with different object formats (at
+# least when the respective linkers do not accept the same command line
+# options).  Fortunately, for Darwin we can safely hard-code the relevant
+# host options, since all usable linkers support them).
+
+LIBGCCJIT_CURRENT = 24
+LIBGCCJIT_REVISION = 0
+LIBGCCJIT_AGE = 24
+LIBGCCJIT_COMPAT = 0
 LIBGCCJIT_BASENAME = libgccjit
 
 LIBGCCJIT_SONAME = \
@@ -63,18 +73,18 @@ LIBGCCJIT_SONAME = \
 LIBGCCJIT_FILENAME = $(LIBGCCJIT_BASENAME).$(LIBGCCJIT_VERSION_NUM).dylib
 LIBGCCJIT_LINKER_NAME = $(LIBGCCJIT_BASENAME).dylib
 
-# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
-# LD_SONAME_OPTION depending if configure found them, using $(if)
-# We have to define a COMMA here, otherwise the commas in the "true"
-# result are treated as separators by the $(if).
+# Darwin does not have a version script option. Exported symbols are controlled
+# by the following, and library versioning is done using libtool.
+# We have to define a COMMA here, otherwise the commas are treated as
+# separators.
 COMMA := ,
 LIBGCCJIT_VERSION_SCRIPT_OPTION = \
-   $(if $(LD_VERSION_SCRIPT_OPTION),\
- 
-Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map)
+  -Wl$(COMMA)-exported_symbols_list$(COMMA)$(srcdir)/jit/libgccjit.exports
 
+# For Darwin host, we need a l64 or ld64-compatible linker, that uses
+# -install_name to introduce this.
 LIBGCCJIT_SONAME_OPTION = \
-   $(if $(LD_SONAME_OPTION), \
--Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))
+  -Wl$(COMMA)-install_name$(COMMA)$(LIBGCCJIT_SONAME)
 
 LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_FILENAME)
 LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
@@ -143,15 +153,18 @@ ifneq (,$(findstring mingw,$(target)))
 # Create import library
 LIBGCCJIT_EXTRA_OPTS = -Wl,--out-implib,$(LIBGCCJIT_IMPORT_LIB)
 else
-
 ifneq (,$(findstring darwin,$(host)))
-# TODO : Construct a Darwin-style symbol export file.
-LIBGCCJIT_EXTRA_OPTS = -Wl,-compatibility_version,$(LIBGCCJIT_VERSION_NUM) \
-   
-Wl,-current_version,$(LIBGCCJIT_VERSION_NUM).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_AGE)
 \
-   $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
-   $(LIBGCCJIT_SONAME_OPTION)
+LIBGCCJIT_VERS = $(LIBGCCJIT_CURRENT).$(LIBGCCJIT_REVISION).$(LIBGCCJIT_AGE)
+LIBGCCJIT_EXTRA_OPTS = -Wl,-current_version,$(LIBGCCJIT_VERS) \
+ -Wl,-compatibility_version,$(LIBGCCJIT_COMPAT) \
+  $(LIBGCCJIT_VERSION_SCRIPT_OPTION) $(LIBGCCJIT_SONAME_OPTION)
+# Use the default (shared) libgcc.
+JIT_LDFLAGS = $(filter-out -static-libgcc, $(LDFLAGS))
+ifeq (,$(findstring darwin8,$(host)))
+JIT_LDFLAGS += -Wl,-rpath,@loader_path
+endif
 else
-
+JIT_LDFLAGS = $(LDFLAGS)
 LIBGCCJIT_EXTRA_OPTS = $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
$(LIBGCCJIT_SONAME_OPTION)
 endif
@@ -165,7 +178,7 @@ $(LIBGCCJIT_FILENAME): $(jit_OBJS) \
$(LIBDEPS) $(srcdir)/jit/libgccjit.map \
$(EXTRA_GCC_OBJS) $(jit.prev)
@$(call LINK_PROGRESS,$(INDEX.jit),start)
-   +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ -shared \
+   +$(LLINKER) $(ALL_LINKERFLAGS) $(JIT_LDFLAGS) -o $@ -shared \
 $(jit_OBJS) libbackend.a libcommon-target.a libcommon.a \
 $(CPPLIB) 

[gcc r12-10382] Darwin: Correct a version check.

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:13ae931863dcc3684742ed81ce84d005fbec1bb7

commit r12-10382-g13ae931863dcc3684742ed81ce84d005fbec1bb7
Author: Iain Sandoe 
Date:   Mon Apr 1 20:47:25 2024 +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 
(cherry picked from commit 451bb0b9262d2f54173937569a29d7f1ad234e30)

Diff:
---
 gcc/config/darwin.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 6153f3c39fe..76feb87a29d 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -3381,7 +3381,7 @@ darwin_override_options (void)
   /* External toolchains based on LLVM or clang 7+ have support for
 dwarf-4.  */
   if ((dsymutil_version.kind == LLVM && dsymutil_version.major >= 7)
- || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 7))
+ || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 700))
dwarf_version = 4;
   else if (dsymutil_version.kind == DWARFUTILS
   && dsymutil_version.major >= 121)


[gcc r12-10381] configure, Darwin: Correct a pasto in host-shared processing.

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:f6b8bd94ff853ac321c72cc80968d8386023b7e5

commit r12-10381-gf6b8bd94ff853ac321c72cc80968d8386023b7e5
Author: Iain Sandoe 
Date:   Sun Jun 26 09:24:28 2022 +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 

ChangeLog:

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

(cherry picked from commit 1edfc8f2d3307a3ffa077a605f432832d7715462)

Diff:
---
 configure| 2 +-
 configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 5dcaab14ae9..77638bc84a6 100755
--- a/configure
+++ b/configure
@@ -8646,7 +8646,7 @@ fi
 # Check whether --enable-host-shared was given.
 if test "${enable_host_shared+set}" = set; then :
   enableval=$enable_host_shared; host_shared=$enableval
- case $target in
+ case $host in
x86_64-*-darwin* | aarch64-*-darwin*)
  if test x$host_shared != xyes ; then
# PIC is the default, and actually cannot be switched off.
diff --git a/configure.ac b/configure.ac
index 85977482aee..7abd02f8b56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1918,7 +1918,7 @@ AC_ARG_ENABLE(host-shared,
 [AS_HELP_STRING([--enable-host-shared],
[build host code as shared libraries])],
 [host_shared=$enableval
- case $target in
+ case $host in
x86_64-*-darwin* | aarch64-*-darwin*)
  if test x$host_shared != xyes ; then
# PIC is the default, and actually cannot be switched off.


[gcc r11-11337] Objective-C, NeXT: Adjust symbol marking to match host tools.

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:49c3c423218ea5f02dbbc6b847e15c06174f81ba

commit r11-11337-g49c3c423218ea5f02dbbc6b847e15c06174f81ba
Author: Iain Sandoe 
Date:   Mon May 2 19:42:49 2022 +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 

gcc/ChangeLog:

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

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (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)

Diff:
---
 gcc/config/darwin.c | 2 ++
 gcc/objc/objc-next-runtime-abi-02.c | 6 --
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index b79c0d1d2b4..dedf84d6247 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -1933,6 +1933,8 @@ darwin_label_is_anonymous_local_objc_name (const char 
*name)
 }
   else if (!strncmp ((const char *)p, "ClassMethods", 12))
 return false;
+  else if (!strncmp ((const char *)p, "ClassProtocols", 14))
+return false;
   else if (!strncmp ((const char *)p, "Instance", 8))
 {
   if (p[8] == 'I' || p[8] == 'M')
diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index 19f137c632e..f1c858b2cd7 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -1035,6 +1035,7 @@ next_runtime_abi_02_protocol_decl (tree p)
   else
 decl = start_var_decl (objc_v2_protocol_template, buf);
   OBJCMETA (decl, objc_meta, meta_protocol);
+  DECL_PRESERVE_P (decl) = 1;
   return decl;
 }
 
@@ -2124,8 +2125,8 @@ build_v2_classrefs_table (void)
  expr = convert (objc_class_type, build_fold_addr_expr (expr));
}
   /* The runtime wants this, even if it appears unused, so we must force 
the
-output.
-  DECL_PRESERVE_P (decl) = 1; */
+output.  */
+  DECL_PRESERVE_P (decl) = 1;
   finish_var_decl (decl, expr);
 }
 }
@@ -2327,6 +2328,7 @@ build_v2_protocol_list_address_table (void)
   expr = convert (objc_protocol_type, build_fold_addr_expr (ref->refdecl));
   OBJCMETA (decl, objc_meta, meta_label_protocollist);
   finish_var_decl (decl, expr);
+  DECL_PRESERVE_P (decl) = 1;
 }
 
 /* TODO: delete the vec.  */


[gcc r11-11336] testsuite: Fix weak_undefined handling on Darwin

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:d79d1073c444ceb85b3cd2f55be7b4dfe598d287

commit r11-11336-gd79d1073c444ceb85b3cd2f55be7b4dfe598d287
Author: Rainer Orth 
Date:   Tue Mar 28 10:40:05 2023 +0200

testsuite: Fix weak_undefined handling on Darwin

The patch that introduced the weak_undefined effective-target keyword
and corresponding dg-add-options support

commit 378ec7b87a5265dbe2d489c245fac98ef37fa638
Author: Alexandre Oliva 
Date:   Thu Mar 23 00:45:05 2023 -0300

[testsuite] test for weak_undefined support and add options

badly broke the affected tests on macOS like so:

ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 
weak_undefined "
ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 
weak_undefined "

add_options_for_weak_undefined tries to call an non-existant proc "89".
Even after fixing this by escaping the brackets, two tests still failed to
link since they lacked the corresponding calls do dg-add-options
weak_undefined.

Tested on x86_64-apple-darwin20.6.0 and i386-pc-solaris2.11.

2023-03-27  Rainer Orth  

gcc/testsuite:
* lib/target-supports.exp (add_options_for_weak_undefined): Escape
brackets.
* gcc.dg/visibility-22.c: Add weak_undefined options.

(cherry picked from commit 8443f42f05f9026dadad1236b9e44ec294c70337)

Diff:
---
 gcc/testsuite/gcc.dg/visibility-22.c  |  1 +
 gcc/testsuite/lib/target-supports.exp | 12 
 2 files changed, 13 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/visibility-22.c 
b/gcc/testsuite/gcc.dg/visibility-22.c
index e2b78d1c7fd..9123b350b2e 100644
--- a/gcc/testsuite/gcc.dg/visibility-22.c
+++ b/gcc/testsuite/gcc.dg/visibility-22.c
@@ -3,6 +3,7 @@
 /* { dg-require-visibility "" } */
 /* { dg-require-effective-target weak_undefined } */
 /* { dg-options "-O2 -fPIC" { target fpic } } */
+/* { dg-add-options weak_undefined } */
 
 extern void foo () __attribute__((weak,visibility("hidden")));
 int
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index a09606e4497..63a5f5579be 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -348,6 +348,18 @@ proc check_weak_available { } {
 }
 }
 
+# return options to add to enable weak undefined symbols.
+
+proc add_options_for_weak_undefined { flags } {
+if { [istarget *-*-darwin*] } {
+   lappend flags "-Wl,-undefined,dynamic_lookup"
+   if { [istarget *-*-darwin\[89\]*] } {
+   lappend flags "-Wl,-flat_namespace"
+   }
+}
+return $flags
+}
+
 # return 1 if weak undefined symbols are supported.
 
 proc check_effective_target_weak_undefined { } {


[gcc r11-11335] testsuite, objective-c: Fix a testcase on Windows.

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:ce169d2712296b193ecb94768fee1477bb0d0ed0

commit r11-11335-gce169d2712296b193ecb94768fee1477bb0d0ed0
Author: Iain Sandoe 
Date:   Wed Feb 15 10:47:51 2023 +

testsuite, objective-c: Fix a testcase on Windows.

Windows needs to use uintptr_t to represent an integral pointer type (long
is not the right type there).

Patch from 'nightstike'.

Signed-off-by: Iain Sandoe 

gcc/testsuite/ChangeLog:

* obj-c++.dg/proto-lossage-4.mm: Use uintptr_t for integral pointer
representations.

(cherry picked from commit 142bd88c5f609546a466743ab1066d5620a830bc)

Diff:
---
 gcc/testsuite/obj-c++.dg/proto-lossage-4.mm | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/obj-c++.dg/proto-lossage-4.mm 
b/gcc/testsuite/obj-c++.dg/proto-lossage-4.mm
index 2e753d1f8ba..ff053bec7d0 100644
--- a/gcc/testsuite/obj-c++.dg/proto-lossage-4.mm
+++ b/gcc/testsuite/obj-c++.dg/proto-lossage-4.mm
@@ -6,24 +6,26 @@
 /* One-line substitute for objc/objc.h */
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 
+typedef __UINTPTR_TYPE__ uintptr_t;
+
 @protocol Proto
-- (long)someValue;
+- (uintptr_t)someValue;
 @end
 
 @interface Obj
-- (long)anotherValue;
+- (uintptr_t)anotherValue;
 @end
 
-long foo(void) {
-  long receiver = 2;
+uintptr_t foo(void) {
+  uintptr_t receiver = 2;
   Obj *objrcvr;
   Obj  *objrcvr2;
 
   /* NB: Since 'receiver' is an invalid ObjC message receiver, the compiler
  should warn but then search for methods as if we were messaging 'id'.  */
 
-  receiver += [receiver someValue]; /* { dg-warning "invalid receiver type 
.long int." } */
-  receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type 
.long int." } */
+  receiver += [receiver someValue]; /* { dg-warning "invalid receiver type 
.uintptr_t." } */
+  receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type 
.uintptr_t." } */
 
   receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not 
respond to .\\-someValue." } */
 /* { dg-error "invalid conversion" "" { target *-*-* } .-1 } */


[gcc r11-11334] c++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic.

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:8af693c4ae1a0f8cecef34e98dad1752ebf0bb75

commit r11-11334-g8af693c4ae1a0f8cecef34e98dad1752ebf0bb75
Author: Iain Sandoe 
Date:   Thu Jan 6 08:37:18 2022 +

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 

gcc/cp/ChangeLog:

* g++spec.c (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)

Diff:
---
 gcc/cp/g++spec.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
index 3c9bd1490b4..984106f10dd 100644
--- a/gcc/cp/g++spec.c
+++ b/gcc/cp/g++spec.c
@@ -222,7 +222,12 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
 
case OPT_static_libstdc__:
  library = library >= 0 ? 2 : library;
+#ifdef HAVE_LD_STATIC_DYNAMIC
+ /* Remove -static-libstdc++ from the command only if target supports
+LD_STATIC_DYNAMIC.  When not supported, it is left in so that a
+back-end target can use outfile substitution.  */
  args[i] |= SKIPOPT;
+#endif
  break;
 
case OPT_stdlib_:


[gcc r11-11333] testsuite, Darwin: Fix darwin-comm-1.c error messages for Darwin <= 10.

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:45385f6932567f1b0ce5e1f809135c73c6b70df5

commit r11-11333-g45385f6932567f1b0ce5e1f809135c73c6b70df5
Author: Iain Sandoe 
Date:   Sat Jun 25 09:58:35 2022 +0100

testsuite, Darwin: Fix darwin-comm-1.c error messages for Darwin <= 10.

When amending the allowed alignment size to accommodate the larger values
permitted by newer tools, we retained the object file limit of 2^15 for
Darwin versions <= 10, since that is what the native tools expect there.

This triggers a different diagnostic path with a distinct error message,
which is checked in the revised test here.

Signed-off-by: Iain Sandoe 

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-comm-1.c: Check for the correct error message for
Darwin <= 10.

(cherry picked from commit 54a5f478487a955c3ffaec3e9164a72599bc1cfb)

Diff:
---
 gcc/testsuite/gcc.dg/darwin-comm-1.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/darwin-comm-1.c 
b/gcc/testsuite/gcc.dg/darwin-comm-1.c
index 46519984fd8..2ea11d63d81 100644
--- a/gcc/testsuite/gcc.dg/darwin-comm-1.c
+++ b/gcc/testsuite/gcc.dg/darwin-comm-1.c
@@ -1,5 +1,6 @@
-/* { dg-do compile { target *-*-darwin[912]* } } */
+/* { dg-do compile { target *-*-darwin* } } */
 /* { dg-options "-fcommon" } */
 
 /* In all cases, common has a max alignment of 2^15.  */
-int badcommon __attribute__ ((aligned (65536))); /* { dg-error "common 
variables must have an alignment" } */
+int badcommon __attribute__ ((aligned (65536))); /* { dg-error "common 
variables must have an alignment" "" { target { *-*-darwin1[1-9]* *-*-darwin2* 
} } } */
+/* { dg-error "requested alignment .65536. exceeds object file maximum 32768" 
"" { target { *-*-darwin[4-9]* *-*-darwin10* } } .-1 } */
\ No newline at end of file


[gcc r11-11331] configure, Darwin: Adjust handing of stdlib option.

2024-04-22 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:889dccb5131cd52f3f7735dce7b02105cc067a9e

commit r11-11331-g889dccb5131cd52f3f7735dce7b02105cc067a9e
Author: Iain Sandoe 
Date:   Sat Sep 16 08:40:49 2023 +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 

gcc/ChangeLog:

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

(cherry picked from commit ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc)

Diff:
---
 gcc/configure| 45 ++---
 gcc/configure.ac | 38 ++
 2 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index 327c59652e8..3a9d5e269d1 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -3746,31 +3746,54 @@ gcc_gxx_libcxx_include_dir=
 if test "${with_gxx_libcxx_include_dir+set}" = set; then :
   withval=$with_gxx_libcxx_include_dir; case "${withval}" in
 yes)   as_fn_error $? "bad value ${withval} given for libc++ include 
directory" "$LINENO" 5 ;;
-no);;
 *) gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;;
 esac
 fi
 
 
+# --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option.
+# if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option.
+# if --with-gxx-libcxx-include-dir is unset we enable the stdlib option
+# based on the platform (to be available on platform versions where it is the
+# default for the system tools). We also use a default path within the compiler
+# install tree.
+# Otherwise, we use the path provided and enable the stdlib option.
 # If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we
 # check to see if the latter starts with the former and, upon success, compute
 # gcc_gxx_libcxx_include_dir as relative to the sysroot.
 gcc_gxx_libcxx_include_dir_add_sysroot=0
-
+gcc_enable_stdlib_opt=0
 if test x${gcc_gxx_libcxx_include_dir} != x; then
+  if test x${gcc_gxx_libcxx_include_dir} = xno; then
+# set defaults for the dir, but the option is disabled anyway.
+gcc_gxx_libcxx_include_dir=
+  else
+gcc_enable_stdlib_opt=1
+  fi
+else
+  case $target in
+*-darwin1[1-9]* | *-darwin2*)
+   # Default this on for Darwin versions which default to libcxx,
+   # and embed the path in the compiler install so that we get a
+   # self-contained toolchain.
+   gcc_enable_stdlib_opt=1
+   ;;
+*) ;;
+  esac
+fi
 
-$as_echo "#define ENABLE_STDLIB_OPTION 1" >>confdefs.h
+cat >>confdefs.h <<_ACEOF
+#define ENABLE_STDLIB_OPTION $gcc_enable_stdlib_opt
+_ACEOF
 
-else
-  $as_echo "#define ENABLE_STDLIB_OPTION 0" >>confdefs.h
 
-fi
-# ??? This logic must match 
libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
+# Sysroot behaviour as for gxx-include-dir
 if test x${gcc_gxx_libcxx_include_dir} = x; then
+  # default path,embedded in the compiler tree.
+  libcxx_incdir='include/c++/v1'
   if test x${enable_version_specific_runtime_libs} = xyes; then
-gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1'
+gcc_gxx_libcxx_include_dir='${libsubdir}/$libcxx_incdir'
   else
-libcxx_incdir='libc++_include/c++/$(version)/v1'
 if test x$host != x$target; then
libcxx_incdir="$target_alias/$libcxx_incdir"
 fi
@@ -19423,7 +19446,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19426 "configure"
+#line 19449 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19529,7 +19552,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19532 "configure"
+#line 19555 

[gcc r12-10379] testsuite, Darwin: Allow for an undefined symbol [PR114036].

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:ed046c2cc0f0a2d00cc77e5e9ce5d8f71e2278c6

commit r12-10379-ged046c2cc0f0a2d00cc77e5e9ce5d8f71e2278c6
Author: Iain Sandoe 
Date:   Sun Mar 31 11:27:53 2024 +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 
(cherry picked from commit ad8e34eaa870608e2b07b4e7147e6ef2944bb8b5)

Diff:
---
 gcc/testsuite/gcc.misc-tests/gcov-14.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.misc-tests/gcov-14.c 
b/gcc/testsuite/gcc.misc-tests/gcov-14.c
index 2bebf7e4a93..61a9191c068 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov-14.c
+++ b/gcc/testsuite/gcc.misc-tests/gcov-14.c
@@ -3,7 +3,7 @@
 /* { dg-do run { target native } } */
 /* { dg-options "-O2 -fprofile-arcs -ftest-coverage -fgnu89-inline" } */
 /* The following line arranges that Darwin has behavior like elf weak import.  
*/
-/* { dg-additional-options "-flat_namespace -undefined suppress" { target 
*-*-darwin* }  } */
+/* { dg-additional-options "-Wl,-U,_Foo" { target *-*-darwin* }  } */
 /* { dg-require-weak "" } */
 /* { dg-skip-if "undefined weak not supported" { { hppa*-*-hpux* } && { ! lp64 
} } } */
 /* { dg-skip-if "undefined weak not supported" { powerpc-ibm-aix* } } */


[gcc r12-10378] Darwin: Do not emit .macinfo when dsymutil cannot consume it.

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:8f0f24387945ef03fcd61bf978565145bfaf3493

commit r12-10378-g8f0f24387945ef03fcd61bf978565145bfaf3493
Author: Iain Sandoe 
Date:   Sun Mar 31 23:25:31 2024 +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 
(cherry picked from commit 3c499f8f6f7d19b21d7047efabbe6396ee1c2cac)

Diff:
---
 gcc/config/darwin.cc | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 3cbdc97662d..6153f3c39fe 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -3376,11 +3376,6 @@ darwin_override_options (void)
  global_options.x_flag_objc_abi);
 }
 
-  /* Limit DWARF to the chosen version, the linker and debug linker might not
- be able to consume newer structures.  */
-  if (!OPTION_SET_P (dwarf_strict))
-dwarf_strict = 1;
-
   if (!OPTION_SET_P (dwarf_version))
 {
   /* External toolchains based on LLVM or clang 7+ have support for
@@ -3403,6 +3398,24 @@ darwin_override_options (void)
   OPTION_SET_P (dwarf_split_debug_info) = 0;
 }
 
+  /* Cases where dsymutil will exclude files with .macinfo sections; we are
+ better off forcing the debug level to 2 than completely excluding the
+ files.  If strict dwarf is set, then emit the macinfo anyway.  */
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+  && (!OPTION_SET_P (dwarf_strict) || dwarf_strict == 0)
+  && ((dsymutil_version.kind == CLANG && dsymutil_version.major >= 1500)
+ || (dsymutil_version.kind == LLVM && dsymutil_version.major >= 15)))
+{
+  inform (input_location,
+ "%<-g3%> is not supported by the debug linker in use (set to 2)");
+  debug_info_level = DINFO_LEVEL_NORMAL;
+}
+
+  /* Limit DWARF to the chosen version, the linker and debug linker might not
+ be able to consume newer structures.  */
+  if (!OPTION_SET_P (dwarf_strict))
+dwarf_strict = 1;
+
   /* Do not allow unwind tables to be generated by default for m32.
  fnon-call-exceptions will override this, regardless of what we do.  */
   if (generating_for_darwin_version < 10


[gcc r12-10377] libphobos, Darwin: Enable libphobos for most Darwin.

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:50dd6d3cf89214a97c13f0983bd1e87c306dff51

commit r12-10377-g50dd6d3cf89214a97c13f0983bd1e87c306dff51
Author: Iain Sandoe 
Date:   Mon Apr 1 13:58:20 2024 +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 

Diff:
---
 libphobos/configure.tgt | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index 0063dd23249..817d41a4d2d 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -27,6 +27,9 @@ case "${target}" in
   *-*-dragonfly*)
LIBPHOBOS_SUPPORTED=yes
;;
+  aarch64-*-darwin2*)
+   LIBPHOBOS_SUPPORTED=yes
+   ;;
   aarch64*-*-linux*)
LIBPHOBOS_SUPPORTED=yes
;;
@@ -55,6 +58,12 @@ case "${target}" in
   sparc*-*-solaris2.11*)
LIBPHOBOS_SUPPORTED=yes
;;
+  *-*-darwin9* | *-*-darwin1[01]*)
+   LIBDRUNTIME_ONLY=yes
+   ;;
+  x86_64-*-darwin1[2-9]* | x86_64-*-darwin2* | i?86-*-darwin1[2-7])
+   LIBPHOBOS_SUPPORTED=yes
+   ;;
   x86_64-*-freebsd* | i?86-*-freebsd*)
LIBPHOBOS_SUPPORTED=yes
;;


[gcc r12-10375] testsuite, Darwin: Use the IOKit framework in framework-1.c [PR114049].

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:4c8d37badaa42e85218eb9b89aef3e4f6cf4486e

commit r12-10375-g4c8d37badaa42e85218eb9b89aef3e4f6cf4486e
Author: Iain Sandoe 
Date:   Mon Mar 18 10:06:44 2024 +

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 
(cherry picked from commit 4adb1a5839e7a3310a127c1776f1f95d7edaa6ff)

Diff:
---
 gcc/testsuite/gcc.dg/framework-1.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/framework-1.c 
b/gcc/testsuite/gcc.dg/framework-1.c
index de4adc39868..fdec129a8fb 100644
--- a/gcc/testsuite/gcc.dg/framework-1.c
+++ b/gcc/testsuite/gcc.dg/framework-1.c
@@ -1,4 +1,10 @@
 /* { dg-do compile { target *-*-darwin* } } */
 /* { dg-options "-F." } */
 
-#include 
+/* 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.  */
+
+#include 


[gcc r12-10374] libstdc++: Sync the atomic_link_flags implementation with GCC.

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:63842c1dd7f48ed8b8284455c05ea5dfccfcd42b

commit r12-10374-g63842c1dd7f48ed8b8284455c05ea5dfccfcd42b
Author: Iain Sandoe 
Date:   Mon Mar 18 09:57:33 2024 +

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 
(cherry picked from commit 71a44faa8a4f76d68356c66c6054e6c242df820f)

Diff:
---
 libstdc++-v3/testsuite/lib/dg-options.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp 
b/libstdc++-v3/testsuite/lib/dg-options.exp
index 203bb0dfed5..7269b6a4efc 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -274,7 +274,7 @@ proc atomic_link_flags { paths } {
   if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"]
|| [file exists 
"${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } {
   append flags " -B${gccpath}/libatomic/ "
-  append flags " -L${gccpath}/libatomic/.libs"
+  append flags " -B${gccpath}/libatomic/.libs"
   append ld_library_path ":${gccpath}/libatomic/.libs"
   }
 } else {


[gcc r12-10372] Darwin, testsuite: -multiply_defined is obsolete

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:d450d2b3d0b36d5f2715f204cb0ad2ff1759d3c8

commit r12-10372-gd450d2b3d0b36d5f2715f204cb0ad2ff1759d3c8
Author: Francois-Xavier Coudert 
Date:   Sat Feb 10 15:52:44 2024 +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)

Diff:
---
 gcc/testsuite/gcc.dg/ssp-2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/ssp-2.c b/gcc/testsuite/gcc.dg/ssp-2.c
index 752fe5393f4..608ca300032 100644
--- a/gcc/testsuite/gcc.dg/ssp-2.c
+++ b/gcc/testsuite/gcc.dg/ssp-2.c
@@ -1,6 +1,7 @@
 /* { dg-do run { target native } } */
 /* { dg-options "-fstack-protector" } */
 /* { dg-options "-fstack-protector -Wl,-multiply_defined,suppress" { target 
*-*-darwin* } } */
+/* { dg-prune-output "-multiply_defined is obsolete" } */
 /* { dg-require-effective-target fstack_protector } */
 
 #include 


[gcc r12-10371] Darwin, testsuite: -bind_at_load is deprecated

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:1cd44c5e28533963b8cc7ddcac38e1b87c7c5dd1

commit r12-10371-g1cd44c5e28533963b8cc7ddcac38e1b87c7c5dd1
Author: Francois-Xavier Coudert 
Date:   Sat Feb 10 12:55:29 2024 +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)

Diff:
---
 gcc/testsuite/gcc.dg/darwin-ld-2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/darwin-ld-2.c 
b/gcc/testsuite/gcc.dg/darwin-ld-2.c
index 5de19524f0b..2a6b491da5b 100644
--- a/gcc/testsuite/gcc.dg/darwin-ld-2.c
+++ b/gcc/testsuite/gcc.dg/darwin-ld-2.c
@@ -3,6 +3,7 @@
 
 /* { dg-options "-bind_at_load" } */
 /* { dg-do link { target *-*-darwin* } } */
+/* { dg-prune-output "-bind_at_load is deprecated" } */
 
 int main()
 {


[gcc r12-10370] Testsuite: restrict test to nonpic targets

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:0eb6f8874047f7e7f13027aaac14d3de276c5e69

commit r12-10370-g0eb6f8874047f7e7f13027aaac14d3de276c5e69
Author: Francois-Xavier Coudert 
Date:   Mon Dec 11 09:26:23 2023 +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)

Diff:
---
 gcc/testsuite/gcc.target/i386/pr100936.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.target/i386/pr100936.c 
b/gcc/testsuite/gcc.target/i386/pr100936.c
index c076cbb2405..af494946fcd 100644
--- a/gcc/testsuite/gcc.target/i386/pr100936.c
+++ b/gcc/testsuite/gcc.target/i386/pr100936.c
@@ -1,6 +1,7 @@
 /* PR target/100936 */
 /* { dg-do assemble } */
 /* { dg-options "-O2" } */
+/* { dg-require-effective-target nonpic } */
 
 __seg_gs int var;


[gcc r12-10369] Testsuite, i386: Mark test as requiring ifunc

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:711506673963587572a5a97fc86809378ac76656

commit r12-10369-g711506673963587572a5a97fc86809378ac76656
Author: Francois-Xavier Coudert 
Date:   Mon Oct 30 15:41:10 2023 +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)

Diff:
---
 gcc/testsuite/gcc.target/i386/pr105554.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.target/i386/pr105554.c 
b/gcc/testsuite/gcc.target/i386/pr105554.c
index 08e90bb3368..e9ef494270a 100644
--- a/gcc/testsuite/gcc.target/i386/pr105554.c
+++ b/gcc/testsuite/gcc.target/i386/pr105554.c
@@ -1,5 +1,6 @@
 /* PR target/105554 */
 /* { dg-do compile } */
+/* { dg-require-ifunc "" } */
 /* { dg-options "-O2 -Wno-psabi -mno-sse3" } */
 
 typedef long long v4di __attribute__((__vector_size__(32)));


[gcc r12-10368] Testsuite, DWARF2: adjust regexp to match darwin output

2024-04-21 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:57506ac6ece97188c427e075e08b8128822fcd1e

commit r12-10368-g57506ac6ece97188c427e075e08b8128822fcd1e
Author: Francois-Xavier Coudert 
Date:   Sun Aug 20 12:53:19 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c 
b/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
index 2faef6e2a4f..22eb35fcf09 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
@@ -2,7 +2,7 @@
the DW_TAG_inlined_subroutine and the DW_TAG_variable for the local.  */
 /* { dg-options "-O -gdwarf -dA" } */
 /* { dg-do compile } */
-/* { dg-final { scan-assembler 
"DW_TAG_inlined_subroutine\[^\\(\]*\\(\[^\\)\]*\\)\[^\\(\]*\\(DIE 
\\(0x\[0-9a-f\]*\\) DW_TAG_formal_parameter\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) 
DW_TAG_variable" } } */
+/* { dg-final { scan-assembler 
"DW_TAG_inlined_subroutine\[^\\(\]*\(\|\\(\[^\\)\]*\\)\)\[^\\(\]*\\(DIE 
\\(0x\[0-9a-f\]*\\) DW_TAG_formal_parameter\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) 
DW_TAG_variable" } } */
 /* { dg-final { scan-assembler-times "DW_TAG_inlined_subroutine" 2 } } */
 
 static int foo (int i)


[gcc r12-10366] Testsuite, Darwin: skip PIE test

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a6fa5387a3417ee46a97886d1065eb102363

commit r12-10366-ga6fa5387a3417ee46a97886d1065eb102363
Author: Francois-Xavier Coudert 
Date:   Mon Oct 30 12:41:17 2023 +0100

Testsuite, Darwin: skip PIE test

gcc/testsuite/ChangeLog:

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

(cherry picked from commit a0c557690c8d5327deda6e21f8d1deca8451a4cb)

Diff:
---
 gcc/testsuite/gcc.dg/pie-2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/pie-2.c b/gcc/testsuite/gcc.dg/pie-2.c
index 1838745a11a..0a1cc27a503 100644
--- a/gcc/testsuite/gcc.dg/pie-2.c
+++ b/gcc/testsuite/gcc.dg/pie-2.c
@@ -2,6 +2,7 @@
 /* { dg-options "-fPIE" } */
 /* { dg-require-effective-target pie } */
 /* { dg-skip-if "__PIC__ is always 1 for MIPS" { mips*-*-* } } */
+/* { dg-skip-if "__PIE__ is often not defined on darwin" { *-*-darwin* } } */
 
 #if __PIC__ != 2
 # error __PIC__ is not 2!


[gcc r12-10365] testsuite, Darwin: Skip g++.dg/debug/dwarf2/pr85550.C

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:65f76ed01aca192ccfc13764456892760f9ab1fd

commit r12-10365-g65f76ed01aca192ccfc13764456892760f9ab1fd
Author: Iain Sandoe 
Date:   Sun Oct 1 20:38:44 2023 +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 
(cherry picked from commit 76547f4c97b1c0744487d624c5e2e5a15d0370a9)

Diff:
---
 gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C 
b/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C
index 35b0f56e959..c95f75255d4 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C
@@ -2,6 +2,7 @@
 // { dg-do link }
 // { dg-options "-O2 -g -fdebug-types-section" }
 // { dg-skip-if "AIX DWARF5" { powerpc-ibm-aix* } }
+// { dg-skip-if "No debug linker support" { *-*-darwin* } }
 
 struct A {
   int bar () const { return 0; }


[gcc r12-10364] testsuite: adjust for darwin linker warning

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:69e2b9620d223c98c0457b26d99964434c69ef11

commit r12-10364-g69e2b9620d223c98c0457b26d99964434c69ef11
Author: Francois-Xavier Coudert 
Date:   Fri Sep 8 21:55:56 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/darwin-segaddr.c | 1 +
 gcc/testsuite/gcc.dg/pie-7.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/darwin-segaddr.c 
b/gcc/testsuite/gcc.dg/darwin-segaddr.c
index 526db77bd9c..77112ddb484 100644
--- a/gcc/testsuite/gcc.dg/darwin-segaddr.c
+++ b/gcc/testsuite/gcc.dg/darwin-segaddr.c
@@ -2,6 +2,7 @@
 /* { dg-do run { target *-*-darwin* } } */
 /* { dg-options "-O0 -segaddr __TEST 0x20 -fno-pie" { target { *-*-darwin* 
&& { ! lp64 } } } } */
 /* { dg-options "-O0 -segaddr __TEST 0x11000 -fno-pie" { target { 
*-*-darwin* && lp64 } } } */
+/* { dg-prune-output "-no_pie is deprecated when targeting new OS versions" } 
*/
 
 extern void abort ();
 
diff --git a/gcc/testsuite/gcc.dg/pie-7.c b/gcc/testsuite/gcc.dg/pie-7.c
index e118a98bafd..3879a6cc120 100644
--- a/gcc/testsuite/gcc.dg/pie-7.c
+++ b/gcc/testsuite/gcc.dg/pie-7.c
@@ -1,5 +1,6 @@
 /* { dg-do run { target pie } } */
 /* { dg-options "-fno-pie -no-pie" } */
+/* { dg-prune-output "-no_pie is deprecated when targeting new OS versions" } 
*/
 
 int main(void)
 {


[gcc r12-10363] Testsuite, darwin: account for macOS 13 and 14

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:79f5f989986a32b4c68daf53f9bc5741094af97a

commit r12-10363-g79f5f989986a32b4c68daf53f9bc5741094af97a
Author: Francois-Xavier Coudert 
Date:   Mon Aug 21 00:00:44 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/darwin-minversion-link.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-link.c 
b/gcc/testsuite/gcc.dg/darwin-minversion-link.c
index b6ede31c985..a835e9d4648 100644
--- a/gcc/testsuite/gcc.dg/darwin-minversion-link.c
+++ b/gcc/testsuite/gcc.dg/darwin-minversion-link.c
@@ -17,6 +17,8 @@
 /* { dg-additional-options "-mmacosx-version-min=010.015.06 -DCHECK=101506" { 
target *-*-darwin19* } } */
 /* { dg-additional-options "-mmacosx-version-min=011.000.00 -DCHECK=11" { 
target *-*-darwin20* } } */
 /* { dg-additional-options "-mmacosx-version-min=012.000.00 -DCHECK=12" { 
target *-*-darwin21* } } */
+/* { dg-additional-options "-mmacosx-version-min=013.000.00 -DCHECK=13" { 
target *-*-darwin22* } } */
+/* { dg-additional-options "-mmacosx-version-min=014.000.00 -DCHECK=14" { 
target *-*-darwin23* } } */
 
 int
 main ()


[gcc r12-10362] Testsuite: mark IPA test as requiring alias support

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:3d48cd6623d7b70c8d1e2a0365bb016390409013

commit r12-10362-g3d48cd6623d7b70c8d1e2a0365bb016390409013
Author: Francois-Xavier Coudert 
Date:   Sun Aug 20 14:13:22 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c 
b/gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c
index 452e1b88514..57c5262dd4a 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c
@@ -1,4 +1,5 @@
 /* { dg-do link } */
+/* { dg-require-alias "" } */
 /* { dg-options "-O2 -fdump-ipa-icf-optimized -flto -fdump-tree-optimized" } */
 /* { dg-require-effective-target lto } */
 /* { dg-additional-sources "ipa-icf-38a.c" }*/


[gcc r12-10361] Testsuite: fix analyzer tests on Darwin

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:c2cb625eb141cacd0bee6c6ce5888d673ac38ca4

commit r12-10361-gc2cb625eb141cacd0bee6c6ce5888d673ac38ca4
Author: Francois-Xavier Coudert 
Date:   Sat Aug 19 23:22:06 2023 +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)

Diff:
---
 gcc/testsuite/gcc.dg/analyzer/analyzer.exp | 8 
 1 file changed, 8 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/analyzer/analyzer.exp 
b/gcc/testsuite/gcc.dg/analyzer/analyzer.exp
index 15d979cd8b5..333e8402443 100644
--- a/gcc/testsuite/gcc.dg/analyzer/analyzer.exp
+++ b/gcc/testsuite/gcc.dg/analyzer/analyzer.exp
@@ -32,6 +32,14 @@ if [info exists DEFAULT_CFLAGS] then {
 # If a testcase doesn't have special options, use these.
 set DEFAULT_CFLAGS "-fanalyzer -Wanalyzer-too-complex 
-fanalyzer-call-summaries"
 
+if { [istarget "*-*-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
+  set DEFAULT_CFLAGS "$DEFAULT_CFLAGS -D_FORTIFY_SOURCE=0"
+}
+
 # Initialize `dg'.
 dg-init


[gcc r12-10360] testsuite, Darwin: Allow for undefined symbols in shared test.

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:edc5acccf94e521c126b4d3b3b49287ceb8cd841

commit r12-10360-gedc5acccf94e521c126b4d3b3b49287ceb8cd841
Author: Iain Sandoe 
Date:   Mon Jan 29 10:09:25 2024 +

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 

Diff:
---
 gcc/testsuite/lib/target-supports.exp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index e0076ed8f69..64216dfbdb2 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1258,13 +1258,20 @@ proc check_effective_target_aarch64_tlsle32 { } {
 # emitted, 0 otherwise.
 
 proc check_effective_target_shared { } {
+# Darwin's linker defaults to error on undefined (which makes it look as
+# if we do not support shared) but we can tell it to allow the symbols used
+# here to be undefined.
+set extra_flags ""
+if { [istarget *-*-darwin\[912\]*] } {
+  set extra_flags "-Wl,-U,_foo,-U,_bar,-U,__Z3foov"
+}
 # Note that M68K has a multilib that supports -fpic but not
 # -fPIC, so we need to check both.  We test with a program that
 # requires GOT references.
 return [check_no_compiler_messages shared executable {
extern int foo (void); extern int bar;
int baz (void) { return foo () + bar; }
-} "-shared -fpic"]
+} "-shared -fpic $extra_flags"]
 }
 
 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.


[gcc r12-10359] testsuite, jit, Darwin: Handle Mach-O in assembler tests.

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:b358e73b7d642afa7a2b836283910ef7539dafe2

commit r12-10359-gb358e73b7d642afa7a2b836283910ef7539dafe2
Author: Iain Sandoe 
Date:   Sat Jan 13 13:40:51 2024 +

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 
(cherry picked from commit 283e3a974bf08e4fb64d51d2062e1f7ed7482ff4)

Diff:
---
 gcc/testsuite/jit.dg/test-setting-alignment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/jit.dg/test-setting-alignment.c 
b/gcc/testsuite/jit.dg/test-setting-alignment.c
index 8489df9c6b9..14edc723f61 100644
--- a/gcc/testsuite/jit.dg/test-setting-alignment.c
+++ b/gcc/testsuite/jit.dg/test-setting-alignment.c
@@ -62,5 +62,6 @@ create_code (gcc_jit_context *ctxt, void *user_data)
 }
 
 /* { dg-final { jit-verify-output-file-was-created "" } } */
-/* { dg-final { jit-verify-assembler-output ".comm foo,4,8" } } */
+/* { dg-final { jit-verify-assembler-output ".comm foo,4,8" { target { ! 
*-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".comm\\s_foo,4,3" { target 
*-*-darwin* } } } */
 /* { dg-final { jit-verify-assembler-output "movl  -16\\\(%rbp\\\), %eax" 
} } */


[gcc r12-10358] testsuite, jit: Allow for target-specific assembler scans.

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:e73c4d7a236da0a1a9232861fe32bca0e5304870

commit r12-10358-ge73c4d7a236da0a1a9232861fe32bca0e5304870
Author: Iain Sandoe 
Date:   Sat Jan 13 13:30:08 2024 +

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 
(cherry picked from commit e0e3ef18a047d54d63be91d82a55448851353260)

Diff:
---
 gcc/testsuite/jit.dg/jit.exp | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp
index 3568dbb9d63..35d38cec5bc 100644
--- a/gcc/testsuite/jit.dg/jit.exp
+++ b/gcc/testsuite/jit.dg/jit.exp
@@ -871,9 +871,23 @@ proc jit-verify-assembler { args } {
 proc jit-verify-assembler-output { args } {
 verbose "jit-verify-assembler: $args"
 
+if { [llength $args] > 3 } {
+   error "jit-verify-assembler-output: too many arguments"
+   return
+}
+
 set dg-output-text [lindex $args 0]
 verbose "dg-output-text: ${dg-output-text}"
 
+if { [llength $args] >= 2 } {
+   switch [dg-process-target [lindex $args 1]] {
+   "S" { }
+   "N" { return }
+   "F" { setup_xfail "*-*-*" }
+   "P" { }
+   }
+}
+
 upvar 2 name name
 verbose "name: $name"


[gcc r12-10357] testsuite, jit: Handle whitespace in test-link-section-assembler.c.

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:12e4b9ce523bd60acfb3d5567e493822fcdcf698

commit r12-10357-g12e4b9ce523bd60acfb3d5567e493822fcdcf698
Author: Iain Sandoe 
Date:   Sat Jan 13 12:49:28 2024 +

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 
(cherry picked from commit 2b0abfd3f8dbe3e9af79bb6bdc06d727d36f1946)

Diff:
---
 gcc/testsuite/jit.dg/test-link-section-assembler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/jit.dg/test-link-section-assembler.c 
b/gcc/testsuite/jit.dg/test-link-section-assembler.c
index a90b00e9a82..a78e9fd26ef 100644
--- a/gcc/testsuite/jit.dg/test-link-section-assembler.c
+++ b/gcc/testsuite/jit.dg/test-link-section-assembler.c
@@ -34,4 +34,4 @@ create_code (gcc_jit_context *ctxt, void *user_data)
 }
 
 /* { dg-final { jit-verify-output-file-was-created "" } } */
-/* { dg-final { jit-verify-assembler-output ".section  .my_section" } } */
+/* { dg-final { jit-verify-assembler-output ".section\\s.my_section" } } */


[gcc r12-10356] Objective-C/C++: Ensure sufficient setup for the preprocessor.

2024-04-20 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:633e24e1c7846cdd6796074f42254afdf0f44ef3

commit r12-10356-g633e24e1c7846cdd6796074f42254afdf0f44ef3
Author: Iain Sandoe 
Date:   Tue Jan 9 17:31:41 2024 +

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 
(cherry picked from commit 60f58d0630805e8dce79f5489658fd83e42fa8f1)

Diff:
---
 gcc/objc/objc-act.cc | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/objc/objc-act.cc b/gcc/objc/objc-act.cc
index 252274c8f5d..4820c5dbac3 100644
--- a/gcc/objc/objc-act.cc
+++ b/gcc/objc/objc-act.cc
@@ -347,6 +347,11 @@ bool
 objc_init (void)
 {
   bool ok;
+
+  /* Set up stuff used by the preprocessor as well as FE parser.  */
+  interface_hash_init ();
+  hash_init ();
+
 #ifdef OBJCPLUS
   if (cxx_init () == false)
 #else
@@ -376,8 +381,6 @@ objc_init (void)
 
   /* Set up stuff used by FE parser and all runtimes.  */
   errbuf = XNEWVEC (char, 1024 * 10);
-  interface_hash_init ();
-  hash_init ();
   objc_encoding_init ();
   /* ... and then check flags and set-up for the selected runtime ... */
   if (flag_next_runtime && flag_objc_abi >= 2)


[gcc r12-10354] testsuite, objective-c++: Fix imported NSObjCRuntime.h.

2024-04-19 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:f04f8734f792159d8bc001946fe4ca6f3503034f

commit r12-10354-gf04f8734f792159d8bc001946fe4ca6f3503034f
Author: Iain Sandoe 
Date:   Fri Jun 23 15:29:14 2023 +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 

gcc/testsuite/ChangeLog:

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

(cherry picked from commit d83e0e3bc375a05844438d28c9a4ab24c5401eb9)

Diff:
---
 gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h 
b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h
index 189af80436a..62556f9ac88 100644
--- a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h
+++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h
@@ -29,6 +29,9 @@
 #ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
 #define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
 
+/* Allow the elaborated enum use in _GS_NAMED_ENUM. */
+#pragma GCC system_header
+
 #ifdef __cplusplus
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS 1


[gcc r12-10353] testsuite, Objective-C: Fix duplicate libobjc cases.

2024-04-19 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:04dbdb7347a0b4846311cfce7665b49ea288433f

commit r12-10353-g04dbdb7347a0b4846311cfce7665b49ea288433f
Author: Iain Sandoe 
Date:   Thu Jan 25 20:17:42 2024 +

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 
(cherry picked from commit 30d9e81c19d69e15b2e9c53e4377879cbf9b0b84)

Diff:
---
 gcc/testsuite/obj-c++.dg/encode-10.mm | 1 -
 gcc/testsuite/obj-c++.dg/encode-9.mm  | 1 -
 2 files changed, 2 deletions(-)

diff --git a/gcc/testsuite/obj-c++.dg/encode-10.mm 
b/gcc/testsuite/obj-c++.dg/encode-10.mm
index 2b3af88dcb1..2477400b7f3 100644
--- a/gcc/testsuite/obj-c++.dg/encode-10.mm
+++ b/gcc/testsuite/obj-c++.dg/encode-10.mm
@@ -1,5 +1,4 @@
 /* Test for @encode in templates.  */
-/* { dg-options "-lobjc" } */
 /* { dg-do run } */
 #include
 #include 
diff --git a/gcc/testsuite/obj-c++.dg/encode-9.mm 
b/gcc/testsuite/obj-c++.dg/encode-9.mm
index 6b064dfdc09..4fdb5fa50fb 100644
--- a/gcc/testsuite/obj-c++.dg/encode-9.mm
+++ b/gcc/testsuite/obj-c++.dg/encode-9.mm
@@ -1,5 +1,4 @@
 /* Test than @encode is properly instantiated. */
-/* { dg-options "-lobjc" } */
 /* { dg-do run } */
 
 #include 


[gcc r12-10352] Darwin: Handle the fPIE option specially.

2024-04-19 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:30766064e4f88bca3909ecd9737eeb5f4d36be81

commit r12-10352-g30766064e4f88bca3909ecd9737eeb5f4d36be81
Author: Iain Sandoe 
Date:   Wed Oct 25 15:28:52 2023 +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 
(cherry picked from commit da9e72f80f3358bd9586e11aaf03341c1f867318)

Diff:
---
 gcc/config/darwin.cc | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 129250a48fd..3cbdc97662d 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -3299,6 +3299,8 @@ darwin_override_options (void)
 {
   if (strverscmp (darwin_macosx_version_min, "10.14") >= 0)
generating_for_darwin_version = 18;
+  else if (strverscmp (darwin_macosx_version_min, "10.8") >= 0)
+   generating_for_darwin_version = 12;
   else if (strverscmp (darwin_macosx_version_min, "10.7") >= 0)
generating_for_darwin_version = 11;
   else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0)
@@ -3469,8 +3471,17 @@ darwin_override_options (void)
   && dwarf_debuginfo_p ())
 flag_var_tracking_uninit = flag_var_tracking;
 
-  /* Final check on PCI options; for Darwin these are not dependent on the PIE
- ones, although PIE does require PIC to support it.  */
+  if (OPTION_SET_P (flag_pie) && flag_pie)
+{
+  /* This is a little complicated, to match Xcode tools.
+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 Darwin12-17 and for 32b only.  */
+  flag_pie = generating_for_darwin_version >= 12 && !TARGET_64BIT ? 2 : 0;
+  flag_pic = 2; /* We always set this.  */
+}
+
+  /* Final check on PIC options.  */
   if (MACHO_DYNAMIC_NO_PIC_P)
 {
   if (flag_pic)


[gcc r12-10351] Darwin: Correct handling of weak crts.

2024-04-19 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:f1ef7143fba7e09ec10a60227ebb46eb5d6553f9

commit r12-10351-gf1ef7143fba7e09ec10a60227ebb46eb5d6553f9
Author: Iain Sandoe 
Date:   Thu Mar 21 14:34:44 2024 +

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 

Diff:
---
 gcc/config/darwin.h | 37 ++---
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 0f17932440f..6b124601274 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -367,7 +367,9 @@ extern GTY(()) int darwin_ms_struct;
 %{e*} %{r} \
 %{o*}%{!o:-o a.out} \
 %{!r:%{!nostdlib:%{!nostartfiles:%S}}} \
-%{L*} %(link_libgcc) %o \
+%{L*} %(link_libgcc) \
+%{!r:%{!nostdlib:%{!nodefaultlibs: " DARWIN_WEAK_CRTS "}}} \
+%o \
 %{!r:%{!nostdlib:%{!nodefaultlibs:\
   %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
   %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \
@@ -381,15 +383,15 @@ extern GTY(()) int darwin_ms_struct;
   %(link_ssp) \
   %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \
   %(link_gcc_c_sequence) \
-  %{!nodefaultexport:%{dylib|dynamiclib|bundle: \
-   %:version-compare(>= 10.11 asm_macosx_version_min= -U) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= 
___emutls_get_address) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= 
___emutls_get_address) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= -U) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= 
___emutls_register_common) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
-   %:version-compare(>= 10.11 asm_macosx_version_min= 
___emutls_register_common) \
+  %{!nodefaultexport: \
+   %{%:version-compare(>= 10.11 asm_macosx_version_min= -U): \
+  ___emutls_get_address -exported_symbol ___emutls_get_address \
+ -U ___emutls_register_common \
+ -exported_symbol ___emutls_register_common \
+ -U ___gcc_nested_func_ptr_created \
+ -exported_symbol ___gcc_nested_func_ptr_created \
+ -U ___gcc_nested_func_ptr_deleted \
+ -exported_symbol ___gcc_nested_func_ptr_deleted \
   }} \
 }}}\
 %{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\
@@ -515,17 +517,22 @@ extern GTY(()) int darwin_ms_struct;
 #undef REAL_LIBGCC_SPEC
 #define REAL_LIBGCC_SPEC \
 "%{static-libgcc|static: \
-%:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh) \
-%:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w);
  \
+%:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh);\
shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime:  \
 %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \
-%:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w)
  \
 %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh)   \
 %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4)   \
-%:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5);   \
-   : -lemutls_w
  \
+%:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)\
   } -lgcc "
 
+#define DARWIN_WEAK_CRTS \
+"%{static-libgcc|static: \
+   %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w) ; \
+   shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \
+ %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) ; \
+   : -lemutls_w \
+  }"
+
 /* We specify crt0.o as -lcrt0.o so that ld will search the library path.  */
 
 #undef  STARTFILE_SPEC


[gcc r12-10350] Objective-C, Darwin: Do not overalign CFStrings and Objective-C metadata.

2024-04-19 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:877d87416656cbd8bf21676e6f54865583aa03c8

commit r12-10350-g877d87416656cbd8bf21676e6f54865583aa03c8
Author: Iain Sandoe 
Date:   Thu Jan 25 20:11:09 2024 +

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 
(cherry picked from commit f74f840d35117bcaf995cee99fb2ab30c60f64f3)

Diff:
---
 gcc/config/darwin.cc|  1 +
 gcc/objc/objc-next-runtime-abi-02.cc| 18 +++---
 gcc/objc/objc-runtime-shared-support.cc |  4 
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index a11095716d8..129250a48fd 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -3859,6 +3859,7 @@ darwin_build_constant_cfstring (tree str)
   /* global namespace.  */
   DECL_CONTEXT (var) = NULL_TREE;
   DECL_INITIAL (var) = constructor;
+  DECL_USER_ALIGN (var) = 1;
   lang_hooks.decls.pushdecl (var);
   rest_of_decl_compilation (var, 1, 0);
   desc->ccf_str = var;
diff --git a/gcc/objc/objc-next-runtime-abi-02.cc 
b/gcc/objc/objc-next-runtime-abi-02.cc
index a9b3e32b92d..1dee05df769 100644
--- a/gcc/objc/objc-next-runtime-abi-02.cc
+++ b/gcc/objc/objc-next-runtime-abi-02.cc
@@ -2246,6 +2246,7 @@ build_v2_address_table (vec *src, const char 
*nam, tree attr)
   DECL_PRESERVE_P (decl) = 1;
   expr = objc_build_constructor (type, initlist);
   OBJCMETA (decl, objc_meta, attr);
+  DECL_USER_ALIGN (decl) = 1;
   finish_var_decl (decl, expr);
 }
 
@@ -2320,8 +2321,9 @@ build_v2_protocol_list_address_table (void)
decl = create_global_decl (objc_protocol_type, buf, /*is def=*/true);
   expr = convert (objc_protocol_type, build_fold_addr_expr (ref->refdecl));
   OBJCMETA (decl, objc_meta, meta_label_protocollist);
-  finish_var_decl (decl, expr);
   DECL_PRESERVE_P (decl) = 1;
+  DECL_USER_ALIGN (decl) = 1;
+  finish_var_decl (decl, expr);
 }
 
 /* TODO: delete the vec.  */
@@ -2399,6 +2401,7 @@ generate_v2_protocol_list (tree i_or_p, tree klass_ctxt)
   /* ObjC2 puts all these in the base section.  */
   OBJCMETA (refs_decl, objc_meta, meta_base);
   DECL_PRESERVE_P (refs_decl) = 1;
+  DECL_USER_ALIGN (refs_decl) = 1;
   finish_var_decl (refs_decl,
   objc_build_constructor (TREE_TYPE (refs_decl),initlist));
   return refs_decl;
@@ -2507,6 +2510,7 @@ generate_v2_meth_descriptor_table (tree chain, tree 
protocol,
   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, initlist);
   /* Get into the right section.  */
   OBJCMETA (decl, objc_meta, attr);
+  DECL_USER_ALIGN (decl) = 1;
   finish_var_decl (decl, objc_build_constructor (method_list_template, v));
   return decl;
 }

  1   2   >