Don't call lto-wrapper for ar and ranlib 02/257602/1 accepted/tizen/6.5/base/tool/20211027.112442 accepted/tizen/base/tool/20210503.092848 submit/tizen_6.5_base/20211026.180901 submit/tizen_6.5_base/20211027.183101 submit/tizen_6.5_base/20211027.200501 submit/tizen_base/20210430.035409 tizen_6.5.m2_release
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 25 Feb 2020 11:30:33 +0000 (03:30 -0800)
committerDongkyun Son <dongkyun.s@samsung.com>
Wed, 28 Apr 2021 05:29:24 +0000 (14:29 +0900)
Since ar and ranlib don't need to know symbol types to work properly,
we should avoid calling lto-wrapper for them to speed them up.

bfd/

PR binutils/25584
* plugin.c (need_lto_wrapper_p): New.
(bfd_plugin_set_program_name): Add an int argument to set
need_lto_wrapper_p.
(get_lto_wrapper): Return FALSE if need_lto_wrapper_p isn't
set.
* plugin.h (bfd_plugin_set_program_name): Add an int argument.

binutils/

PR binutils/25584
* ar.c (main): Pass 0 to bfd_plugin_set_program_name.
* nm.c (main): Pass 1 to bfd_plugin_set_program_name.

(cherry picked from commit ecda90163e2b0a6f0be96e3fc262c28820a27211)

Change-Id: I2110670d62156392eae11af1b51b03870b6715f7

bfd/ChangeLog
bfd/plugin.c
bfd/plugin.h
binutils/ChangeLog
binutils/ar.c
binutils/nm.c

index 5ce31aa..b7e15e5 100644 (file)
@@ -1,3 +1,13 @@
+2020-02-25  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/25584
+       * plugin.c (need_lto_wrapper_p): New.
+       (bfd_plugin_set_program_name): Add an int argument to set
+       need_lto_wrapper_p.
+       (get_lto_wrapper): Return FALSE if need_lto_wrapper_p isn't
+       set.
+       * plugin.h (bfd_plugin_set_program_name): Add an int argument.
+
 2020-02-19  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR binutils/25355
index f19409a..deddfc9 100644 (file)
@@ -146,6 +146,17 @@ struct plugin_list_entry
   bfd_boolean initialized;
 };
 
+static const char *plugin_program_name;
+static int need_lto_wrapper_p;
+
+void
+bfd_plugin_set_program_name (const char *program_name,
+                            int need_lto_wrapper)
+{
+  plugin_program_name = program_name;
+  need_lto_wrapper_p = need_lto_wrapper;
+}
+
 /* Use GCC LTO wrapper to covert LTO IR object to the real object.  */
 
 static bfd_boolean
@@ -164,6 +175,9 @@ get_lto_wrapper (struct plugin_list_entry *plugin)
   char dir_seperator = '\0';
   char *resolution_file;
 
+  if (!need_lto_wrapper_p)
+    return FALSE;
+
   if (plugin->initialized)
     {
       if (plugin->lto_wrapper)
@@ -488,14 +502,6 @@ add_symbols (void * handle,
   return LDPS_OK;
 }
 
-static const char *plugin_program_name;
-
-void
-bfd_plugin_set_program_name (const char *program_name)
-{
-  plugin_program_name = program_name;
-}
-
 int
 bfd_plugin_open_input (bfd *ibfd, struct ld_plugin_input_file *file)
 {
index 9d2139a..06c19e2 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef _PLUGIN_H_
 #define _PLUGIN_H_
 
-void bfd_plugin_set_program_name (const char *);
+void bfd_plugin_set_program_name (const char *, int);
 int bfd_plugin_open_input (bfd *, struct ld_plugin_input_file *);
 void bfd_plugin_set_plugin (const char *);
 bfd_boolean bfd_plugin_target_p (const bfd_target *);
index d0e7778..7e4dafd 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-25  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/25584
+       * ar.c (main): Pass 0 to bfd_plugin_set_program_name.
+       * nm.c (main): Pass 1 to bfd_plugin_set_program_name.
+
 2019-10-12  Nick Clifton  <nickc@redhat.com>
 
        Release 2.33.1
index 44a4d8f..bb8a19a 100644 (file)
@@ -713,7 +713,7 @@ main (int argc, char **argv)
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 #if BFD_SUPPORTS_PLUGINS
-  bfd_plugin_set_program_name (program_name);
+  bfd_plugin_set_program_name (program_name, 0);
 #endif
 
   expandargv (&argc, &argv);
index f987fae..1f6247f 100644 (file)
@@ -1699,7 +1699,7 @@ main (int argc, char **argv)
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 #if BFD_SUPPORTS_PLUGINS
-  bfd_plugin_set_program_name (program_name);
+  bfd_plugin_set_program_name (program_name, 1);
 #endif
 
   START_PROGRESS (program_name, 0);