diff options
author | Prathamesh Kulkarni <prathameshk@nvidia.com> | 2024-12-18 17:03:51 +0530 |
---|---|---|
committer | Prathamesh Kulkarni <prathameshk@nvidia.com> | 2024-12-18 17:03:51 +0530 |
commit | e2f6ed54f75bbf8dd0292af90304890f06a9be17 (patch) | |
tree | 0be43e527612a09ffe964de04ff0a9f17d180a5b /libatomic | |
parent | 12dd892b1a3ad719e76e6ca40f8cbc224610b849 (diff) | |
download | gcc-e2f6ed54f75bbf8dd0292af90304890f06a9be17.zip gcc-e2f6ed54f75bbf8dd0292af90304890f06a9be17.tar.gz gcc-e2f6ed54f75bbf8dd0292af90304890f06a9be17.tar.bz2 |
PR81358: Enable automatic linking of libatomic.
ChangeLog:
PR driver/81358
* Makefile.def: Add dependencies so libatomic is built before target
libraries are configured.
* Makefile.tpl: Export TARGET_CONFIGDIRS.
* configure.ac: Add libatomic to bootstrap_target_libs.
* Makefile.in: Regenerate.
* configure: Regenerate.
gcc/ChangeLog:
PR driver/81358
* common.opt: New option -flink-libatomic.
* gcc.cc (LINK_LIBATOMIC_SPEC): New macro.
* config/gnu-user.h (GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC): Use
LINK_LIBATOMIC_SPEC.
* doc/invoke.texi: Document -flink-libatomic.
* configure.ac: Define TARGET_PROVIDES_LIBATOMIC.
* configure: Regenerate.
* config.in: Regenerate.
libatomic/ChangeLog:
PR driver/81358
* Makefile.am: Pass -fno-link-libatomic.
New rule all.
* configure.ac: Assert that CFLAGS is set and pass -fno-link-libatomic.
* Makefile.in: Regenerate.
* configure: Regenerate.
Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
Co-authored-by: Matthew Malcolmson <mmalcolmson@nvidia.com>
Diffstat (limited to 'libatomic')
-rw-r--r-- | libatomic/Makefile.am | 7 | ||||
-rw-r--r-- | libatomic/Makefile.in | 6 | ||||
-rwxr-xr-x | libatomic/configure | 29 | ||||
-rw-r--r-- | libatomic/configure.ac | 25 |
4 files changed, 53 insertions, 14 deletions
diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am index efadd9d..723e0be 100644 --- a/libatomic/Makefile.am +++ b/libatomic/Makefile.am @@ -69,7 +69,7 @@ libatomic_darwin_rpath += -Wl,-rpath,@loader_path endif libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \ - $(lt_host_flags) $(libatomic_darwin_rpath) + -Wc,-fno-link-libatomic $(lt_host_flags) $(libatomic_darwin_rpath) libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c \ fenv.c fence.c flag.c @@ -162,6 +162,11 @@ libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD) # when it is reloaded during the build of all-multi. all-multi: $(libatomic_la_LIBADD) +gcc_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc +all: all-multi libatomic.la + $(INSTALL_DATA) .libs/libatomic.a $(gcc_objdir)/ + chmod 644 $(gcc_objdir)/libatomic.a + # target overrides -include $(tmake_file) diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in index 9798e7c..f19e0a3 100644 --- a/libatomic/Makefile.in +++ b/libatomic/Makefile.in @@ -421,7 +421,7 @@ libatomic_version_info = -version-info $(libtool_VERSION) @ENABLE_DARWIN_AT_RPATH_TRUE@ -Wc,-nodefaultrpaths \ @ENABLE_DARWIN_AT_RPATH_TRUE@ -Wl,-rpath,@loader_path libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \ - $(lt_host_flags) $(libatomic_darwin_rpath) + -Wc,-fno-link-libatomic $(lt_host_flags) $(libatomic_darwin_rpath) libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c \ init.c fenv.c fence.c flag.c $(am__append_5) @@ -458,6 +458,7 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \ @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16 -mcx16 libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES) libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD) +gcc_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc MULTISRCTOP = MULTIBUILDTOP = MULTIDIRS = @@ -901,6 +902,9 @@ vpath % $(strip $(search_path)) # makefile fragments to avoid broken *.Ppo getting included into the Makefile # when it is reloaded during the build of all-multi. all-multi: $(libatomic_la_LIBADD) +all: all-multi libatomic.la + $(INSTALL_DATA) .libs/libatomic.a $(gcc_objdir)/ + chmod 644 $(gcc_objdir)/libatomic.a # target overrides -include $(tmake_file) diff --git a/libatomic/configure b/libatomic/configure index d579bab..0a34027 100755 --- a/libatomic/configure +++ b/libatomic/configure @@ -3415,6 +3415,26 @@ esac # the wrong, non-multilib-adjusted value will be used in multilibs. # As a side effect, we have to subst CFLAGS ourselves. +# AC_PROG_CC sets CFLAGS to "-g -O2" by default (if unset), and +# then compile conftests with default CFLAGS, leaving no place to temporarily +# modify CFLAGS and restore them later. However we need to pass +# -fno-link-libatomic in CFLAGS so conftests compiled in AC_PROG_CC don't fail. +# Assert that CFLAGS is always set by user so the default setting of CFLAGS by +# AC_PROG_CC won't be applicable anyway. +if test -z "${CFLAGS}"; then + as_fn_error $? "CFLAGS must be set." "$LINENO" 5 +fi + +# In order to override CFLAGS_FOR_TARGET, all of our special flags go +# in XCFLAGS. But we need them in CFLAGS during configury. So put them +# in both places for now and restore CFLAGS at the end of config. +save_CFLAGS="$CFLAGS" + +# Append -fno-link-libatomic to avoid automatically linking libatomic, +# while building libatomic itself. +XCFLAGS="$XCFLAGS -fno-link-libatomic" +CFLAGS="$save_CFLAGS $XCFLAGS" + ac_ext=c @@ -4593,11 +4613,6 @@ fi -# In order to override CFLAGS_FOR_TARGET, all of our special flags go -# in XCFLAGS. But we need them in CFLAGS during configury. So put them -# in both places for now and restore CFLAGS at the end of config. -save_CFLAGS="$CFLAGS" - # Find other programs we need. if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. @@ -11456,7 +11471,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11459 "configure" +#line 11474 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11562,7 +11577,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11565 "configure" +#line 11580 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/libatomic/configure.ac b/libatomic/configure.ac index 32a2cdb..23a9695 100644 --- a/libatomic/configure.ac +++ b/libatomic/configure.ac @@ -129,6 +129,26 @@ AC_SUBST(toolexeclibdir) # the wrong, non-multilib-adjusted value will be used in multilibs. # As a side effect, we have to subst CFLAGS ourselves. +# AC_PROG_CC sets CFLAGS to "-g -O2" by default (if unset), and +# then compile conftests with default CFLAGS, leaving no place to temporarily +# modify CFLAGS and restore them later. However we need to pass +# -fno-link-libatomic in CFLAGS so conftests compiled in AC_PROG_CC don't fail. +# Assert that CFLAGS is always set by user so the default setting of CFLAGS by +# AC_PROG_CC won't be applicable anyway. +if test -z "${CFLAGS}"; then + AC_MSG_ERROR([CFLAGS must be set.]) +fi + +# In order to override CFLAGS_FOR_TARGET, all of our special flags go +# in XCFLAGS. But we need them in CFLAGS during configury. So put them +# in both places for now and restore CFLAGS at the end of config. +save_CFLAGS="$CFLAGS" + +# Append -fno-link-libatomic to avoid automatically linking libatomic, +# while building libatomic itself. +XCFLAGS="$XCFLAGS -fno-link-libatomic" +CFLAGS="$save_CFLAGS $XCFLAGS" + m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) m4_define([_AC_ARG_VAR_PRECIOUS],[]) AC_PROG_CC @@ -137,11 +157,6 @@ m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) AC_SUBST(CFLAGS) -# In order to override CFLAGS_FOR_TARGET, all of our special flags go -# in XCFLAGS. But we need them in CFLAGS during configury. So put them -# in both places for now and restore CFLAGS at the end of config. -save_CFLAGS="$CFLAGS" - # Find other programs we need. AC_CHECK_TOOL(AR, ar) AC_CHECK_TOOL(NM, nm) |