pmaports/cross/gcc-armv7/0028-configure-fix-detection-of-atomic-builtins-in-libato.patch
2023-06-09 11:45:27 -07:00

57 lines
2.1 KiB
Diff

From cd46156af13743fe93c48d00b0661add2c319226 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Sun, 29 Aug 2021 12:23:34 +0200
Subject: [PATCH 28/33] configure: fix detection of atomic builtins in
libatomic configure script
Alpine's --enable-autolink-libatomic (which is enabled for riscv64 by
default) causes the libatomic configure script to incorrectly detect
which builtins are available on riscv64. This then causes incorrect code
generation for libatomic since it assumes compiler builtins to be
available which are not actually available on riscv64.
This commit fixes this issue by disabling linking of libatomic configure
test code entirely, thereby preventing linking against libatomic.
See:
* https://gitlab.alpinelinux.org/alpine/aports/-/issues/12948
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c6
---
libatomic/configure.tgt | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
index a92ae9e8309..90b579ca4d8 100644
--- a/libatomic/configure.tgt
+++ b/libatomic/configure.tgt
@@ -30,6 +30,26 @@
# on ${target_cpu}. For example to allow proper use of multilibs.
configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}"
+# The libatomic configure script performs several checks to determine
+# whether builtins for atomic operations are available. When compiling
+# with --enable-autolink-libatomic the test code compiled by the
+# configure script is also linked against libatomic. This causes it
+# to think that builtins are available, even if there are not, since
+# the tested symbols are provided by libatomic.
+#
+# This is a hack to ensure that we don't link against libatomic by not
+# linking any configure test code at all when --enable-autolink-libatomic
+# is given.
+#
+# See:
+#
+# * https://gitlab.alpinelinux.org/alpine/aports/-/issues/12817
+# * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c4
+#
+if test x$enable_autolink_libatomic = xyes; then
+ gcc_no_link=yes
+fi
+
case "${target_cpu}" in
alpha*)
# fenv.c needs this option to generate inexact exceptions.
--
2.41.0