> -----Original Message-----
> From: Xi Ruoyao <xry...@xry111.site>
> Sent: 16 November 2024 09:23
> To: Prathamesh Kulkarni <prathame...@nvidia.com>; josmy...@redhat.com;
> Matthew Malcomson <mmalcom...@nvidia.com>; gcc-patches@gcc.gnu.org
> Subject: Re: [RFC] PR81358: Enable automatic linking of libatomic
> 
> External email: Use caution opening links or attachments
> 
> 
> On Sat, 2024-11-16 at 03:44 +0000, Prathamesh Kulkarni wrote:
> > diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in index
> > 9798e7c09e9..62cd5e0a76b 100644
> > --- a/libatomic/Makefile.in
> > +++ b/libatomic/Makefile.in
> > @@ -1,7 +1,7 @@
> > -# Makefile.in generated by automake 1.15.1 from Makefile.am.
> > +# Makefile.in generated by automake 1.16.1 from Makefile.am.
> 
> You cannot use a random automake version.  Please use the version
> specified in https://gcc.gnu.org/install/prerequisites.html.
Hi Xi,
Ah indeed, thanks for pointing out.
The attached patch uses automake-1.15.1 and autoconf-2.69 to autogenerate 
Makefile.in and configure files.
Bootstrapped+tested on aarch64-linux-gnu.
Does the patch look in the right direction ?

Thanks,
Prathamesh
> 
> --
> Xi Ruoyao <xry...@xry111.site>
> School of Aerospace Science and Technology, Xidian University
PR81358: Enable automatic linking of libatomic.

ChangeLog:
        PR driver/81358
        * Makefile.def: Add dependencies so libatomic is built before target
        libraries are configured.
        * 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.

libatomic/ChangeLog:
        PR driver/81358
        * Makefile.am: Pass -fno-link-libatomic.
        New rule all.
        * configure.ac: Pass -fno-link-libatomic. 
        * Makefile.in: Regenerate.
        * configure: Regenerate.

Signed-off-by: Prathamesh Kulkarni <prathame...@nvidia.com>
Co-authored-by: Matthew Malcolmson <mmalcolm...@nvidia.com>

diff --git a/Makefile.def b/Makefile.def
index 19954e7d731..90899fa28cf 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -656,6 +656,26 @@ lang_env_dependencies = { module=libgcc; no_gcc=true; 
no_c=true; };
 // a dependency on libgcc for native targets to configure.
 lang_env_dependencies = { module=libiberty; no_c=true; };
 
+dependencies = { module=configure-target-libbacktrace; 
on=all-target-libatomic; };
+dependencies = { module=configure-target-libgloss; on=all-target-libatomic; };
+dependencies = { module=configure-target-newlib; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgomp; on=all-target-libatomic; };
+dependencies = { module=configure-target-libitm; on=all-target-libatomic; };
+dependencies = { module=configure-target-libstdc++v3; on=all-target-libatomic; 
};
+dependencies = { module=configure-target-libsanitizer; 
on=all-target-libatomic; };
+dependencies = { module=configure-target-libvtv; on=all-target-libatomic; };
+dependencies = { module=configure-target-libssp; on=all-target-libatomic; };
+dependencies = { module=configure-target-libquadmath; on=all-target-libatomic; 
};
+dependencies = { module=configure-target-libgfortran; on=all-target-libatomic; 
};
+dependencies = { module=configure-target-libffi; on=all-target-libatomic; };
+dependencies = { module=configure-target-libobjc; on=all-target-libatomic; };
+dependencies = { module=configure-target-libada; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgm2; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgo; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgrust; on=all-target-libatomic; };
+dependencies = { module=configure-target-libphobos; on=all-target-libatomic; };
+dependencies = { module=configure-target-zlib; on=all-target-libatomic; };
+
 dependencies = { module=configure-target-fastjar; on=configure-target-zlib; };
 dependencies = { module=all-target-fastjar; on=all-target-zlib; };
 dependencies = { module=configure-target-libgo; on=configure-target-libffi; };
diff --git a/Makefile.in b/Makefile.in
index 966d6045496..5295929bfa9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -68551,6 +68551,66 @@ all-flex: maybe-all-build-bison
 all-flex: maybe-all-m4
 all-flex: maybe-all-build-texinfo
 all-m4: maybe-all-build-texinfo
+configure-target-libbacktrace: maybe-all-target-libatomic
+configure-stage1-target-libbacktrace: maybe-all-stage1-target-libatomic
+configure-stage2-target-libbacktrace: maybe-all-stage2-target-libatomic
+configure-stage3-target-libbacktrace: maybe-all-stage3-target-libatomic
+configure-stage4-target-libbacktrace: maybe-all-stage4-target-libatomic
+configure-stageprofile-target-libbacktrace: 
maybe-all-stageprofile-target-libatomic
+configure-stagetrain-target-libbacktrace: maybe-all-stagetrain-target-libatomic
+configure-stagefeedback-target-libbacktrace: 
maybe-all-stagefeedback-target-libatomic
+configure-stageautoprofile-target-libbacktrace: 
maybe-all-stageautoprofile-target-libatomic
+configure-stageautofeedback-target-libbacktrace: 
maybe-all-stageautofeedback-target-libatomic
+configure-target-libgomp: maybe-all-target-libatomic
+configure-stage1-target-libgomp: maybe-all-stage1-target-libatomic
+configure-stage2-target-libgomp: maybe-all-stage2-target-libatomic
+configure-stage3-target-libgomp: maybe-all-stage3-target-libatomic
+configure-stage4-target-libgomp: maybe-all-stage4-target-libatomic
+configure-stageprofile-target-libgomp: maybe-all-stageprofile-target-libatomic
+configure-stagetrain-target-libgomp: maybe-all-stagetrain-target-libatomic
+configure-stagefeedback-target-libgomp: 
maybe-all-stagefeedback-target-libatomic
+configure-stageautoprofile-target-libgomp: 
maybe-all-stageautoprofile-target-libatomic
+configure-stageautofeedback-target-libgomp: 
maybe-all-stageautofeedback-target-libatomic
+configure-target-libsanitizer: maybe-all-target-libatomic
+configure-stage1-target-libsanitizer: maybe-all-stage1-target-libatomic
+configure-stage2-target-libsanitizer: maybe-all-stage2-target-libatomic
+configure-stage3-target-libsanitizer: maybe-all-stage3-target-libatomic
+configure-stage4-target-libsanitizer: maybe-all-stage4-target-libatomic
+configure-stageprofile-target-libsanitizer: 
maybe-all-stageprofile-target-libatomic
+configure-stagetrain-target-libsanitizer: maybe-all-stagetrain-target-libatomic
+configure-stagefeedback-target-libsanitizer: 
maybe-all-stagefeedback-target-libatomic
+configure-stageautoprofile-target-libsanitizer: 
maybe-all-stageautoprofile-target-libatomic
+configure-stageautofeedback-target-libsanitizer: 
maybe-all-stageautofeedback-target-libatomic
+configure-target-libvtv: maybe-all-target-libatomic
+configure-stage1-target-libvtv: maybe-all-stage1-target-libatomic
+configure-stage2-target-libvtv: maybe-all-stage2-target-libatomic
+configure-stage3-target-libvtv: maybe-all-stage3-target-libatomic
+configure-stage4-target-libvtv: maybe-all-stage4-target-libatomic
+configure-stageprofile-target-libvtv: maybe-all-stageprofile-target-libatomic
+configure-stagetrain-target-libvtv: maybe-all-stagetrain-target-libatomic
+configure-stagefeedback-target-libvtv: maybe-all-stagefeedback-target-libatomic
+configure-stageautoprofile-target-libvtv: 
maybe-all-stageautoprofile-target-libatomic
+configure-stageautofeedback-target-libvtv: 
maybe-all-stageautofeedback-target-libatomic
+configure-target-libphobos: maybe-all-target-libatomic
+configure-stage1-target-libphobos: maybe-all-stage1-target-libatomic
+configure-stage2-target-libphobos: maybe-all-stage2-target-libatomic
+configure-stage3-target-libphobos: maybe-all-stage3-target-libatomic
+configure-stage4-target-libphobos: maybe-all-stage4-target-libatomic
+configure-stageprofile-target-libphobos: 
maybe-all-stageprofile-target-libatomic
+configure-stagetrain-target-libphobos: maybe-all-stagetrain-target-libatomic
+configure-stagefeedback-target-libphobos: 
maybe-all-stagefeedback-target-libatomic
+configure-stageautoprofile-target-libphobos: 
maybe-all-stageautoprofile-target-libatomic
+configure-stageautofeedback-target-libphobos: 
maybe-all-stageautofeedback-target-libatomic
+configure-target-zlib: maybe-all-target-libatomic
+configure-stage1-target-zlib: maybe-all-stage1-target-libatomic
+configure-stage2-target-zlib: maybe-all-stage2-target-libatomic
+configure-stage3-target-zlib: maybe-all-stage3-target-libatomic
+configure-stage4-target-zlib: maybe-all-stage4-target-libatomic
+configure-stageprofile-target-zlib: maybe-all-stageprofile-target-libatomic
+configure-stagetrain-target-zlib: maybe-all-stagetrain-target-libatomic
+configure-stagefeedback-target-zlib: maybe-all-stagefeedback-target-libatomic
+configure-stageautoprofile-target-zlib: 
maybe-all-stageautoprofile-target-libatomic
+configure-stageautofeedback-target-zlib: 
maybe-all-stageautofeedback-target-libatomic
 configure-target-libgo: maybe-configure-target-libffi
 all-target-libgo: maybe-all-target-libffi
 configure-target-libphobos: maybe-configure-target-libbacktrace
@@ -68678,6 +68738,45 @@ configure-m4: stage_last
 @endif gcc-bootstrap
 
 @if gcc-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libgloss: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-newlib: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libitm: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libstdc++v3: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libssp: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libquadmath: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libgfortran: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libffi: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libobjc: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libada: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libgm2: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libgo: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
+@unless target-libatomic-bootstrap
+configure-target-libgrust: maybe-all-target-libatomic
+@endunless target-libatomic-bootstrap
 @unless target-zlib-bootstrap
 configure-target-fastjar: maybe-configure-target-zlib
 @endunless target-zlib-bootstrap
@@ -68755,6 +68854,19 @@ all-fastjar: maybe-all-libiberty
 all-bison: maybe-all-gettext
 all-flex: maybe-all-gettext
 all-m4: maybe-all-gettext
+configure-target-libgloss: maybe-all-target-libatomic
+configure-target-newlib: maybe-all-target-libatomic
+configure-target-libitm: maybe-all-target-libatomic
+configure-target-libstdc++v3: maybe-all-target-libatomic
+configure-target-libssp: maybe-all-target-libatomic
+configure-target-libquadmath: maybe-all-target-libatomic
+configure-target-libgfortran: maybe-all-target-libatomic
+configure-target-libffi: maybe-all-target-libatomic
+configure-target-libobjc: maybe-all-target-libatomic
+configure-target-libada: maybe-all-target-libatomic
+configure-target-libgm2: maybe-all-target-libatomic
+configure-target-libgo: maybe-all-target-libatomic
+configure-target-libgrust: maybe-all-target-libatomic
 configure-target-fastjar: maybe-configure-target-zlib
 all-target-fastjar: maybe-all-target-zlib
 configure-target-libgo: maybe-all-target-libstdc++-v3
diff --git a/configure b/configure
index a2e86731b08..4b026944563 100755
--- a/configure
+++ b/configure
@@ -10870,6 +10870,11 @@ if echo " ${target_configdirs} " | grep " libgomp " > 
/dev/null 2>&1 ; then
   bootstrap_target_libs=${bootstrap_target_libs}target-libgomp,
 fi
 
+# If we are building libatomic, bootstrap it.
+if echo " ${target_configdirs} " | grep " libatomic " > /dev/null 2>&1 ; then
+  bootstrap_target_libs=${bootstrap_target_libs}target-libatomic,
+fi
+
 # If we are building libsanitizer and $BUILD_CONFIG contains bootstrap-asan
 # or bootstrap-ubsan, bootstrap it.
 if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; then
diff --git a/configure.ac b/configure.ac
index 25419a1d2ab..566d18c0a9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3106,6 +3106,11 @@ if echo " ${target_configdirs} " | grep " libgomp " > 
/dev/null 2>&1 ; then
   bootstrap_target_libs=${bootstrap_target_libs}target-libgomp,
 fi
 
+# If we are building libatomic, bootstrap it.
+if echo " ${target_configdirs} " | grep " libatomic " > /dev/null 2>&1 ; then
+  bootstrap_target_libs=${bootstrap_target_libs}target-libatomic,
+fi
+
 # If we are building libsanitizer and $BUILD_CONFIG contains bootstrap-asan
 # or bootstrap-ubsan, bootstrap it.
 if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; then
diff --git a/gcc/common.opt b/gcc/common.opt
index 33be6b8042a..4026e27c71e 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3336,6 +3336,9 @@ Use the Modern linker (MOLD) linker instead of the 
default linker.
 fuse-linker-plugin
 Common Undocumented Var(flag_use_linker_plugin)
 
+flink-libatomic
+Common Driver Var(flag_link_libatomic) Init(1)
+
 ; Positive if we should track variables, negative if we should run
 ; the var-tracking pass only to discard debug annotations, zero if
 ; we're not to run it.
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index f7eefdafe8b..27d0ef07e1e 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -109,8 +109,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
 #define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
 #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/gcc.cc b/gcc/gcc.cc
index 5fe5fd86a98..3bf77f28683 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -981,6 +981,13 @@ proper position among the other output files.  */
 
 /* Here is the spec for running the linker, after compiling all files.  */
 
+#ifdef USE_LD_AS_NEEDED
+#define LINK_LIBATOMIC_SPEC "%{!fno-link-libatomic:" LD_AS_NEEDED_OPTION \
+                           " -latomic " LD_NO_AS_NEEDED_OPTION "} "
+#else
+#define LINK_LIBATOMIC_SPEC ""
+#endif
+
 /* 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.  */
diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
index efadd9dcd48..66ef9fd8675 100644
--- a/libatomic/Makefile.am
+++ b/libatomic/Makefile.am
@@ -35,9 +35,9 @@ search_path = $(addprefix $(top_srcdir)/config/, 
$(config_path)) \
 vpath % $(strip $(search_path))
 
 DEFAULT_INCLUDES = $(addprefix -I, $(search_path))
-AM_CFLAGS = $(XCFLAGS)
-AM_CCASFLAGS = $(XCFLAGS)
-AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
+AM_CFLAGS = $(XCFLAGS) -fno-link-libatomic
+AM_CCASFLAGS = $(XCFLAGS) -fno-link-libatomic
+AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS) -fno-link-libatomic
 
 toolexeclib_LTLIBRARIES = libatomic.la
 noinst_LTLIBRARIES = libatomic_convenience.la
@@ -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 9798e7c09e9..3ecfe89e4c6 100644
--- a/libatomic/Makefile.in
+++ b/libatomic/Makefile.in
@@ -405,9 +405,9 @@ search_path = $(addprefix $(top_srcdir)/config/, 
$(config_path)) \
        $(top_srcdir) $(top_builddir)
 
 DEFAULT_INCLUDES = $(addprefix -I, $(search_path))
-AM_CFLAGS = $(XCFLAGS)
-AM_CCASFLAGS = $(XCFLAGS)
-AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
+AM_CFLAGS = $(XCFLAGS) -fno-link-libatomic
+AM_CCASFLAGS = $(XCFLAGS) -fno-link-libatomic
+AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS) -fno-link-libatomic
 toolexeclib_LTLIBRARIES = libatomic.la
 noinst_LTLIBRARIES = libatomic_convenience.la
 @LIBAT_BUILD_VERSIONED_SHLIB_FALSE@libatomic_version_script = 
@@ -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 d579bab96f8..3ae8fcb3efd 100755
--- a/libatomic/configure
+++ b/libatomic/configure
@@ -706,8 +706,8 @@ EXEEXT
 ac_ct_CC
 CPPFLAGS
 LDFLAGS
-CFLAGS
 CC
+CFLAGS
 toolexeclibdir
 toolexecdir
 multi_basedir
@@ -3409,6 +3409,8 @@ esac
 
 
 
+CFLAGS="$CFLAGS -fno-link-libatomic"
+
 # Check the compiler.
 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
 # We must force CC to /not/ be precious variables; otherwise
@@ -4591,8 +4593,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.
@@ -11929,6 +11929,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
     ;;
 esac
 
+SYSROOT_CFLAGS_FOR_TARGET="$SYSROOT_CFLAGS_FOR_TARGET -fno-link-libatomic"
 
 
 # Get target configury.
@@ -14994,6 +14995,8 @@ rm -f core conftest.err conftest.$ac_objext \
   ;;
 esac
 
+CFLAGS="$CFLAGS -fno-link-libatomic"
+
 # See what sort of export controls are available.
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the target 
supports hidden visibility" >&5
@@ -15753,12 +15756,16 @@ fi
 
 XCFLAGS="$XCFLAGS $CET_FLAGS"
 
-XCFLAGS="$XCFLAGS $XPCFLAGS"
+XCFLAGS="$XCFLAGS $XPCFLAGS -fno-link-libatomic"
+XLDFLAGS="$XLDFLAGS -fno-link-libatomic"
+
+
 
 
 
 
 
+LDFLAGS="$LDFLAGS -fno-link-libatomic"
 
 
 # Conditionalize the makefile for this target machine.
diff --git a/libatomic/configure.ac b/libatomic/configure.ac
index 32a2cdb13ae..2472529f539 100644
--- a/libatomic/configure.ac
+++ b/libatomic/configure.ac
@@ -123,6 +123,8 @@ esac
 AC_SUBST(toolexecdir)
 AC_SUBST(toolexeclibdir)
 
+CFLAGS="$CFLAGS -fno-link-libatomic"
+AC_SUBST(CFLAGS)
 # Check the compiler.
 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
 # We must force CC to /not/ be precious variables; otherwise
@@ -135,8 +137,6 @@ AC_PROG_CC
 AM_PROG_AS
 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.
@@ -172,6 +172,7 @@ case "$target" in
     ;;
 esac
 
+SYSROOT_CFLAGS_FOR_TARGET="$SYSROOT_CFLAGS_FOR_TARGET -fno-link-libatomic"
 AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
 
 # Get target configury.
@@ -239,6 +240,8 @@ case " $config_path " in
   ;;
 esac
 
+CFLAGS="$CFLAGS -fno-link-libatomic"
+
 # See what sort of export controls are available.
 LIBAT_CHECK_ATTRIBUTE_VISIBILITY
 LIBAT_CHECK_ATTRIBUTE_DLLEXPORT
@@ -266,7 +269,8 @@ AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = 
"xyes"],
 GCC_CET_FLAGS(CET_FLAGS)
 XCFLAGS="$XCFLAGS $CET_FLAGS"
 
-XCFLAGS="$XCFLAGS $XPCFLAGS"
+XCFLAGS="$XCFLAGS $XPCFLAGS -fno-link-libatomic"
+XLDFLAGS="$XLDFLAGS -fno-link-libatomic"
 
 AC_SUBST(config_path)
 AC_SUBST(XCFLAGS)
@@ -274,6 +278,9 @@ AC_SUBST(XLDFLAGS)
 AC_SUBST(LIBS)
 AC_SUBST(SIZES)
 
+LDFLAGS="$LDFLAGS -fno-link-libatomic"
+AC_SUBST(LDFLAGS)
+
 # Conditionalize the makefile for this target machine.
 tmake_file_=
 for f in ${tmake_file}

Reply via email to