From b1468238d13abdd98e3d07003e2a8af5e3505c12 Mon Sep 17 00:00:00 2001 From: luohailing 00576038 Date: Fri, 27 May 2022 18:59:59 +0800 Subject: [PATCH] Backport: Add USE_LLD_LD --- gcc.spec | 6 +++ lld.patch | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 lld.patch diff --git a/gcc.spec b/gcc.spec index 8ff4f3e..fba4af1 100644 --- a/gcc.spec +++ b/gcc.spec @@ -96,6 +96,7 @@ Patch39: fix-PR83666-punt-BLKmode-when-expand_debug_expr.patch Patch40: fix-AArch64-128-bit-immediate-ICEs.patch Patch41: PR-c-83227-C-17-ICE-with-init-list-derived.patch Patch42: Remove-_GLIBCXX_USE_INT128-autoconf-macro.patch +Patch43: lld.patch #AutoReqProv: off AutoReq: true @@ -582,6 +583,7 @@ package or when debugging this package. %patch40 -p1 %patch41 -p1 %patch42 -p1 +%patch43 -p1 %if 0%{?_enable_debug_packages} cat > split-debuginfo.sh <<\EOF @@ -3338,6 +3340,10 @@ fi %changelog +* Fri May 27 2022 luohailing - 7.3.0-50 +- lld.patch: Likewise +- gcc.spec: Add new patch + * Wed Apr 20 2022 benniaobufeijiushiji - 7.3.0-2020033101.49 - gcc.spec: Bugfix for removing Date in release version, use a const number instead. diff --git a/lld.patch b/lld.patch new file mode 100644 index 0000000..97a676d --- /dev/null +++ b/lld.patch @@ -0,0 +1,107 @@ +commit d69ac8b7f890f79560b11a3548fa39f3e7f8427e +Author: Roman Geissler +Date: Thu Nov 8 22:05:27 2018 +0000 + + collect2.c (linker_select): Add USE_LLD_LD. + + * collect2.c (linker_select): Add USE_LLD_LD. + (ld_suffixes): Add ld.lld. + (main): Handle -fuse-ld=lld. + * common.opt (-fuse-ld=lld): New option. + * doc/invoke.texi (-fuse-ld=lld): Document. + * opts.c (common_handle_option): Handle OPT_fuse_ld_lld. + + From-SVN: r265940 + +diff --git a/gcc/collect2.c b/gcc/collect2.c +index a96af137a44..6463ff7b645 100644 +--- a/gcc/collect2.c ++++ b/gcc/collect2.c +@@ -831,6 +831,7 @@ main (int argc, char **argv) + USE_PLUGIN_LD, + USE_GOLD_LD, + USE_BFD_LD, ++ USE_LLD_LD, + USE_LD_MAX + } selected_linker = USE_DEFAULT_LD; + static const char *const ld_suffixes[USE_LD_MAX] = +@@ -838,7 +839,8 @@ main (int argc, char **argv) + "ld", + PLUGIN_LD_SUFFIX, + "ld.gold", +- "ld.bfd" ++ "ld.bfd", ++ "ld.lld" + }; + static const char *const real_ld_suffix = "real-ld"; + static const char *const collect_ld_suffix = "collect-ld"; +@@ -1007,6 +1009,8 @@ main (int argc, char **argv) + selected_linker = USE_BFD_LD; + else if (strcmp (argv[i], "-fuse-ld=gold") == 0) + selected_linker = USE_GOLD_LD; ++ else if (strcmp (argv[i], "-fuse-ld=lld") == 0) ++ selected_linker = USE_LLD_LD; + + #ifdef COLLECT_EXPORT_LIST + /* These flags are position independent, although their order +@@ -1096,7 +1100,8 @@ main (int argc, char **argv) + /* Maybe we know the right file to use (if not cross). */ + ld_file_name = 0; + #ifdef DEFAULT_LINKER +- if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD) ++ if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD || ++ selected_linker == USE_LLD_LD) + { + char *linker_name; + # ifdef HOST_EXECUTABLE_SUFFIX +@@ -1315,7 +1320,7 @@ main (int argc, char **argv) + else if (!use_collect_ld + && strncmp (arg, "-fuse-ld=", 9) == 0) + { +- /* Do not pass -fuse-ld={bfd|gold} to the linker. */ ++ /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */ + ld1--; + ld2--; + } +diff --git a/gcc/common.opt b/gcc/common.opt +index 5a5d33205a4..99489fbd553 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -2732,6 +2732,10 @@ fuse-ld=gold + Common Driver Negative(fuse-ld=bfd) + Use the gold linker instead of the default linker. + ++fuse-ld=lld ++Common Driver Negative(fuse-ld=lld) ++Use the lld LLVM linker instead of the default linker. ++ + fuse-linker-plugin + Common Undocumented Var(flag_use_linker_plugin) + +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index e0a770491b6..8762f3f7bc3 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -12610,6 +12610,10 @@ Use the @command{bfd} linker instead of the default linker. + @opindex fuse-ld=gold + Use the @command{gold} linker instead of the default linker. + ++@item -fuse-ld=lld ++@opindex fuse-ld=lld ++Use the LLVM @command{lld} linker instead of the default linker. ++ + @cindex Libraries + @item -l@var{library} + @itemx -l @var{library} +diff --git a/gcc/opts.c b/gcc/opts.c +index 34c283dd765..f094f5f1251 100644 +--- a/gcc/opts.c ++++ b/gcc/opts.c +@@ -2557,6 +2557,7 @@ common_handle_option (struct gcc_options *opts, + + case OPT_fuse_ld_bfd: + case OPT_fuse_ld_gold: ++ case OPT_fuse_ld_lld: + case OPT_fuse_linker_plugin: + /* No-op. Used by the driver and passed to us because it starts with f.*/ + break; -- Gitee