Blame SOURCES/gcc11-libgcc-link.patch

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