2021-11-29 07:07:20 +00:00
|
|
|
From 7e123432a35fcaa25de85b4940daabcd70c1a6bd Mon Sep 17 00:00:00 2001
|
2021-03-14 10:32:02 +00:00
|
|
|
From: Drew DeVault <sir@cmpwn.com>
|
|
|
|
Date: Wed, 9 Dec 2020 16:07:26 +0000
|
2021-04-25 11:08:48 +00:00
|
|
|
Subject: [PATCH] configure: Add --enable-autolink-libatomic, use in
|
2021-03-14 10:32:02 +00:00
|
|
|
LINK_GCC_C_SEQUENCE_SPEC [PR81358]
|
|
|
|
|
|
|
|
This fixes issues with RISC-V.
|
|
|
|
---
|
|
|
|
Makefile.in | 1 +
|
|
|
|
gcc/config.in | 6 ++++++
|
|
|
|
gcc/config/gnu-user.h | 12 +++++++++++-
|
2021-11-25 09:09:10 +00:00
|
|
|
gcc/configure | 34 +++++++++++++++++++++++++++++++---
|
|
|
|
gcc/configure.ac | 22 +++++++++++++++++++++-
|
2021-03-14 10:32:02 +00:00
|
|
|
gcc/doc/install.texi | 8 ++++++++
|
|
|
|
gcc/doc/tm.texi | 8 +++++++-
|
|
|
|
gcc/doc/tm.texi.in | 8 +++++++-
|
|
|
|
gcc/gcc.c | 12 +++++++++++-
|
2021-11-25 09:09:10 +00:00
|
|
|
9 files changed, 103 insertions(+), 8 deletions(-)
|
2021-03-14 10:32:02 +00:00
|
|
|
|
|
|
|
diff --git a/Makefile.in b/Makefile.in
|
2021-11-25 09:09:10 +00:00
|
|
|
index f97db1ef569..7e577ed3dbb 100644
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/Makefile.in
|
|
|
|
+++ b/Makefile.in
|
|
|
|
@@ -222,6 +222,7 @@ HOST_EXPORTS = \
|
|
|
|
RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
|
|
|
|
READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \
|
|
|
|
TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
|
|
|
|
+ TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; \
|
|
|
|
HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \
|
|
|
|
GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
|
|
|
|
GMPINC="$(HOST_GMPINC)"; export GMPINC; \
|
|
|
|
diff --git a/gcc/config.in b/gcc/config.in
|
2021-11-25 09:09:10 +00:00
|
|
|
index 059c818c895..2a560417440 100644
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/gcc/config.in
|
|
|
|
+++ b/gcc/config.in
|
|
|
|
@@ -106,6 +106,12 @@
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
+/* Define if libatomic should always be linked. */
|
|
|
|
+#ifndef USED_FOR_TARGET
|
|
|
|
+#undef ENABLE_AUTOLINK_LIBATOMIC
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+
|
|
|
|
/* Define to 1 to specify that we are using the BID decimal floating point
|
|
|
|
format instead of DPD */
|
|
|
|
#ifndef USED_FOR_TARGET
|
|
|
|
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
|
2021-11-25 09:09:10 +00:00
|
|
|
index 902378e1bad..daf7727a01a 100644
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/gcc/config/gnu-user.h
|
|
|
|
+++ b/gcc/config/gnu-user.h
|
|
|
|
@@ -109,8 +109,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC)
|
|
|
|
+# ifdef LD_AS_NEEDED_OPTION
|
|
|
|
+# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION
|
|
|
|
+# else
|
|
|
|
+# define LINK_LIBATOMIC_SPEC "-latomic"
|
|
|
|
+# endif
|
|
|
|
+#elif !defined(LINK_LIBATOMIC_SPEC)
|
|
|
|
+# define LINK_LIBATOMIC_SPEC ""
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \
|
|
|
|
- "%{static|static-pie:--start-group} %G %{!nolibc:%L} \
|
|
|
|
+ "%{static|static-pie:--start-group} %G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L} \
|
|
|
|
%{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"
|
|
|
|
|
|
|
|
#undef LINK_GCC_C_SEQUENCE_SPEC
|
|
|
|
diff --git a/gcc/configure b/gcc/configure
|
2021-11-25 09:09:10 +00:00
|
|
|
index 592e81e40f6..8672298f23f 100755
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/gcc/configure
|
|
|
|
+++ b/gcc/configure
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -978,6 +978,7 @@ with_changes_root_url
|
2021-03-14 10:32:02 +00:00
|
|
|
enable_languages
|
|
|
|
with_multilib_list
|
2021-11-25 09:09:10 +00:00
|
|
|
with_multilib_generator
|
2021-03-14 10:32:02 +00:00
|
|
|
+enable_autolink_libatomic
|
|
|
|
with_zstd
|
|
|
|
with_zstd_include
|
|
|
|
with_zstd_lib
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -1707,6 +1708,9 @@ Optional Features:
|
2021-03-14 10:32:02 +00:00
|
|
|
--disable-shared don't provide a shared libgcc
|
|
|
|
--disable-gcov don't provide libgcov and related host tools
|
|
|
|
--enable-languages=LIST specify which front-ends to build
|
|
|
|
+ --enable-autolink-libatomic
|
|
|
|
+ enable automatic linking of libatomic (ignored if
|
|
|
|
+ not built)
|
|
|
|
--disable-rpath do not hardcode runtime library paths
|
|
|
|
--enable-sjlj-exceptions
|
|
|
|
arrange to use setjmp/longjmp exception handling
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -8070,7 +8074,6 @@ else
|
2021-03-14 10:32:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-11-25 09:09:10 +00:00
|
|
|
-
|
|
|
|
# Check whether --with-multilib-generator was given.
|
|
|
|
if test "${with_multilib_generator+set}" = set; then :
|
|
|
|
withval=$with_multilib_generator; :
|
|
|
|
@@ -8078,6 +8081,32 @@ else
|
|
|
|
with_multilib_generator=default
|
|
|
|
fi
|
|
|
|
|
2021-03-14 10:32:02 +00:00
|
|
|
+# If libatomic is available, whether it should be linked automatically
|
|
|
|
+# Check whether --enable-autolink-libatomic was given.
|
|
|
|
+if test "${enable_autolink_libatomic+set}" = set; then :
|
|
|
|
+ enableval=$enable_autolink_libatomic;
|
|
|
|
+ case $enable_autolink_libatomic in
|
|
|
|
+ yes | no) ;;
|
|
|
|
+ *) as_fn_error $? "'$enable_autolink_libatomic' is an invalid value for
|
|
|
|
+--enable-autolink-libatomic. Valid choices are 'yes' and 'no'." "$LINENO" 5 ;;
|
|
|
|
+ esac
|
|
|
|
+
|
|
|
|
+else
|
|
|
|
+ enable_autolink_libatomic=''
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+if test x$enable_autolink_libatomic = xyes; then
|
|
|
|
+ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then
|
|
|
|
+
|
|
|
|
+$as_echo "#define ENABLE_AUTOLINK_LIBATOMIC 1" >>confdefs.h
|
|
|
|
+
|
|
|
|
+ else
|
|
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&5
|
|
|
|
+$as_echo "$as_me: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&2;}
|
|
|
|
+ fi
|
|
|
|
+fi
|
|
|
|
+
|
2021-11-25 09:09:10 +00:00
|
|
|
|
2021-03-14 10:32:02 +00:00
|
|
|
# -------------------------
|
|
|
|
# Checks for other programs
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -19501,7 +19530,7 @@ else
|
2021-03-14 10:32:02 +00:00
|
|
|
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
|
|
|
lt_status=$lt_dlunknown
|
|
|
|
cat > conftest.$ac_ext <<_LT_EOF
|
2021-11-25 09:09:10 +00:00
|
|
|
-#line 19501 "configure"
|
2021-03-14 10:32:02 +00:00
|
|
|
+#line 19158 "configure"
|
|
|
|
#include "confdefs.h"
|
|
|
|
|
|
|
|
#if HAVE_DLFCN_H
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -34068,4 +34097,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
|
2021-03-14 10:32:02 +00:00
|
|
|
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
|
|
|
|
fi
|
|
|
|
|
|
|
|
-
|
|
|
|
diff --git a/gcc/configure.ac b/gcc/configure.ac
|
2021-11-25 09:09:10 +00:00
|
|
|
index 1577529ffb7..e96691f69ba 100644
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/gcc/configure.ac
|
|
|
|
+++ b/gcc/configure.ac
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -1149,6 +1149,27 @@ AC_ARG_WITH(multilib-generator,
|
2021-03-14 10:32:02 +00:00
|
|
|
:,
|
2021-11-25 09:09:10 +00:00
|
|
|
with_multilib_generator=default)
|
2021-03-14 10:32:02 +00:00
|
|
|
|
|
|
|
+# If libatomic is available, whether it should be linked automatically
|
|
|
|
+AC_ARG_ENABLE(autolink-libatomic,
|
|
|
|
+[AS_HELP_STRING([--enable-autolink-libatomic],
|
|
|
|
+ [enable automatic linking of libatomic (ignored if not built)])],
|
|
|
|
+[
|
|
|
|
+ case $enable_autolink_libatomic in
|
|
|
|
+ yes | no) ;;
|
|
|
|
+ *) AC_MSG_ERROR(['$enable_autolink_libatomic' is an invalid value for
|
|
|
|
+--enable-autolink-libatomic. Valid choices are 'yes' and 'no'.]) ;;
|
|
|
|
+ esac
|
|
|
|
+], [enable_autolink_libatomic=''])
|
|
|
|
+
|
|
|
|
+if test x$enable_autolink_libatomic = xyes; then
|
|
|
|
+ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then
|
|
|
|
+ AC_DEFINE(ENABLE_AUTOLINK_LIBATOMIC, 1,
|
|
|
|
+ [Define if libatomic should always be linked.])
|
|
|
|
+ else
|
|
|
|
+ AC_MSG_WARN([libatomic is not build for this target, --enable-autolink-libatomic ignored])
|
|
|
|
+ fi
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
# -------------------------
|
|
|
|
# Checks for other programs
|
|
|
|
# -------------------------
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -7729,4 +7750,3 @@ done
|
2021-03-14 10:32:02 +00:00
|
|
|
],
|
|
|
|
[subdirs='$subdirs'])
|
|
|
|
AC_OUTPUT
|
|
|
|
-
|
|
|
|
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
|
2021-11-25 09:09:10 +00:00
|
|
|
index 4c38244ae58..4a544e6a4ee 100644
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/gcc/doc/install.texi
|
|
|
|
+++ b/gcc/doc/install.texi
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -2213,6 +2213,14 @@ files, but these changed header paths may conflict with some compilation
|
2021-03-14 10:32:02 +00:00
|
|
|
environments. Enabled by default, and may be disabled using
|
|
|
|
@option{--disable-canonical-system-headers}.
|
|
|
|
|
|
|
|
+@item --enable-autolink-libatomic
|
|
|
|
+@itemx --disable-autolink-libatomic
|
|
|
|
+Tell GCC that it should automatically link libatomic; if supported by
|
|
|
|
+the linker, the file is only linked as needed. This flag is ignored
|
|
|
|
+when libatomic is not built. Note that this conigure flag is in particular
|
|
|
|
+useful when building an offloading-target compiler; as for those, a
|
|
|
|
+user had to specify @code{-foffload=target=-latomic} otherwise.
|
|
|
|
+
|
|
|
|
@item --with-glibc-version=@var{major}.@var{minor}
|
|
|
|
Tell GCC that when the GNU C Library (glibc) is used on the target it
|
|
|
|
will be version @var{major}.@var{minor} or later. Normally this can
|
|
|
|
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
|
2021-11-25 09:09:10 +00:00
|
|
|
index b370bc76b25..acc78273983 100644
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/gcc/doc/tm.texi
|
|
|
|
+++ b/gcc/doc/tm.texi
|
|
|
|
@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search.
|
|
|
|
|
|
|
|
@defmac LINK_GCC_C_SEQUENCE_SPEC
|
|
|
|
The sequence in which libgcc and libc are specified to the linker.
|
|
|
|
-By default this is @code{%G %L %G}.
|
|
|
|
+By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}.
|
|
|
|
+@end defmac
|
|
|
|
+
|
|
|
|
+@defmac LINK_LIBATOMIC_SPEC
|
|
|
|
+This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link
|
|
|
|
+libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC}
|
|
|
|
+is set.
|
|
|
|
@end defmac
|
|
|
|
|
|
|
|
@defmac POST_LINK_SPEC
|
|
|
|
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
|
2021-11-25 09:09:10 +00:00
|
|
|
index 2974dae2701..80e003a38ce 100644
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/gcc/doc/tm.texi.in
|
|
|
|
+++ b/gcc/doc/tm.texi.in
|
|
|
|
@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search.
|
|
|
|
|
|
|
|
@defmac LINK_GCC_C_SEQUENCE_SPEC
|
|
|
|
The sequence in which libgcc and libc are specified to the linker.
|
|
|
|
-By default this is @code{%G %L %G}.
|
|
|
|
+By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}.
|
|
|
|
+@end defmac
|
|
|
|
+
|
|
|
|
+@defmac LINK_LIBATOMIC_SPEC
|
|
|
|
+This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link
|
|
|
|
+libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC}
|
|
|
|
+is set.
|
|
|
|
@end defmac
|
|
|
|
|
|
|
|
@defmac POST_LINK_SPEC
|
|
|
|
diff --git a/gcc/gcc.c b/gcc/gcc.c
|
2021-11-25 09:09:10 +00:00
|
|
|
index 5093e8bbfd2..1871b5ab6eb 100644
|
2021-03-14 10:32:02 +00:00
|
|
|
--- a/gcc/gcc.c
|
|
|
|
+++ b/gcc/gcc.c
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -980,13 +980,23 @@ proper position among the other output files. */
|
|
|
|
# define ASM_DEBUG_OPTION_SPEC ""
|
2021-03-14 10:32:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
+#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC)
|
|
|
|
+# ifdef LD_AS_NEEDED_OPTION
|
|
|
|
+# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION
|
|
|
|
+# else
|
|
|
|
+# define LINK_LIBATOMIC_SPEC "-latomic"
|
|
|
|
+# endif
|
|
|
|
+#elif !defined(LINK_LIBATOMIC_SPEC)
|
|
|
|
+# define LINK_LIBATOMIC_SPEC ""
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
/* Here is the spec for running the linker, after compiling all files. */
|
|
|
|
|
|
|
|
/* This is overridable by the target in case they need to specify the
|
|
|
|
-lgcc and -lc order specially, yet not require them to override all
|
|
|
|
of LINK_COMMAND_SPEC. */
|
|
|
|
#ifndef LINK_GCC_C_SEQUENCE_SPEC
|
|
|
|
-#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
|
|
|
|
+#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L %G}"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ENABLE_DEFAULT_SSP
|
|
|
|
--
|
2021-11-29 07:07:20 +00:00
|
|
|
2.34.0
|
2021-03-14 10:32:02 +00:00
|
|
|
|