diff options
author | Richard Earnshaw <rearnsha@arm.com> | 2025-01-27 13:52:05 +0000 |
---|---|---|
committer | Richard Earnshaw <rearnsha@arm.com> | 2025-01-28 13:54:02 +0000 |
commit | a235c45354de9a89ba2f6f12d3aac42efc18f311 (patch) | |
tree | 3dc15af6dd218fb283c3970d2f22c7b55eb16708 | |
parent | 01339d29b7663d85eea6145eac2b1ad1da428c11 (diff) | |
download | gcc-a235c45354de9a89ba2f6f12d3aac42efc18f311.zip gcc-a235c45354de9a89ba2f6f12d3aac42efc18f311.tar.gz gcc-a235c45354de9a89ba2f6f12d3aac42efc18f311.tar.bz2 |
arm: libbacktrace: Check if the compiler supports __sync atomics
Older versions of the Arm architecture lack support for __sync
operations directly in hardware and require calls into appropriate
operating-system hooks. But such hooks obviously don't exist in a
freestanding environment.
Consquently, it is incorrect to assume during configure that such
functions will exist and we need a configure-time check to determine
whether or not these routines will work.
libbacktrace:
* configure.ac: Always check if the compiler supports __sync
operations.
* configure: Regenerated.
-rwxr-xr-x | libbacktrace/configure | 23 | ||||
-rw-r--r-- | libbacktrace/configure.ac | 10 |
2 files changed, 33 insertions, 0 deletions
diff --git a/libbacktrace/configure b/libbacktrace/configure index db491a7..0ecdd3e 100755 --- a/libbacktrace/configure +++ b/libbacktrace/configure @@ -12760,6 +12760,29 @@ else if test -n "${with_target_subdir}"; then case "${host}" in hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;; + arm*-*-eabi*) + # Older versions of the Arm architecture lack the necessary instructions + # for these constructs, so check whether we can use them. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +int +main () +{ +__sync_bool_compare_and_swap (&i, i, i); + __sync_lock_test_and_set (&i, 1); + __sync_lock_release (&i); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + libbacktrace_cv_sys_sync=yes +else + libbacktrace_cv_sys_sync=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext;; *) libbacktrace_cv_sys_sync=yes ;; esac else diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac index b700bf9..75b3a75 100644 --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -199,6 +199,16 @@ AC_CACHE_CHECK([__sync extensions], [if test -n "${with_target_subdir}"; then case "${host}" in hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;; + arm*-*-eabi*) + # Older versions of the Arm architecture lack the necessary instructions + # for these constructs, so check whether we can use them. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([int i;], + [__sync_bool_compare_and_swap (&i, i, i); + __sync_lock_test_and_set (&i, 1); + __sync_lock_release (&i);])], + [libbacktrace_cv_sys_sync=yes], + [libbacktrace_cv_sys_sync=no]);; *) libbacktrace_cv_sys_sync=yes ;; esac else |