https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119645

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Thomas Schwinge <tschwi...@gcc.gnu.org>:

https://gcc.gnu.org/g:059b5509c14904b55c37f659170240ae0d2c1c8e

commit r15-9256-g059b5509c14904b55c37f659170240ae0d2c1c8e
Author: Thomas Schwinge <tschwi...@baylibre.com>
Date:   Sat Apr 5 23:11:23 2025 +0200

    GCN, nvptx libstdc++: Force use of '__atomic' builtins [PR119645]

    For both GCN, nvptx, this gets rid of 'configure'-time:

        configure: WARNING: No native atomic operations are provided for this
platform.
        configure: WARNING: They will be faked using a mutex.
        configure: WARNING: Performance of certain classes will degrade as a
result.

    ..., and changes:

        -checking for lock policy for shared_ptr reference counts... mutex
        +checking for lock policy for shared_ptr reference counts... atomic

    That means, '[...]/[target]/libstdc++-v3/', 'Makefile's change:

        -ATOMICITY_SRCDIR = config/cpu/generic/atomicity_mutex
        +ATOMICITY_SRCDIR = config/cpu/generic/atomicity_builtins

    ..., and '[...]/[target]/libstdc++-v3/config.h' changes:

        /* Defined if shared_ptr reference counting should use atomic
operations. */
        -/* #undef HAVE_ATOMIC_LOCK_POLICY */
        +#define HAVE_ATOMIC_LOCK_POLICY 1

        /* Define if the compiler supports C++11 atomics. */
        -/* #undef _GLIBCXX_ATOMIC_BUILTINS */
        +#define _GLIBCXX_ATOMIC_BUILTINS 1

    ..., and '[...]/[target]/libstdc++-v3/include/[target]/bits/c++config.h'
    changes:

        /* Defined if shared_ptr reference counting should use atomic
operations. */
        -/* #undef _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY */
        +#define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1

        /* Define if the compiler supports C++11 atomics. */
        -/* #undef _GLIBCXX_ATOMIC_BUILTINS */
        +#define _GLIBCXX_ATOMIC_BUILTINS 1

    This means that '[...]/[target]/libstdc++-v3/libsupc++/atomicity.cc',
    '[...]/[target]/libstdc++-v3/libsupc++/atomicity.o' then uses atomic
    instructions for synchronization instead of C++ static local variables,
which
    in turn for their guard variables, via 'libstdc++-v3/libsupc++/guard.cc',
used
    'libgcc/gthr.h' recursive mutexes, which currently are unsupported for GCN.

    For GCN, this turns ~500 libstdc++ execution test FAILs into PASSes, and
also
    progresses:

        PASS: g++.dg/tree-ssa/pr20458.C  -std=gnu++17 (test for excess errors)
        [-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++17 execution
test
        PASS: g++.dg/tree-ssa/pr20458.C  -std=gnu++26 (test for excess errors)
        [-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++26 execution
test
        UNSUPPORTED: g++.dg/tree-ssa/pr20458.C  -std=gnu++98: exception
handling not supported

    (For nvptx, there is no effective change, due to other misconfiguration.)

            PR target/119645
            libstdc++-v3/
            * acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY) [GCN, nvptx]:
            Hard-code results.
            * configure: Regenerate.
            * configure.host [GCN, nvptx] (atomicity_dir): Set to
            'cpu/generic/atomicity_builtins'.

Reply via email to