public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libstdc++ patch RFA: Fix dl_iterate_phdr configury for libbacktrace
@ 2023-11-03  3:04 Ian Lance Taylor
  2023-11-03  9:12 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Lance Taylor @ 2023-11-03  3:04 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

The libbacktrace sources, as used by libstdc++-v3, fail to correctly
determine whether the system supports dl_iterate_phdr.  The issue is
that the libbacktrace configure assumes that _GNU_SOURCE is defined
during compilation, but the libstdc++-v3 configure does not do that.
This configury failure is the cause of PR 112263.

This patch fixes the problem.  OK for mainline?

Ian

PR libbacktrace/112263
* acinclude.m4: Set -D_GNU_SOURCE in BACKTRACE_CPPFLAGS and when
grepping link.h for dl_iterate_phdr.
* configure: Regenerate.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1939 bytes --]

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index d8f0ba1c3e2..41446c2c3d6 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -5443,7 +5443,7 @@ AC_DEFUN([GLIBCXX_ENABLE_BACKTRACE], [
 
   # Most of this is adapted from libsanitizer/configure.ac
 
-  BACKTRACE_CPPFLAGS=
+  BACKTRACE_CPPFLAGS="-D_GNU_SOURCE"
 
   # libbacktrace only needs atomics for int, which we've already tested
   if test "$glibcxx_cv_atomic_int" = "yes"; then
@@ -5471,8 +5471,11 @@ AC_DEFUN([GLIBCXX_ENABLE_BACKTRACE], [
     have_dl_iterate_phdr=no
   else
     # When built as a GCC target library, we can't do a link test.
+    ac_save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
     AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
 		    [have_dl_iterate_phdr=no])
+    CPPFLAGS="$ac_save_CPPFLAGS"
   fi
   if test "$have_dl_iterate_phdr" = "yes"; then
     BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_DL_ITERATE_PHDR=1"
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 9f12c5baa3f..693564d3c7e 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -73299,7 +73299,7 @@ fi
 
   # Most of this is adapted from libsanitizer/configure.ac
 
-  BACKTRACE_CPPFLAGS=
+  BACKTRACE_CPPFLAGS="-D_GNU_SOURCE"
 
   # libbacktrace only needs atomics for int, which we've already tested
   if test "$glibcxx_cv_atomic_int" = "yes"; then
@@ -73382,6 +73382,8 @@ done
     have_dl_iterate_phdr=no
   else
     # When built as a GCC target library, we can't do a link test.
+    ac_save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <link.h>
@@ -73395,6 +73397,7 @@ else
 fi
 rm -f conftest*
 
+    CPPFLAGS="$ac_save_CPPFLAGS"
   fi
   if test "$have_dl_iterate_phdr" = "yes"; then
     BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_DL_ITERATE_PHDR=1"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: libstdc++ patch RFA: Fix dl_iterate_phdr configury for libbacktrace
  2023-11-03  3:04 libstdc++ patch RFA: Fix dl_iterate_phdr configury for libbacktrace Ian Lance Taylor
@ 2023-11-03  9:12 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2023-11-03  9:12 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches

On Fri, 3 Nov 2023 at 03:04, Ian Lance Taylor <iant@golang.org> wrote:
>
> The libbacktrace sources, as used by libstdc++-v3, fail to correctly
> determine whether the system supports dl_iterate_phdr.  The issue is
> that the libbacktrace configure assumes that _GNU_SOURCE is defined
> during compilation, but the libstdc++-v3 configure does not do that.
> This configury failure is the cause of PR 112263.
>
> This patch fixes the problem.  OK for mainline?

Thanks for figuring this one out, I forget toabout _GNU_SOURCE often,
because g++ defines it automatically.

OK for mainline and gcc-13 and gcc-12, thanks!

>
> Ian
>
> PR libbacktrace/112263
> * acinclude.m4: Set -D_GNU_SOURCE in BACKTRACE_CPPFLAGS and when
> grepping link.h for dl_iterate_phdr.
> * configure: Regenerate.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-03  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-03  3:04 libstdc++ patch RFA: Fix dl_iterate_phdr configury for libbacktrace Ian Lance Taylor
2023-11-03  9:12 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).