From Craig Silverstein: Add -O option.
authorIan Lance Taylor <iant@google.com>
Fri, 21 Sep 2007 05:43:33 +0000 (05:43 +0000)
committerIan Lance Taylor <iant@google.com>
Fri, 21 Sep 2007 05:43:33 +0000 (05:43 +0000)
gold/options.cc
gold/options.h

index fc3d7c6..2f83e10 100644 (file)
@@ -244,6 +244,9 @@ options::Command_line_options::options[] =
              &General_options::add_to_search_path),
   GENERAL_ARG('m', NULL, N_("Ignored for compatibility"), NULL, ONE_DASH,
              &General_options::ignore),
+  GENERAL_ARG('O', NULL, N_("Optimize output file size"),
+             N_("-O level"), ONE_DASH,
+             &General_options::set_optimization_level),
   GENERAL_ARG('o', "output", N_("Set output file name"),
              N_("-o FILE, --output FILE"), TWO_DASHES,
              &General_options::set_output_file_name),
@@ -289,6 +292,7 @@ General_options::General_options()
   : export_dynamic_(false),
     dynamic_linker_(NULL),
     search_path_(),
+    optimization_level_(0),
     output_file_name_("a.out"),
     is_relocatable_(false),
     create_eh_frame_hdr_(false),
index f1f21e0..1d0232e 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef GOLD_OPTIONS_H
 #define GOLD_OPTIONS_H
 
+#include <cstdlib>
 #include <list>
 #include <string>
 #include <vector>
@@ -54,6 +55,11 @@ class General_options
   search_path() const
   { return this->search_path_; }
 
+  // -O: optimization level (0: don't try to optimize output size).
+  int
+  optimization_level() const
+  { return this->optimization_level_; }
+
   // -o: Output file name.
   const char*
   output_file_name() const
@@ -110,6 +116,10 @@ class General_options
   { this->search_path_.push_back(arg); }
 
   void
+  set_optimization_level(const char* arg)
+  { this->optimization_level_ = atoi(arg); }
+
+  void
   set_output_file_name(const char* arg)
   { this->output_file_name_ = arg; }
 
@@ -144,6 +154,7 @@ class General_options
   bool export_dynamic_;
   const char* dynamic_linker_;
   Dir_list search_path_;
+  int optimization_level_;
   const char* output_file_name_;
   bool is_relocatable_;
   bool create_eh_frame_hdr_;