This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch][rfc] Enabling more optimizations with -ON

In compilers the -ON options enable various optimizations. Different
compilers (and compiler versions) have different ones, but the option
itself is commonly available and selects a somewhat corresponding

In both bfd ld and gold very few optimizations are enabled with the
-ON options. This means that users have to know which optimizations
are available:

ld ...-O3 --gc-sections --icf=safe....

If an optimization is added to one of them, a configure check has to
be used to find if the program is being linked with gold or bfd (and
which version).

As a starting point, the attached patch changes gold to gc sections by
default if given -O3 or higher. It can still be disabled with an
explicit --no-gc-sections.


2014-11-03  Rafael Ãvila de EspÃndola <>

        * (General_options::finalize): Set gc_sections by default
if -O3 or higher is used.
diff --git a/gold/ b/gold/
index 731061d..b704439 100644
--- a/gold/
+++ b/gold/
@@ -1250,6 +1250,9 @@ General_options::finalize()
     gold_fatal(_("Options --incremental-changed, --incremental-unchanged, "
 		 "--incremental-unknown require the use of --incremental"));
+  if (!this->user_set_gc_sections() && this->optimize() >= 3)
+      this->set_gc_sections(true);
   // Check for options that are not compatible with incremental linking.
   // Where an option can be disabled without seriously changing the semantics
   // of the link, we turn the option off; otherwise, we issue a fatal error.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]