On Wed, Jan 28, 2026 at 7:14 PM Jonathan Wakely <[email protected]> wrote:

> The conftest.cc in GLIBCXX_ENABLE_BACKTRACE checks if calls to
> __atomic_load and __atomic_store result in libatomic calls. For arm-eabi
> those expand to normal loads with a call to __sync_synchronize to ensure
> correct ordering. That means the generated assembly does not match the
> grep pattern "__atomic_" and so configure incorrectly assumes we can use
> atomics in libbacktrace.
>
> The fix is to grep for "__atomic_|__sync_" instead of just "__atomic_".
>
> As explained in the bug comments, the similar grep for "__atomic_" in
> the GLIBCXX_ENABLE_ATOMIC_BUILTINS macro doesn't need the same change.
> That conftest.cc program does emit a call to a libatomic function that
> matches the grep pattern "__atomic_" so the test gives the right answer
> for arm-eabi.
>
> libstdc++-v3/ChangeLog:
>
>         PR libstdc++/120567
>         * acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Include "__sync_" in
>         grep command to check for extern calls to libatomic.
>         * configure: Regenerate.
> ---
>
LGTM,

>
> Cross-built for arm-eabi and manually verified the config output is
> correct. Testing now on aarch64-linux and x86_64-linux.
>
> I'll wait for the CI results from linaro before pushing this.
>
>  libstdc++-v3/acinclude.m4 | 2 +-
>  libstdc++-v3/configure    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
> index 38030e432d81..8dc9e17b214c 100644
> --- a/libstdc++-v3/acinclude.m4
> +++ b/libstdc++-v3/acinclude.m4
> @@ -5318,7 +5318,7 @@ EOF
>
>      AC_MSG_CHECKING([for atomic builtins for libbacktrace])
>      if AC_TRY_EVAL(ac_compile); then
> -      if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
> +      if grep -E '__atomic_|__sync_' conftest.s >/dev/null 2>&1 ; then
>         glibcxx_cv_libbacktrace_atomics=no
>        else
>         glibcxx_cv_libbacktrace_atomics=yes
> diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
> index 4f144382e1b1..6713e4504b1c 100755
> --- a/libstdc++-v3/configure
> +++ b/libstdc++-v3/configure
> @@ -54172,7 +54172,7 @@ $as_echo_n "checking for atomic builtins for
> libbacktrace... " >&6; }
>    ac_status=$?
>    $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
>    test $ac_status = 0; }; then
> -      if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
> +      if grep -E '__atomic_|__sync_' conftest.s >/dev/null 2>&1 ; then
>         glibcxx_cv_libbacktrace_atomics=no
>        else
>         glibcxx_cv_libbacktrace_atomics=yes
> --
> 2.52.0
>
>

Reply via email to