[gcc r14-9541] libstdc++, Darwin: Do not use dev/null as the file for executables.

2024-03-19 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:e47330d0742c985fd8d5fe7089aa381d34967d61

commit r14-9541-ge47330d0742c985fd8d5fe7089aa381d34967d61
Author: Iain Sandoe 
Date:   Tue Mar 19 10:40:50 2024 +

libstdc++, Darwin: Do not use dev/null as the file for executables.

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

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

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

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

libstdc++-v3/ChangeLog:

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

Signed-off-by: Iain Sandoe 

Diff:
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 58804ecab26..7466fb51c58 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -615,11 +615,15 @@ proc v3_target_compile { source dest type options } {
}
 }
 
+# For Windows and Darwin we might want to create a temporary file.
+# Note that it needs deleting.
+set file_to_delete ""
 # Small adjustment for Windows hosts.
 if { $dest == "/dev/null"
  && [info exists ::env(OS)] && [string match "Windows*" $::env(OS)] } {
if { $type == "executable" } {
set dest "x.exe"
+   set file_to_delete ${dest}
} else {
# Windows uses special file named "nul" as a substitute for
# /dev/null
@@ -627,6 +631,15 @@ proc v3_target_compile { source dest type options } {
}
 }
 
+# Using /dev/null as the executable name does not work on Darwin when
+# debug is enabled, since the debug linker does not accept /dev/null as
+# a valid executable name.
+if { $dest == "/dev/null" && [istarget *-*-darwin*]
+ && $type == "executable" } {
+   set dest dev-null-[pid].exe
+   set file_to_delete ${dest}
+}
+
 lappend options "compiler=$cxx_final"
 lappend options "timeout=[timeout_value]"
 
@@ -637,7 +650,12 @@ proc v3_target_compile { source dest type options } {
 }
 
 set comp_output [target_compile $source $dest $type $options]
-
+if { $type == "executable" && $file_to_delete != "" } {
+   file delete $file_to_delete
+   if { [istarget *-*-darwin*] && [file exists $file_to_delete.dSYM] } {
+   file delete -force $file_to_delete.dSYM
+   }
+}
 return $comp_output
 }


[gcc r14-9542] libstdc++: Sync the atomic_link_flags implementation with GCC.

2024-03-19 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:71a44faa8a4f76d68356c66c6054e6c242df820f

commit r14-9542-g71a44faa8a4f76d68356c66c6054e6c242df820f
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 

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 bc387d17ed7..00ca678a53a 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -314,7 +314,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 r13-8576] libstdc++: Sync the atomic_link_flags implementation with GCC.

2024-04-03 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:5975807ae77896e6e67656f38304149a643816b9

commit r13-8576-g5975807ae77896e6e67656f38304149a643816b9
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 f7d5b05d6ed..427a251e789 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -314,7 +314,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 r13-8577] libstdc++, Darwin: Handle a linker warning [PR112397].

2024-04-03 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:ae11f0154116f4e5fa8769b1ea1600b1b1c22958

commit r13-8577-gae11f0154116f4e5fa8769b1ea1600b1b1c22958
Author: Iain Sandoe 
Date:   Thu Feb 8 17:54:31 2024 +

libstdc++, Darwin: Handle a linker warning [PR112397].

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

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

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

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

PR target/112397

libstdc++-v3/ChangeLog:

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

Signed-off-by: Iain Sandoe 
Co-authored-by: Jonathan Wakely 
(cherry picked from commit 1609fdff16f17ead37666f6d0e801800ee3d04d2)

Diff:
---
 libstdc++-v3/configure | 36 
 libstdc++-v3/configure.ac  |  7 +++
 libstdc++-v3/libsupc++/Makefile.am |  8 
 libstdc++-v3/libsupc++/Makefile.in |  6 ++
 4 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 53882c3f6b6..d35baaf7c6e 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -789,6 +789,8 @@ GLIBCXX_HOSTED_TRUE
 glibcxx_compiler_shared_flag
 glibcxx_compiler_pic_flag
 glibcxx_lt_pic_flag
+OS_IS_DARWIN_FALSE
+OS_IS_DARWIN_TRUE
 enable_static
 enable_shared
 lt_host_flags
@@ -12187,7 +12189,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12190 "configure"
+#line 12192 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12293,7 +12295,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12296 "configure"
+#line 12298 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15595,6 +15597,20 @@ esac
 
 
 
+os_is_darwin=no
+case ${host_os} in
+  darwin*) os_is_darwin=yes ;;
+  *) ;;
+esac
+ if test x${os_is_darwin} = xyes; then
+  OS_IS_DARWIN_TRUE=
+  OS_IS_DARWIN_FALSE='#'
+else
+  OS_IS_DARWIN_TRUE='#'
+  OS_IS_DARWIN_FALSE=
+fi
+
+
 if test "$enable_vtable_verify" = yes; then
   predep_objects_CXX="${predep_objects_CXX} 
${glibcxx_builddir}/../libgcc/vtv_start.o"
   postdep_objects_CXX="${postdep_objects_CXX} 
${glibcxx_builddir}/../libgcc/vtv_end.o"
@@ -16017,7 +16033,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
   # Fake what AC_TRY_COMPILE does.
 
 cat > conftest.$ac_ext << EOF
-#line 16020 "configure"
+#line 16036 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -16052,7 +16068,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16055 "configure"
+#line 16071 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -16087,7 +16103,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16090 "configure"
+#line 16106 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -16123,7 +16139,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16126 "configure"
+#line 16142 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -16279,7 +16295,7 @@ $as_echo "mutex" >&6; }
   # unnecessary for this test.
 
 cat > conftest.$ac_ext << EOF
-#line 16282 "configure"
+#line 16298 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -16321,7 +16337,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
   cat > conftest.$ac_ext << EOF
-#line 16324 "configure"
+#line 16340 "configure"
 template
   struct same
   { typedef T2 type; };
@@ -73293,6 +73309,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z 
"${MAINTAINER_MODE_FALSE}"; then
   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${OS_IS_DARWIN_TRUE}" && test -z "${OS_IS_DARWIN_FALSE}"; then

[gcc r12-10336] libstdc++, Darwin: Limit recursive mutex init to OS versions needing it.

2024-04-18 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:ab4ff3e9fe881ef85a8156f2be528872c6a2fdfc

commit r12-10336-gab4ff3e9fe881ef85a8156f2be528872c6a2fdfc
Author: Iain Sandoe 
Date:   Sat Dec 3 17:09:35 2022 +

libstdc++, Darwin: Limit recursive mutex init to OS versions needing it.

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

Signed-off-by: Iain Sandoe 

libstdc++-v3/ChangeLog:

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

(cherry picked from commit a044c9d25972b22c6b4c8ec27f2de5fd622573cc)

Diff:
---
 libstdc++-v3/config/os/bsd/darwin/os_defines.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/os/bsd/darwin/os_defines.h 
b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
index a8b6d4fa324..f56f31ad2f5 100644
--- a/libstdc++-v3/config/os/bsd/darwin/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
@@ -39,8 +39,12 @@
 // -flat_namespace to work around the way that it doesn't.
 #define _GLIBCXX_WEAK_DEFINITION __attribute__ ((weak))
 
-// Static initializer macro is buggy in darwin, see libstdc++/51906
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
+ && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1080)
+// Static initializer macro is absent for Darwin < 11 and buggy in Darwin 11,
+// see libstdc++/51906.  Fixed in Darwin 12 (OS X 10.8).
 #define _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
+#endif
 
 // Configure checks for nanosleep fail on Darwin, but nanosleep and
 // sched_yield are always available, so use them.


[gcc r12-10373] libstdc++, Darwin: Do not use dev/null as the file for executables.

2024-04-21 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:678f6bc1655d9bf4ecec06e733122823a512ee4d

commit r12-10373-g678f6bc1655d9bf4ecec06e733122823a512ee4d
Author: Iain Sandoe 
Date:   Tue Mar 19 10:40:50 2024 +

libstdc++, Darwin: Do not use dev/null as the file for executables.

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

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

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

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

libstdc++-v3/ChangeLog:

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

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

Diff:
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 0debbea7ee1..789d0fce549 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -510,11 +510,41 @@ proc v3_target_compile { source dest type options } {
}
 }
 
+# For Windows and Darwin we might want to create a temporary file.
+# Note that it needs deleting.
+set file_to_delete ""
+# Small adjustment for Windows hosts.
+if { $dest == "/dev/null"
+ && [info exists ::env(OS)] && [string match "Windows*" $::env(OS)] } {
+   if { $type == "executable" } {
+   set dest "x.exe"
+   set file_to_delete ${dest}
+   } else {
+   # Windows uses special file named "nul" as a substitute for
+   # /dev/null
+   set dest "nul"
+   }
+}
+
+# Using /dev/null as the executable name does not work on Darwin when
+# debug is enabled, since the debug linker does not accept /dev/null as
+# a valid executable name.
+if { $dest == "/dev/null" && [istarget *-*-darwin*]
+ && $type == "executable" } {
+   set dest dev-null-[pid].exe
+   set file_to_delete ${dest}
+}
+
 lappend options "compiler=$cxx_final"
 lappend options "timeout=[timeout_value]"
 
 set comp_output [target_compile $source $dest $type $options]
-
+if { $type == "executable" && $file_to_delete != "" } {
+   file delete $file_to_delete
+   if { [istarget *-*-darwin*] && [file exists $file_to_delete.dSYM] } {
+   file delete -force $file_to_delete.dSYM
+   }
+}
 return $comp_output
 }


[gcc r12-10376] libstdc++, Darwin: Handle a linker warning [PR112397].

2024-04-21 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:77f17e405a0669db9a6c8af69bde6eb1170f48bd

commit r12-10376-g77f17e405a0669db9a6c8af69bde6eb1170f48bd
Author: Iain Sandoe 
Date:   Thu Feb 8 17:54:31 2024 +

libstdc++, Darwin: Handle a linker warning [PR112397].

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

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

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

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

PR target/112397

libstdc++-v3/ChangeLog:

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

Signed-off-by: Iain Sandoe 
Co-authored-by: Jonathan Wakely 
(cherry picked from commit 1609fdff16f17ead37666f6d0e801800ee3d04d2)

Diff:
---
 libstdc++-v3/configure | 36 
 libstdc++-v3/configure.ac  |  7 +++
 libstdc++-v3/libsupc++/Makefile.am |  8 
 libstdc++-v3/libsupc++/Makefile.in |  6 ++
 4 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index bc92ce1303c..ccc23f1b352 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -786,6 +786,8 @@ GLIBCXX_HOSTED_TRUE
 glibcxx_compiler_shared_flag
 glibcxx_compiler_pic_flag
 glibcxx_lt_pic_flag
+OS_IS_DARWIN_FALSE
+OS_IS_DARWIN_TRUE
 enable_static
 enable_shared
 lt_host_flags
@@ -12191,7 +12193,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12194 "configure"
+#line 12196 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12297,7 +12299,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12300 "configure"
+#line 12302 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15579,6 +15581,20 @@ esac
 
 
 
+os_is_darwin=no
+case ${host_os} in
+  darwin*) os_is_darwin=yes ;;
+  *) ;;
+esac
+ if test x${os_is_darwin} = xyes; then
+  OS_IS_DARWIN_TRUE=
+  OS_IS_DARWIN_FALSE='#'
+else
+  OS_IS_DARWIN_TRUE='#'
+  OS_IS_DARWIN_FALSE=
+fi
+
+
 if test "$enable_vtable_verify" = yes; then
   predep_objects_CXX="${predep_objects_CXX} 
${glibcxx_builddir}/../libgcc/vtv_start.o"
   postdep_objects_CXX="${postdep_objects_CXX} 
${glibcxx_builddir}/../libgcc/vtv_end.o"
@@ -15981,7 +15997,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
   # Fake what AC_TRY_COMPILE does.
 
 cat > conftest.$ac_ext << EOF
-#line 15984 "configure"
+#line 16000 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -16016,7 +16032,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16019 "configure"
+#line 16035 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -16051,7 +16067,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16054 "configure"
+#line 16070 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -16087,7 +16103,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16090 "configure"
+#line 16106 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -16243,7 +16259,7 @@ $as_echo "mutex" >&6; }
   # unnecessary for this test.
 
 cat > conftest.$ac_ext << EOF
-#line 16246 "configure"
+#line 16262 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -16285,7 +16301,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
   cat > conftest.$ac_ext << EOF
-#line 16288 "configure"
+#line 16304 "configure"
 template
   struct same
   { typedef T2 type; };
@@ -79293,6 +79309,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z 
"${MAINTAINER_MODE_FALSE}"; then
   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${OS_IS_DARWIN_TRUE}" && test -z "${OS_IS_DARWIN_FALSE}"; then

[gcc r11-11332] testsuite, Darwin: Remove an unnecessary flags addition.

2024-04-22 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:b4ad231ce26a66a9e11f246df2c602626d99fc6a

commit r11-11332-gb4ad231ce26a66a9e11f246df2c602626d99fc6a
Author: Iain Sandoe 
Date:   Sun Jun 19 20:47:43 2022 +0100

testsuite, Darwin: Remove an unnecessary flags addition.

The addition of the multiply_defined suppress flag has been handled for some
considerable time now in the Darwin specs; remove it from the testsuite 
libs.
Avoid duplicates in the specs.

Signed-off-by: Iain Sandoe 

gcc/ChangeLog:

* config/darwin.h: Avoid duplicate multiply_defined specs on
earlier Darwin versions with shared libgcc.

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp: Remove additional flag handled
by Darwin specs.

gcc/testsuite/ChangeLog:

* lib/g++.exp: Remove additional flag handled by Darwin specs.
* lib/obj-c++.exp: Likewise.

(cherry picked from commit 3c776fdf1a825818ad7248d442e846f532574ff7)

Diff:
---
 gcc/config/darwin.h  | 5 ++---
 gcc/testsuite/lib/g++.exp| 4 
 gcc/testsuite/lib/obj-c++.exp| 4 
 libstdc++-v3/testsuite/lib/libstdc++.exp | 3 ---
 4 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 504dfcec4da..b2bd33f8d4a 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -215,8 +215,7 @@ extern GTY(()) int darwin_ms_struct;
   "%{image_base*:-Xlinker -image_base -Xlinker %*} %= 10.7 mmacosx-version-min= -no_pie) }"
 
 #define DARWIN_CC1_SPEC
\
-  "%

[gcc r11-11356] libstdc++, Darwin: Limit recursive mutex init to OS versions needing it.

2024-04-24 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:17212f5912d8f57b3757633444ae64c9831aa8f7

commit r11-11356-g17212f5912d8f57b3757633444ae64c9831aa8f7
Author: Iain Sandoe 
Date:   Sat Dec 3 17:09:35 2022 +

libstdc++, Darwin: Limit recursive mutex init to OS versions needing it.

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

Signed-off-by: Iain Sandoe 

libstdc++-v3/ChangeLog:

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

(cherry picked from commit a044c9d25972b22c6b4c8ec27f2de5fd622573cc)

Diff:
---
 libstdc++-v3/config/os/bsd/darwin/os_defines.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/os/bsd/darwin/os_defines.h 
b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
index 0b3bb7950b1..394d7209711 100644
--- a/libstdc++-v3/config/os/bsd/darwin/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
@@ -39,8 +39,12 @@
 // -flat_namespace to work around the way that it doesn't.
 #define _GLIBCXX_WEAK_DEFINITION __attribute__ ((weak))
 
-// Static initializer macro is buggy in darwin, see libstdc++/51906
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
+ && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1080)
+// Static initializer macro is absent for Darwin < 11 and buggy in Darwin 11,
+// see libstdc++/51906.  Fixed in Darwin 12 (OS X 10.8).
 #define _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
+#endif
 
 // Configure checks for nanosleep fail on Darwin, but nanosleep and
 // sched_yield are always available, so use them.


[gcc r11-11400] libstdc++, Darwin: Do not use dev/null as the file for executables.

2024-04-29 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:3b01cc3b088b4781743fcef64f4ab27c73d54009

commit r11-11400-g3b01cc3b088b4781743fcef64f4ab27c73d54009
Author: Iain Sandoe 
Date:   Tue Mar 19 10:40:50 2024 +

libstdc++, Darwin: Do not use dev/null as the file for executables.

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

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

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

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

libstdc++-v3/ChangeLog:

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

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

Diff:
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 527d6ba0711..dde67de3eb7 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -507,11 +507,41 @@ proc v3_target_compile { source dest type options } {
}
 }
 
+# For Windows and Darwin we might want to create a temporary file.
+# Note that it needs deleting.
+set file_to_delete ""
+# Small adjustment for Windows hosts.
+if { $dest == "/dev/null"
+ && [info exists ::env(OS)] && [string match "Windows*" $::env(OS)] } {
+   if { $type == "executable" } {
+   set dest "x.exe"
+   set file_to_delete ${dest}
+   } else {
+   # Windows uses special file named "nul" as a substitute for
+   # /dev/null
+   set dest "nul"
+   }
+}
+
+# Using /dev/null as the executable name does not work on Darwin when
+# debug is enabled, since the debug linker does not accept /dev/null as
+# a valid executable name.
+if { $dest == "/dev/null" && [istarget *-*-darwin*]
+ && $type == "executable" } {
+   set dest dev-null-[pid].exe
+   set file_to_delete ${dest}
+}
+
 lappend options "compiler=$cxx_final"
 lappend options "timeout=[timeout_value]"
 
 set comp_output [target_compile $source $dest $type $options]
-
+if { $type == "executable" && $file_to_delete != "" } {
+   file delete $file_to_delete
+   if { [istarget *-*-darwin*] && [file exists $file_to_delete.dSYM] } {
+   file delete -force $file_to_delete.dSYM
+   }
+}
 return $comp_output
 }


[gcc r11-11403] libstdc++, Darwin: Handle a linker warning [PR112397].

2024-04-29 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:8c19cb9c6186b65f1858c91d423238a00ffe0c01

commit r11-11403-g8c19cb9c6186b65f1858c91d423238a00ffe0c01
Author: Iain Sandoe 
Date:   Thu Feb 8 17:54:31 2024 +

libstdc++, Darwin: Handle a linker warning [PR112397].

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

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

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

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

PR target/112397

libstdc++-v3/ChangeLog:

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

Signed-off-by: Iain Sandoe 
Co-authored-by: Jonathan Wakely 
(cherry picked from commit 1609fdff16f17ead37666f6d0e801800ee3d04d2)

Diff:
---
 libstdc++-v3/configure | 38 +-
 libstdc++-v3/configure.ac  |  7 +++
 libstdc++-v3/libsupc++/Makefile.am |  8 
 libstdc++-v3/libsupc++/Makefile.in |  6 ++
 4 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 8633b8a6dab..316c19a2c95 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -776,6 +776,8 @@ GLIBCXX_HOSTED_TRUE
 glibcxx_compiler_shared_flag
 glibcxx_compiler_pic_flag
 glibcxx_lt_pic_flag
+OS_IS_DARWIN_FALSE
+OS_IS_DARWIN_TRUE
 enable_static
 enable_shared
 lt_host_flags
@@ -12176,7 +12178,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12179 "configure"
+#line 12181 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12282,7 +12284,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12285 "configure"
+#line 12287 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15564,6 +15566,20 @@ esac
 
 
 
+os_is_darwin=no
+case ${host_os} in
+  darwin*) os_is_darwin=yes ;;
+  *) ;;
+esac
+ if test x${os_is_darwin} = xyes; then
+  OS_IS_DARWIN_TRUE=
+  OS_IS_DARWIN_FALSE='#'
+else
+  OS_IS_DARWIN_TRUE='#'
+  OS_IS_DARWIN_FALSE=
+fi
+
+
 if test "$enable_vtable_verify" = yes; then
   predep_objects_CXX="${predep_objects_CXX} 
${glibcxx_builddir}/../libgcc/vtv_start.o"
   postdep_objects_CXX="${postdep_objects_CXX} 
${glibcxx_builddir}/../libgcc/vtv_end.o"
@@ -15964,7 +15980,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
   # Fake what AC_TRY_COMPILE does.
 
 cat > conftest.$ac_ext << EOF
-#line 15967 "configure"
+#line 15983 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -15999,7 +16015,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16002 "configure"
+#line 16018 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -16034,7 +16050,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16037 "configure"
+#line 16053 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -16070,7 +16086,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16073 "configure"
+#line 16089 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -16223,7 +16239,7 @@ $as_echo "mutex" >&6; }
   # unnecessary for this test.
 
 cat > conftest.$ac_ext << EOF
-#line 16226 "configure"
+#line 16242 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -16265,7 +16281,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
 cat > conftest.$ac_ext << EOF
-#line 16268 "configure"
+#line 16284 "configure"
 template
   struct same
   { typedef T2 type; };
@@ -16299,7 +16315,7 @@ $as_echo "$enable_int128" >&6; }
 rm -f conftest*
 
 cat > conftest.$ac_ext << EOF
-#line 16302 "configure"
+#line 16318 "configure"
 template
   struct same
   { typedef T2 type; };
@@ -78444,6 +78460,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z 
"${MAINTAINER_MODE_FALSE}"; then
   as

[gcc r15-3894] libstdc++: Suppress an attribute suggestion warning [PR116853].

2024-09-26 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:d797202caa34f008399dc65e10cc723f52fcbcc5

commit r15-3894-gd797202caa34f008399dc65e10cc723f52fcbcc5
Author: Iain Sandoe 
Date:   Thu Sep 26 11:07:41 2024 +0100

libstdc++: Suppress an attribute suggestion warning [PR116853].

This warning is triggering during the build and breaking bootstrap on
at least two targets.  The warning appears valid, but the final fix for
it is not yet clear.

In the meantime, to restore bootstrap, the following patch ignores the
warning in the relevant code section.

PR libstdc++/116853

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: Ignore suggest-attribute=format
warning when using posix vsnprintf in to_string() implementations.

Signed-off-by: Iain Sandoe 

Diff:
---
 libstdc++-v3/include/bits/basic_string.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libstdc++-v3/include/bits/basic_string.h 
b/libstdc++-v3/include/bits/basic_string.h
index 976577f8f22d..e9b17ea48b5a 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -4399,6 +4399,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 return __str;
   }
 #elif _GLIBCXX_USE_C99_STDIO
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
   // NB: (v)snprintf vs sprintf.
 
   _GLIBCXX_NODISCARD
@@ -4430,6 +4432,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 return __gnu_cxx::__to_xstring(&std::vsnprintf, __n,
   "%Lf", __val);
   }
+#pragma GCC diagnostic pop
 #endif // _GLIBCXX_USE_C99_STDIO
 
 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR


[gcc r15-9150] libstdc++, testsuite, Darwin: Prune a new linker warning present form XCode 16.

2025-04-02 Thread Iain D Sandoe via Libstdc++-cvs
https://gcc.gnu.org/g:efe72d9f050a72ffb698adef8434afae1849dcff

commit r15-9150-gefe72d9f050a72ffb698adef8434afae1849dcff
Author: Iain Sandoe 
Date:   Wed Apr 2 14:38:38 2025 +0100

libstdc++, testsuite, Darwin: Prune a new linker warning present form XCode 
16.

Darwin's linker now warns when duplicate rpaths are presented - which
happens when we emit duplicate '-B' paths.  In principle, we should avoid
this in the test-suite, however at present we tend to have duplicates
because different parts of the machinery add them.  At some point, it might
be nice to have an "add_option_if_missing" and apply that across the whole
of the test infra. However this is not something for late in stage 4.  So
the solution here is to prune the warning - the effect of the duplicate in
the libstdc++ testsuite is not important; it will make the exes very 
slightly
larger but it won't alter the paths that are presented for loading the
runtimes.

libstdc++-v3/ChangeLog:

* testsuite/lib/prune.exp: Prune ld warning about duplicatei
rpaths.

Signed-off-by: Iain Sandoe 

Diff:
---
 libstdc++-v3/testsuite/lib/prune.exp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libstdc++-v3/testsuite/lib/prune.exp 
b/libstdc++-v3/testsuite/lib/prune.exp
index 416e851614ba..a9a29937e43a 100644
--- a/libstdc++-v3/testsuite/lib/prune.exp
+++ b/libstdc++-v3/testsuite/lib/prune.exp
@@ -77,6 +77,9 @@ proc libstdc++-dg-prune { system text } {
 # Ignore harmless warnings from Xcode 4+.
 regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind 
for\[^\n\]*" $text "" text
 
+# Ignore duplicate path warnings from Xcode 16+.
+regsub -all "(^|\n)\[^\n\]*ld: warning: duplicate -rpath\[^\n\]*" $text "" 
text
+
 # Ignore dsymutil warning (tool bug is actually in the linker)
 regsub -all "(^|\n)\[^\n\]*could not find object file symbol for 
symbol\[^\n\]*" $text "" text