libstdc++ patch RFA: Fix dl_iterate_phdr configury for libbacktrace
Checks
Commit Message
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.
Comments
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.
@@ -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"
@@ -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"