* debug.h (DEBUG_INCREMENTAL): New flag.
authorCary Coutant <ccoutant@google.com>
Thu, 14 Oct 2010 22:10:22 +0000 (22:10 +0000)
committerCary Coutant <ccoutant@google.com>
Thu, 14 Oct 2010 22:10:22 +0000 (22:10 +0000)
(debug_string_to_enum): Add DEBUG_INCREMENTAL).
* gold.cc (queue_initial_tasks): Check parameters for incremental link
mode.
* incremental.cc (report_command_line): Ignore all forms of
--incremental.
* layout.cc (Layout::Layout): Check parameters for incremental link
mode.
* options.cc (General_options::parse_incremental): New function.
(General_options::parse_no_incremental): New function.
(General_options::parse_incremental_full): New function.
(General_options::parse_incremental_update): New function.
(General_options::incremental_mode_): New data member.
(General_options::finalize): Check incremental_mode_.
* options.h (General_options): Update help text for --incremental.
Add --no-incremental, --incremental-full, --incremental-update.
(General_options::Incremental_mode): New enum type.
(General_options::incremental_mode): New function.
(General_options::incremental_mode_): New data member.
* parameters.cc (Parameters::incremental_mode_): New data member.
(Parameters::set_options): Set incremental_mode_.
(Parameters::set_incremental_full): New function.
(Parameters::incremental): New function.
(Parameters::incremental_update): New function.
(set_parameters_incremental_full): New function.
* parameters.h (Parameters::set_incremental_full): New function.
(Parameters::incremental): New function.
(Parameters::incremental_update): New function.
(Parameters::incremental_mode_): New data member.
(set_parameters_incremental_full): New function.
* plugin.cc (Plugin_manager::add_input_file): Check parameters for
incremental link mode.
* reloc.cc (Sized_relobj::do_read_relocs): Likewise.
(Sized_relobj::do_relocate_sections): Likewise.
* testsuite/Makefile.am (incremental_test): Use --incremental-full
option.
* testsuite/Makefile.in: Regenerate.
* testsuite/incremental_test.sh: Filter all forms of --incremental.

14 files changed:
gold/ChangeLog
gold/debug.h
gold/gold.cc
gold/incremental.cc
gold/layout.cc
gold/options.cc
gold/options.h
gold/parameters.cc
gold/parameters.h
gold/plugin.cc
gold/reloc.cc
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/incremental_test.sh

index c68e4b2c553bb882e8feb1a2ef8719a0d9402751..0977b3784e0556078daef688035b2afb638176b6 100644 (file)
@@ -1,3 +1,44 @@
+2010-10-14  Cary Coutant  <ccoutant@google.com>
+
+       * debug.h (DEBUG_INCREMENTAL): New flag.
+       (debug_string_to_enum): Add DEBUG_INCREMENTAL).
+       * gold.cc (queue_initial_tasks): Check parameters for incremental link
+       mode.
+       * incremental.cc (report_command_line): Ignore all forms of
+       --incremental.
+       * layout.cc (Layout::Layout): Check parameters for incremental link
+       mode.
+       * options.cc (General_options::parse_incremental): New function.
+       (General_options::parse_no_incremental): New function.
+       (General_options::parse_incremental_full): New function.
+       (General_options::parse_incremental_update): New function.
+       (General_options::incremental_mode_): New data member.
+       (General_options::finalize): Check incremental_mode_.
+       * options.h (General_options): Update help text for --incremental.
+       Add --no-incremental, --incremental-full, --incremental-update.
+       (General_options::Incremental_mode): New enum type.
+       (General_options::incremental_mode): New function.
+       (General_options::incremental_mode_): New data member.
+       * parameters.cc (Parameters::incremental_mode_): New data member.
+       (Parameters::set_options): Set incremental_mode_.
+       (Parameters::set_incremental_full): New function.
+       (Parameters::incremental): New function.
+       (Parameters::incremental_update): New function.
+       (set_parameters_incremental_full): New function.
+       * parameters.h (Parameters::set_incremental_full): New function.
+       (Parameters::incremental): New function.
+       (Parameters::incremental_update): New function.
+       (Parameters::incremental_mode_): New data member.
+       (set_parameters_incremental_full): New function.
+       * plugin.cc (Plugin_manager::add_input_file): Check parameters for
+       incremental link mode.
+       * reloc.cc (Sized_relobj::do_read_relocs): Likewise.
+       (Sized_relobj::do_relocate_sections): Likewise.
+       * testsuite/Makefile.am (incremental_test): Use --incremental-full
+       option.
+       * testsuite/Makefile.in: Regenerate.
+       * testsuite/incremental_test.sh: Filter all forms of --incremental.
+
 2010-10-12  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
 
        * script-sections.h (class Script_sections): Make
index 4b9ef19fe4dd95624a50c5205c82d7e75d3267ed..7fdbee78a2ade8440d06d12ea68a1b0b9c7de919 100644 (file)
@@ -37,9 +37,10 @@ const int DEBUG_TASK = 0x1;
 const int DEBUG_SCRIPT = 0x2;
 const int DEBUG_FILES = 0x4;
 const int DEBUG_RELAXATION = 0x8;
+const int DEBUG_INCREMENTAL = 0x10;
 
 const int DEBUG_ALL = (DEBUG_TASK | DEBUG_SCRIPT | DEBUG_FILES
-                      | DEBUG_RELAXATION);
+                      | DEBUG_RELAXATION | DEBUG_INCREMENTAL);
 
 // Convert a debug string to the appropriate enum.
 inline int
@@ -52,6 +53,7 @@ debug_string_to_enum(const char* arg)
     { "script", DEBUG_SCRIPT },
     { "files", DEBUG_FILES },
     { "relaxation", DEBUG_RELAXATION },
+    { "incremental", DEBUG_INCREMENTAL },
     { "all", DEBUG_ALL }
   };
 
index 74294d769248a64c55a6d9339dc36e5572f9fbf7..6bbf02e4b751c6ce55d2934e878dcb9cdc2a519c 100644 (file)
@@ -178,7 +178,7 @@ queue_initial_tasks(const General_options& options,
     thread_count = cmdline.number_of_input_files();
   workqueue->set_thread_count(thread_count);
 
-  if (cmdline.options().incremental())
+  if (parameters->incremental())
     {
       Incremental_checker incremental_checker(
           parameters->options().output_file_name(),
index 0bd869e8df9bd16c0a2e7701f9921c0aa0c698b3..aa9d7d3a7fe99c9f6e1686ae8cd158622d6a74d2 100644 (file)
@@ -401,7 +401,10 @@ Incremental_inputs::report_command_line(int argc, const char* const* argv)
   for (int i = 1; i < argc; ++i)
     {
       // Adding/removing these options should not result in a full relink.
-      if (strcmp(argv[i], "--incremental-changed") == 0
+      if (strcmp(argv[i], "--incremental") == 0
+         || strcmp(argv[i], "--incremental-full") == 0
+         || strcmp(argv[i], "--incremental-update") == 0
+         || strcmp(argv[i], "--incremental-changed") == 0
          || strcmp(argv[i], "--incremental-unchanged") == 0
          || strcmp(argv[i], "--incremental-unknown") == 0)
         continue;
index b5490d665c06a9a697be18dd22529ce7392da158..2f56d27b2666d84c4f8d9810df7bdfeada1a5ddb 100644 (file)
@@ -218,7 +218,7 @@ Layout::Layout(int number_of_input_files, Script_options* script_options)
   this->special_output_list_.reserve(2);
 
   // Initialize structure needed for an incremental build.
-  if (parameters->options().incremental())
+  if (parameters->incremental())
     this->incremental_inputs_ = new Incremental_inputs;
 
   // The section name pool is worth optimizing in all cases, because
index 21e3f28c296b671b62ba839ce3e7a16115cda7f2..6839ba46f8dd165342070d126de9c6ff22b923a0 100644 (file)
@@ -316,6 +316,34 @@ General_options::parse_defsym(const char*, const char* arg,
   cmdline->script_options().define_symbol(arg);
 }
 
+void
+General_options::parse_incremental(const char*, const char*,
+                                   Command_line*)
+{
+  this->incremental_mode_ = INCREMENTAL_AUTO;
+}
+
+void
+General_options::parse_no_incremental(const char*, const char*,
+                                      Command_line*)
+{
+  this->incremental_mode_ = INCREMENTAL_OFF;
+}
+
+void
+General_options::parse_incremental_full(const char*, const char*,
+                                       Command_line*)
+{
+  this->incremental_mode_ = INCREMENTAL_FULL;
+}
+
+void
+General_options::parse_incremental_update(const char*, const char*,
+                                         Command_line*)
+{
+  this->incremental_mode_ = INCREMENTAL_UPDATE;
+}
+
 void
 General_options::parse_incremental_changed(const char*, const char*,
                                            Command_line*)
@@ -852,6 +880,7 @@ General_options::General_options()
     do_demangle_(false),
     plugins_(NULL),
     dynamic_list_(),
+    incremental_mode_(INCREMENTAL_OFF),
     incremental_disposition_(INCREMENTAL_CHECK),
     implicit_incremental_(false),
     excluded_libs_(),
@@ -1137,7 +1166,7 @@ General_options::finalize()
                 "[0.0, 1.0)"),
               this->hash_bucket_empty_fraction());
 
-  if (this->implicit_incremental_ && !this->incremental())
+  if (this->implicit_incremental_ && this->incremental_mode_ == INCREMENTAL_OFF)
     gold_fatal(_("Options --incremental-changed, --incremental-unchanged, "
                  "--incremental-unknown require the use of --incremental"));
 
index 59e22672a5015c595b8c58e617ef37e66516b31f..7a694a95ce918c4bc5a86ed2d29c204e710cc12c 100644 (file)
@@ -770,9 +770,20 @@ class General_options
   DEFINE_string(dynamic_linker, options::TWO_DASHES, 'I', NULL,
                 N_("Set dynamic linker path"), N_("PROGRAM"));
 
-  DEFINE_bool(incremental, options::TWO_DASHES, '\0', false,
-              N_("Work in progress; do not use"),
-              N_("Do a full build"));
+  DEFINE_special(incremental, options::TWO_DASHES, '\0',
+                N_("Do an incremental link if possible; "
+                   "otherwise, do a full link and prepare output "
+                   "for incremental linking"), NULL);
+
+  DEFINE_special(no_incremental, options::TWO_DASHES, '\0',
+                N_("Do a full link (default)"), NULL);
+
+  DEFINE_special(incremental_full, options::TWO_DASHES, '\0',
+                N_("Do a full link and "
+                   "prepare output for incremental linking"), NULL);
+
+  DEFINE_special(incremental_update, options::TWO_DASHES, '\0',
+                N_("Do an incremental link; exit if not possible"), NULL);
 
   DEFINE_special(incremental_changed, options::TWO_DASHES, '\0',
                  N_("Assume files changed"), NULL);
@@ -1263,6 +1274,25 @@ class General_options
   finalize_dynamic_list()
   { this->dynamic_list_.version_script_info()->finalize(); }
 
+  // The mode selected by the --incremental options.
+  enum Incremental_mode
+  {
+    // No incremental linking (--no-incremental).
+    INCREMENTAL_OFF,
+    // Incremental update only (--incremental-update).
+    INCREMENTAL_UPDATE,
+    // Force a full link, but prepare for subsequent incremental link
+    // (--incremental-full).
+    INCREMENTAL_FULL,
+    // Incremental update if possible, fallback to full link  (--incremental).
+    INCREMENTAL_AUTO
+  };
+
+  // The incremental linking mode.
+  Incremental_mode
+  incremental_mode() const
+  { return this->incremental_mode_; }
+
   // The disposition given by the --incremental-changed,
   // --incremental-unchanged or --incremental-unknown option.  The
   // value may change as we proceed parsing the command line flags.
@@ -1381,6 +1411,8 @@ class General_options
   // script.cc, we store this as a Script_options object, even though
   // we only use a single Version_tree from it.
   Script_options dynamic_list_;
+  // The incremental linking mode.
+  Incremental_mode incremental_mode_;
   // The disposition given by the --incremental-changed,
   // --incremental-unchanged or --incremental-unknown option.  The
   // value may change as we proceed parsing the command line flags.
index 4430388a674a6731f68e972456e807f62c719c10..e04168f924cf9e78a209b0a8108acc3bf9f3d302 100644 (file)
@@ -66,7 +66,7 @@ Set_parameters_target_once set_parameters_target_once(&static_parameters);
 Parameters::Parameters()
    : errors_(NULL), options_(NULL), target_(NULL),
      doing_static_link_valid_(false), doing_static_link_(false),
-     debug_(0),
+     debug_(0), incremental_mode_(General_options::INCREMENTAL_OFF),
      set_parameters_target_once_(&set_parameters_target_once)
  {
  }
@@ -86,6 +86,9 @@ Parameters::set_options(const General_options* options)
   // For speed, we convert the options() debug var from a string to an
   // enum (from debug.h).
   this->debug_ = debug_string_to_enum(this->options().debug());
+  // Set incremental_mode_ based on the value of the --incremental option.
+  // We copy the mode into parameters because it can change based on inputs.
+  this->incremental_mode_ = this->options().incremental_mode();
   // If --verbose is set, it acts as "--debug=files".
   if (options->verbose())
     this->debug_ |= DEBUG_FILES;
@@ -208,6 +211,38 @@ Parameters::check_target_endianness()
     }
 }
 
+// Set the incremental linking mode to INCREMENTAL_FULL.  Used when
+// the linker determines that an incremental update is not possible.
+// Returns false if the incremental mode was INCREMENTAL_UPDATE,
+// indicating that the linker should exit if an update is not possible.
+
+bool
+Parameters::set_incremental_full()
+{
+  gold_assert(this->incremental_mode_ != General_options::INCREMENTAL_OFF);
+  if (this->incremental_mode_ == General_options::INCREMENTAL_UPDATE)
+    return false;
+  this->incremental_mode_ = General_options::INCREMENTAL_FULL;
+  return true;
+}
+
+// Return true if we need to prepare incremental linking information.
+
+bool
+Parameters::incremental() const
+{
+  return this->incremental_mode_ != General_options::INCREMENTAL_OFF;
+}
+
+// Return true if we are doing an incremental update.
+
+bool
+Parameters::incremental_update() const
+{
+  return (this->incremental_mode_ == General_options::INCREMENTAL_UPDATE
+         || this->incremental_mode_ == General_options::INCREMENTAL_AUTO);
+}
+
 void
 set_parameters_errors(Errors* errors)
 { static_parameters.set_errors(errors); }
@@ -227,6 +262,14 @@ void
 set_parameters_doing_static_link(bool doing_static_link)
 { static_parameters.set_doing_static_link(doing_static_link); }
 
+// Set the incremental linking mode to INCREMENTAL_FULL.  Used when
+// the linker determines that an incremental update is not possible.
+// Returns false if the incremental mode was INCREMENTAL_UPDATE,
+// indicating that the linker should exit if an update is not possible.
+bool
+set_parameters_incremental_full()
+{ return static_parameters.set_incremental_full(); }
+
 // Force the target to be valid by using the default.  Use the
 // --oformat option is set; this supports the x86_64 kernel build,
 // which converts a binary file to an object file using -r --format
index 0ca2941e0abbd6788a473df575ba93a0e5523da0..f9022ae1a9661092abba97ca51fc945d094da643 100644 (file)
@@ -144,6 +144,20 @@ class Parameters
   Target_size_endianness
   size_and_endianness() const;
 
+  // Set the incremental linking mode to INCREMENTAL_FULL.  Used when
+  // the linker determines that an incremental update is not possible.
+  // Returns false if the incremental mode was INCREMENTAL_UPDATE,
+  // indicating that the linker should exit if an update is not possible.
+  bool
+  set_incremental_full();
+
+  // Return true if we need to prepare incremental linking information.
+  bool
+  incremental() const;
+
+  // Return true if we are doing an incremental update.
+  bool
+  incremental_update() const;
 
  private:
   void
@@ -160,6 +174,7 @@ class Parameters
   bool doing_static_link_valid_;
   bool doing_static_link_;
   int debug_;
+  int incremental_mode_;
   Set_parameters_target_once* set_parameters_target_once_;
 };
 
@@ -181,6 +196,9 @@ set_parameters_target(Target* target);
 extern void
 set_parameters_doing_static_link(bool doing_static_link);
 
+extern bool
+set_parameters_incremental_full();
+
 // Ensure that the target to be valid by using the default target if
 // necessary.
 
index 2b11cd3dcf8e83eb309798dfb3828e7d22e6e7e3..7dd1fa389f095be66091fc0bfb0380a49d5efffa 100644 (file)
@@ -451,7 +451,7 @@ Plugin_manager::add_input_file(const char* pathname, bool is_lib)
   Input_argument* input_argument = new Input_argument(file);
   Task_token* next_blocker = new Task_token(true);
   next_blocker->add_blocker();
-  if (parameters->options().incremental())
+  if (parameters->incremental())
     gold_error(_("input files added by plug-ins in --incremental mode not "
                 "supported yet"));
   this->workqueue_->queue_soon(new Read_symbols(this->input_objects_,
index 6f2ede7024bb7e09aebbd947373f96d4b83a6ca3..9ffb693b487255a0c03da40d6184bb539f75d8ae 100644 (file)
@@ -303,7 +303,7 @@ Sized_relobj<size, big_endian>::do_read_relocs(Read_relocs_data* rd)
       if (!is_section_allocated
          && !parameters->options().relocatable()
          && !parameters->options().emit_relocs()
-         && !parameters->options().incremental())
+         && !parameters->incremental())
        continue;
 
       if (this->adjust_shndx(shdr.get_sh_link()) != this->symtab_shndx_)
@@ -1000,7 +1000,7 @@ Sized_relobj<size, big_endian>::do_relocate_sections(
            this->emit_relocs(&relinfo, i, sh_type, prelocs, reloc_count,
                              os, output_offset, view, address, view_size,
                              (*pviews)[i].view, (*pviews)[i].view_size);
-         if (parameters->options().incremental())
+         if (parameters->incremental())
            this->incremental_relocs_write(&relinfo, sh_type, prelocs,
                                           reloc_count, os, output_offset, of);
        }
index 24427df20bc152c7f8c8b7bcdd6dda46498b015d..c4e6c038c1a43bd2c0f2e4884078a049b9028014 100644 (file)
@@ -115,7 +115,7 @@ incremental_test_1.o: incremental_test_1.c
 incremental_test_2.o: incremental_test_2.c
        $(COMPILE) -O0 -c -ffunction-sections -g -o $@ $<
 incremental_test: incremental_test_1.o incremental_test_2.o gcctestdir/ld
-       $(LINK) -Bgcctestdir/ -Wl,-incremental incremental_test_1.o incremental_test_2.o -Wl,-debug 2> incremental_test.cmdline
+       $(LINK) -Bgcctestdir/ -Wl,--incremental-full incremental_test_1.o incremental_test_2.o -Wl,-debug 2> incremental_test.cmdline
 incremental_test.stdout: incremental_test ../incremental-dump
        ../incremental-dump incremental_test > $@
 
index ae419b01d2715eb1b74ff18f24cc5fb9b8cbdb8d..d514893816cc9144aa73b3ff820abeab0dd6aa95 100644 (file)
@@ -3785,7 +3785,7 @@ uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@incremental_test_2.o: incremental_test_2.c
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -O0 -c -ffunction-sections -g -o $@ $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@incremental_test: incremental_test_1.o incremental_test_2.o gcctestdir/ld
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,-incremental incremental_test_1.o incremental_test_2.o -Wl,-debug 2> incremental_test.cmdline
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--incremental-full incremental_test_1.o incremental_test_2.o -Wl,-debug 2> incremental_test.cmdline
 @GCC_TRUE@@NATIVE_LINKER_TRUE@incremental_test.stdout: incremental_test ../incremental-dump
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ../incremental-dump incremental_test > $@
 @GCC_TRUE@@NATIVE_LINKER_TRUE@gc_comdat_test_1.o: gc_comdat_test_1.cc 
index 94369d4afbd8e0229801351b92322f9c6c797627..930d7d14cf9ed876d07d8728ef8bf3c6912b7732 100755 (executable)
@@ -50,6 +50,7 @@ check()
 # Extract actual command line from linker's -v output.
 cat incremental_test.cmdline |
   grep "gcctestdir/ld " |
+  sed "s/--incremental[-a-z]* //g" |
   cut -d ' ' -f 2- > actual
 
 # Extract recorded command line from dump of the output file.
This page took 0.038603 seconds and 4 git commands to generate.