wok-next diff gcc/stuff/patches/005_all_default-as-needed.patch @ rev 21060

Update: binutils (2.31.1), bison (3.2.2), gcc (8.2.0), glibc (2.28), linux (4.14.85)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Dec 05 02:04:28 2018 +0200 (2018-12-05)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gcc/stuff/patches/005_all_default-as-needed.patch	Wed Dec 05 02:04:28 2018 +0200
     1.3 @@ -0,0 +1,244 @@
     1.4 +# DP: On linux targets pass --as-needed by default to the linker, but always
     1.5 +# DP: link the sanitizer libraries with --no-as-needed.
     1.6 +
     1.7 +Index: b/gcc/gcc.c
     1.8 +===================================================================
     1.9 +--- a/gcc/gcc.c
    1.10 ++++ b/gcc/gcc.c
    1.11 +@@ -692,8 +692,11 @@ proper position among the other output f
    1.12 + #ifdef LIBASAN_EARLY_SPEC
    1.13 + #define LIBASAN_SPEC STATIC_LIBASAN_LIBS
    1.14 + #elif defined(HAVE_LD_STATIC_DYNAMIC)
    1.15 +-#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \
    1.16 +-		     "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \
    1.17 ++#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \
    1.18 ++		     " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
    1.19 ++		     " -lasan " \
    1.20 ++		     " %{static-libasan:" LD_DYNAMIC_OPTION "}" \
    1.21 ++		     " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
    1.22 + 		     STATIC_LIBASAN_LIBS
    1.23 + #else
    1.24 + #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
    1.25 +@@ -710,8 +713,11 @@ proper position among the other output f
    1.26 + #ifdef LIBTSAN_EARLY_SPEC
    1.27 + #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
    1.28 + #elif defined(HAVE_LD_STATIC_DYNAMIC)
    1.29 +-#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \
    1.30 +-		     "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
    1.31 ++#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \
    1.32 ++		     " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
    1.33 ++		     " -ltsan " \
    1.34 ++		     " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
    1.35 ++		     " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
    1.36 + 		     STATIC_LIBTSAN_LIBS
    1.37 + #else
    1.38 + #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
    1.39 +@@ -728,8 +734,11 @@ proper position among the other output f
    1.40 + #ifdef LIBLSAN_EARLY_SPEC
    1.41 + #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
    1.42 + #elif defined(HAVE_LD_STATIC_DYNAMIC)
    1.43 +-#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \
    1.44 +-		     "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
    1.45 ++#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \
    1.46 ++		     " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
    1.47 ++		     " -llsan " \
    1.48 ++		     " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
    1.49 ++		     " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
    1.50 + 		     STATIC_LIBLSAN_LIBS
    1.51 + #else
    1.52 + #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
    1.53 +@@ -744,8 +753,11 @@ proper position among the other output f
    1.54 + #define STATIC_LIBUBSAN_LIBS \
    1.55 +   " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}"
    1.56 + #ifdef HAVE_LD_STATIC_DYNAMIC
    1.57 +-#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \
    1.58 +-		     "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
    1.59 ++#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \
    1.60 ++		     " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
    1.61 ++		     " -lubsan " \
    1.62 ++		     " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
    1.63 ++		     " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
    1.64 + 		     STATIC_LIBUBSAN_LIBS
    1.65 + #else
    1.66 + #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
    1.67 +Index: b/gcc/config/gnu-user.h
    1.68 +===================================================================
    1.69 +--- a/gcc/config/gnu-user.h
    1.70 ++++ b/gcc/config/gnu-user.h
    1.71 +@@ -161,15 +161,15 @@ see the files COPYING3 and COPYING.RUNTI
    1.72 + #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
    1.73 +   "%{static-libasan:%{!shared:" \
    1.74 +   LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
    1.75 +-  LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
    1.76 ++  LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}"
    1.77 + #undef LIBTSAN_EARLY_SPEC
    1.78 + #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
    1.79 +   "%{static-libtsan:%{!shared:" \
    1.80 +   LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
    1.81 +-  LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
    1.82 ++  LD_DYNAMIC_OPTION "}}%{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed -ltsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
    1.83 + #undef LIBLSAN_EARLY_SPEC
    1.84 + #define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
    1.85 +   "%{static-liblsan:%{!shared:" \
    1.86 +   LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
    1.87 +-  LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
    1.88 ++  LD_DYNAMIC_OPTION "}}%{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed -llsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
    1.89 + #endif
    1.90 +Index: b/gcc/config/aarch64/aarch64-linux.h
    1.91 +===================================================================
    1.92 +--- a/gcc/config/aarch64/aarch64-linux.h
    1.93 ++++ b/gcc/config/aarch64/aarch64-linux.h
    1.94 +@@ -35,6 +35,7 @@
    1.95 + #define CPP_SPEC "%{pthread:-D_REENTRANT}"
    1.96 + 
    1.97 + #define LINUX_TARGET_LINK_SPEC  "%{h*}		\
    1.98 ++   --as-needed					\
    1.99 +    %{static:-Bstatic}				\
   1.100 +    %{shared:-shared}				\
   1.101 +    %{symbolic:-Bsymbolic}			\
   1.102 +Index: b/gcc/config/ia64/linux.h
   1.103 +===================================================================
   1.104 +--- a/gcc/config/ia64/linux.h
   1.105 ++++ b/gcc/config/ia64/linux.h
   1.106 +@@ -58,7 +58,7 @@ do {						\
   1.107 + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
   1.108 + 
   1.109 + #undef LINK_SPEC
   1.110 +-#define LINK_SPEC "\
   1.111 ++#define LINK_SPEC " --as-needed \
   1.112 +   %{shared:-shared} \
   1.113 +   %{!shared: \
   1.114 +     %{!static: \
   1.115 +Index: b/gcc/config/sparc/linux.h
   1.116 +===================================================================
   1.117 +--- a/gcc/config/sparc/linux.h
   1.118 ++++ b/gcc/config/sparc/linux.h
   1.119 +@@ -86,7 +86,7 @@ extern const char *host_detect_local_cpu
   1.120 + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
   1.121 + 
   1.122 + #undef  LINK_SPEC
   1.123 +-#define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
   1.124 ++#define LINK_SPEC "-m elf32_sparc --as-needed %{shared:-shared} \
   1.125 +   %{!mno-relax:%{!r:-relax}} \
   1.126 +   %{!shared: \
   1.127 +     %{!static: \
   1.128 +Index: b/gcc/config/s390/linux.h
   1.129 +===================================================================
   1.130 +--- a/gcc/config/s390/linux.h
   1.131 ++++ b/gcc/config/s390/linux.h
   1.132 +@@ -78,7 +78,7 @@ along with GCC; see the file COPYING3.
   1.133 + 
   1.134 + #undef  LINK_SPEC
   1.135 + #define LINK_SPEC \
   1.136 +-  "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
   1.137 ++  "%{m31:-m elf_s390}%{m64:-m elf64_s390} --as-needed \
   1.138 +    %{shared:-shared} \
   1.139 +    %{!shared: \
   1.140 +       %{static:-static} \
   1.141 +Index: b/gcc/config/rs6000/linux64.h
   1.142 +===================================================================
   1.143 +--- a/gcc/config/rs6000/linux64.h
   1.144 ++++ b/gcc/config/rs6000/linux64.h
   1.145 +@@ -490,13 +490,13 @@ extern int dot_symbols;
   1.146 + 					   " -m elf64ppc")
   1.147 + #endif
   1.148 + 
   1.149 +-#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
   1.150 ++#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --as-needed %{!shared: %{!static: \
   1.151 +   %{!static-pie: \
   1.152 +     %{rdynamic:-export-dynamic} \
   1.153 +     -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \
   1.154 +   %(link_os_extra_spec32)"
   1.155 + 
   1.156 +-#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \
   1.157 ++#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --as-needed %{!shared: %{!static: \
   1.158 +   %{!static-pie: \
   1.159 +     %{rdynamic:-export-dynamic} \
   1.160 +     -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
   1.161 +Index: b/gcc/config/rs6000/sysv4.h
   1.162 +===================================================================
   1.163 +--- a/gcc/config/rs6000/sysv4.h
   1.164 ++++ b/gcc/config/rs6000/sysv4.h
   1.165 +@@ -811,7 +811,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
   1.166 +   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
   1.167 + 			 MUSL_DYNAMIC_LINKER)
   1.168 + 
   1.169 +-#define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
   1.170 ++#define LINK_OS_LINUX_SPEC "-m elf32ppclinux --as-needed %{!shared: %{!static: \
   1.171 +   %{rdynamic:-export-dynamic} \
   1.172 +   -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
   1.173 + 
   1.174 +Index: b/gcc/config/i386/gnu-user64.h
   1.175 +===================================================================
   1.176 +--- a/gcc/config/i386/gnu-user64.h
   1.177 ++++ b/gcc/config/i386/gnu-user64.h
   1.178 +@@ -56,6 +56,7 @@
   1.179 +                   "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
   1.180 +                    %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
   1.181 +                    %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
   1.182 ++  --as-needed \
   1.183 +   %{shared:-shared} \
   1.184 +   %{!shared: \
   1.185 +     %{!static: \
   1.186 +Index: b/gcc/config/i386/gnu-user.h
   1.187 +===================================================================
   1.188 +--- a/gcc/config/i386/gnu-user.h
   1.189 ++++ b/gcc/config/i386/gnu-user.h
   1.190 +@@ -74,7 +74,7 @@ along with GCC; see the file COPYING3.
   1.191 +   { "link_emulation", GNU_USER_LINK_EMULATION },\
   1.192 +   { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
   1.193 + 
   1.194 +-#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
   1.195 ++#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --as-needed %{shared:-shared} \
   1.196 +   %{!shared: \
   1.197 +     %{!static: \
   1.198 +       %{!static-pie: \
   1.199 +Index: b/gcc/config/alpha/linux-elf.h
   1.200 +===================================================================
   1.201 +--- a/gcc/config/alpha/linux-elf.h
   1.202 ++++ b/gcc/config/alpha/linux-elf.h
   1.203 +@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3.
   1.204 + 
   1.205 + #define ELF_DYNAMIC_LINKER	GNU_USER_DYNAMIC_LINKER
   1.206 + 
   1.207 +-#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax}		\
   1.208 ++#define LINK_SPEC "-m elf64alpha --as-needed %{G*} %{relax:-relax}		\
   1.209 +   %{O*:-O3} %{!O*:-O1}						\
   1.210 +   %{shared:-shared}						\
   1.211 +   %{!shared:							\
   1.212 +Index: b/gcc/config/arm/linux-elf.h
   1.213 +===================================================================
   1.214 +--- a/gcc/config/arm/linux-elf.h
   1.215 ++++ b/gcc/config/arm/linux-elf.h
   1.216 +@@ -70,6 +70,7 @@
   1.217 +      %{rdynamic:-export-dynamic} \
   1.218 +      %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
   1.219 +    -X \
   1.220 ++   --as-needed \
   1.221 +    %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
   1.222 +    SUBTARGET_EXTRA_LINK_SPEC
   1.223 + 
   1.224 +Index: b/gcc/config/mips/gnu-user.h
   1.225 +===================================================================
   1.226 +--- a/gcc/config/mips/gnu-user.h
   1.227 ++++ b/gcc/config/mips/gnu-user.h
   1.228 +@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.
   1.229 + #undef GNU_USER_TARGET_LINK_SPEC
   1.230 + #define GNU_USER_TARGET_LINK_SPEC "\
   1.231 +   %{G*} %{EB} %{EL} %{mips*} %{shared} \
   1.232 ++ -as-needed \
   1.233 +   %{!shared: \
   1.234 +     %{!static: \
   1.235 +       %{rdynamic:-export-dynamic} \
   1.236 +Index: b/gcc/config/riscv/linux.h
   1.237 +===================================================================
   1.238 +--- a/gcc/config/riscv/linux.h
   1.239 ++++ b/gcc/config/riscv/linux.h
   1.240 +@@ -50,6 +50,7 @@
   1.241 + #define CPP_SPEC "%{pthread:-D_REENTRANT}"
   1.242 + 
   1.243 + #define LINK_SPEC "\
   1.244 ++-as-needed \
   1.245 + -melf" XLEN_SPEC "lriscv \
   1.246 + %{mno-relax:--no-relax} \
   1.247 + %{shared} \