Blame SOURCES/gcc11-libgcc-link.patch

a46658
libgcc: Honor LDFLAGS_FOR_TARGET when linking libgcc_s
a46658
a46658
When building gcc with some specific LDFLAGS_FOR_TARGET, e.g.
a46658
LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
a46658
those flags propagate info linking of target shared libraries,
a46658
e.g. lib{ubsan,tsan,stdc++,quadmath,objc,lsan,itm,gphobos,gdruntime,gomp,go,gfortran,atomic,asan}.so.*
a46658
but there is one important exception, libgcc_s.so.* linking ignores it.
a46658
a46658
The following patch fixes that.
a46658
a46658
Bootstrapped/regtested on x86_64-linux with LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
a46658
and verified that libgcc_s.so.* is BIND_NOW when it previously wasn't, and
a46658
without any LDFLAGS_FOR_TARGET on x86_64-linux and i686-linux.
a46658
There on x86_64-linux I've verified that the libgcc_s.so.1 linking command
a46658
line for -m64 is identical except for whitespace to one without the patch,
a46658
and for -m32 multilib $(LDFLAGS) actually do supply there an extra -m32
a46658
that also repeats later in the @multilib_flags@, which should be harmless.
a46658
a46658
2021-08-04  Jakub Jelinek  <jakub@redhat.com>
a46658
a46658
	* config/t-slibgcc (SHLIB_LINK): Add $(LDFLAGS).
a46658
	* config/t-slibgcc-darwin (SHLIB_LINK): Likewise.
a46658
	* config/t-slibgcc-vms (SHLIB_LINK): Likewise.
a46658
a46658
--- libgcc/config/t-slibgcc
a46658
+++ libgcc/config/t-slibgcc
a46658
@@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
a46658
 	$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
a46658
 
a46658
 SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
a46658
-	$(SHLIB_LDFLAGS) \
a46658
+	$(SHLIB_LDFLAGS) $(LDFLAGS) \
a46658
 	-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
a46658
 	$(SHLIB_OBJS) $(SHLIB_LC) && \
a46658
 	rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
a46658
--- libgcc/config/t-slibgcc-darwin
a46658
+++ libgcc/config/t-slibgcc-darwin
a46658
@@ -15,7 +15,7 @@ SHLIB_LC = -lc
a46658
 # Note that this version is used for the loader, not the linker; the linker
a46658
 # uses the stub versions named by the versioned members of $(INSTALL_FILES).
a46658
 
a46658
-SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
a46658
+SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
a46658
 	-install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \
a46658
 	-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
a46658
 	-Wl,-exported_symbols_list,$(SHLIB_MAP) \
a46658
--- libgcc/config/t-slibgcc-vms
a46658
+++ libgcc/config/t-slibgcc-vms
a46658
@@ -22,7 +22,7 @@ SHLIB_LINK = \
a46658
   objdump --syms $(SHLIB_OBJS) | \
a46658
   $(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt ; \
a46658
   echo "case_sensitive=NO" >> SYMVEC_$$$$.opt; \
a46658
-  $(CC) $(LIBGCC2_CFLAGS) -nodefaultlibs \
a46658
+  $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -nodefaultlibs \
a46658
   -shared --for-linker=/noinform -o $(SHLIB_NAME) $(SHLIB_OBJS) \
a46658
   --for-linker=SYMVEC_$$$$.opt \
a46658
   --for-linker=gsmatch=equal,$(shlib_version)