This is the mail archive of the binutils@sourceware.org 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] gold: add --incremental, --incremental-changed, --incremental-unchanged and --incremental-unknown command line options


  This patch adds the incremental command line options. They have no
effect yet. The --incremental-* disposition is stored in the
Input_file_argument. Files added by plug-ins and scripts are always
--incremental-unknowns. The latter causes -lXXX libraries to be always
--incremental-unknown. I can look into it later, but I wanted to show
the patch already in case there are some problems with the approach
and the patch needs to be made differently. Specifying --incremental-*
without --incremental is considered an error.

2009-02-05  Mikolaj Zalewski  <mikolajz@google.com>
       * fileread.cc (Input_file::Input_file): Add
Incremental_disposition argument
       All callers changed
       (Input_file::incremental_disposition): New function
       * options.cc (Incremental_disposition): New enum
       (General_options::parse_incremental_changed): New function
       (General_options::parse_incremental_unchanged): New function
       (General_options::parse_incremental_unknown): New function
       (General_options::finalize): Check for use of --incremental-*
without --incremental
       (Input_arguments::set_incremental_disposition): New function
       * options.h (Input_file_argument::Input_file_argument): Add
Incremental_disposition argument
       All callers changed
       (Input_file_argument::incremental_disposition): New function
       (Input_arguments::Input_arguments): Initialize new field
current_incremental_disposition_
       (Input_arguments::set_incremental_disposition): New function
       (Input_arguments::current_incremental_disposition): New function
From 52113bc30d36a71fcba22fb8ff6c0da90915387e Mon Sep 17 00:00:00 2001
From: Mikolaj Zalewski <mikolajz@dhcp-172-26-79-171.nyc.corp.google.com>
Date: Thu, 5 Feb 2009 15:17:58 -0500
Subject: [PATCH] gold: add support for --incremental, --incremental-changed, --incremental-unchanged and --incremental-unknown options

---
 gold/archive.cc  |    6 +++-
 gold/fileread.cc |   11 +++++++-
 gold/fileread.h  |    6 ++++-
 gold/options.cc  |   49 ++++++++++++++++++++++++++++++++++---
 gold/options.h   |   70 +++++++++++++++++++++++++++++++++++++++++++++++------
 gold/plugin.cc   |    3 +-
 gold/script.cc   |    6 +++-
 7 files changed, 132 insertions(+), 19 deletions(-)

diff --git a/gold/archive.cc b/gold/archive.cc
index b1ba6d9..bfbb235 100644
--- a/gold/archive.cc
+++ b/gold/archive.cc
@@ -480,7 +480,8 @@ Archive::get_file_and_offset(off_t off, Input_objects* input_objects,
         {
           Input_file_argument* input_file_arg =
             new Input_file_argument(member_name->c_str(), false, "", false,
-                                    parameters->options());
+                    parameters->options(),
+                    this->input_file_->incremental_disposition());
           *input_file = new Input_file(input_file_arg);
           if (!(*input_file)->open(parameters->options(), *this->dirpath_,
                                    this->task_))
@@ -500,7 +501,8 @@ Archive::get_file_and_offset(off_t off, Input_objects* input_objects,
   // file as a regular relocatable object file.
   Input_file_argument* input_file_arg =
       new Input_file_argument(member_name->c_str(), false, "", false,
-                              this->input_file_->options());
+                              this->input_file_->options(),
+                              this->input_file_->incremental_disposition());
   *input_file = new Input_file(input_file_arg);
   if (!(*input_file)->open(parameters->options(), *this->dirpath_,
                            this->task_))
diff --git a/gold/fileread.cc b/gold/fileread.cc
index 36eee6c..70faf34 100644
--- a/gold/fileread.cc
+++ b/gold/fileread.cc
@@ -717,7 +717,8 @@ Input_file::Input_file(const Task* task, const char* name,
 {
   this->input_argument_ =
     new Input_file_argument(name, false, "", false,
-			    Position_dependent_options());
+			    Position_dependent_options(),
+			    INCREMENTAL_CHECK);
   bool ok = file_.open(task, name, contents, size);
   gold_assert(ok);
 }
@@ -738,6 +739,14 @@ Input_file::name() const
   return this->input_argument_->name();
 }
 
+// Return the incremental disposition for this file given by the user.
+
+Incremental_disposition
+Input_file::incremental_disposition() const
+{
+  return this->input_argument_->incremental_disposition();
+}
+
 // Return whether we are only reading symbols.
 
 bool
diff --git a/gold/fileread.h b/gold/fileread.h
index 3afba86..272e464 100644
--- a/gold/fileread.h
+++ b/gold/fileread.h
@@ -30,13 +30,13 @@
 #include <string>
 #include <vector>
 
+#include "options.h"
 #include "token.h"
 
 namespace gold
 {
 
 class Position_dependent_options;
-class Input_file_argument;
 class Dirsearch;
 class File_view;
 
@@ -440,6 +440,10 @@ class Input_file
   const char*
   name() const;
 
+  // Return the incremental disposition for this file given by the user.
+  Incremental_disposition
+  incremental_disposition() const;
+
   // Return the file name.  For -lc this will return something like
   // "/usr/lib/libc.so".
   const std::string&
diff --git a/gold/options.cc b/gold/options.cc
index ff9bd41..750a3a3 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -290,10 +290,35 @@ General_options::parse_defsym(const char*, const char* arg,
 }
 
 void
+General_options::parse_incremental_changed(const char*, const char*,
+                                           Command_line* cmdline)
+{
+  this->implicit_incremental_ = true;
+  cmdline->inputs().set_incremental_disposition(INCREMENTAL_CHANGED);
+}
+
+void
+General_options::parse_incremental_unchanged(const char*, const char*,
+                                             Command_line* cmdline)
+{
+  this->implicit_incremental_ = true;
+  cmdline->inputs().set_incremental_disposition(INCREMENTAL_UNCHANGED);
+}
+
+void
+General_options::parse_incremental_unknown(const char*, const char*,
+                                           Command_line* cmdline)
+{
+  this->implicit_incremental_ = true;
+  cmdline->inputs().set_incremental_disposition(INCREMENTAL_CHECK);
+}
+
+void
 General_options::parse_library(const char*, const char* arg,
                                Command_line* cmdline)
 {
-  Input_file_argument file(arg, true, "", false, *this);
+  Input_file_argument file(arg, true, "", false, *this,
+      cmdline->inputs().current_incremental_disposition());
   cmdline->inputs().add_file(file);
 }
 
@@ -330,7 +355,8 @@ void
 General_options::parse_just_symbols(const char*, const char* arg,
                                     Command_line* cmdline)
 {
-  Input_file_argument file(arg, false, "", true, *this);
+  Input_file_argument file(arg, false, "", true, *this,
+      cmdline->inputs().current_incremental_disposition());
   cmdline->inputs().add_file(file);
 }
 
@@ -621,7 +647,7 @@ namespace gold
 
 General_options::General_options()
   : execstack_status_(General_options::EXECSTACK_FROM_INPUT), static_(false),
-    do_demangle_(false), plugins_()
+    do_demangle_(false), plugins_(), implicit_incremental_(false)
 {
 }
 
@@ -839,6 +865,10 @@ General_options::finalize()
 		 "[0.0, 1.0)"),
 	       this->hash_bucket_empty_fraction());
 
+  if (this->implicit_incremental_ && !this->incremental())
+    gold_fatal(_("Options --incremental-changed, --incremental-unchanged, "
+                 "--incremental-unknown require the use of --incremental"));
+
   // FIXME: we can/should be doing a lot more sanity checking here.
 }
 
@@ -918,6 +948,16 @@ Input_arguments::end_group()
   this->in_group_ = false;
 }
 
+// Specify what incremental build action should be applied to the following
+// files.
+
+void
+Input_arguments::set_incremental_disposition(
+    Incremental_disposition disposition)
+{
+  this->current_incremental_disposition_ = disposition;
+}
+
 // Command_line options.
 
 Command_line::Command_line()
@@ -988,7 +1028,8 @@ Command_line::process(int argc, const char** argv)
       if (no_more_options || argv[i][0] != '-')
         {
           Input_file_argument file(argv[i], false, "", false,
-                                   this->position_options_);
+              this->position_options_,
+              this->inputs_.current_incremental_disposition());
           this->inputs_.add_file(file);
           ++i;
         }
diff --git a/gold/options.h b/gold/options.h
index b980281..eed62fe 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -56,6 +56,19 @@ class Position_dependent_options;
 class Target;
 class Plugin_manager;
 
+
+// Incremental build action for a specific file, as selected by the user.
+
+enum Incremental_disposition
+{
+  // Determine the status from the timestamp (default).
+  INCREMENTAL_CHECK,
+  // Assume the file changed from the previous build.
+  INCREMENTAL_CHANGED,
+  // Assume the file didn't change from the previous build.
+  INCREMENTAL_UNCHANGED
+};
+
 // The nested namespace is to contain all the global variables and
 // structs that need to be defined in the .h file, but do not need to
 // be used outside this class.
@@ -660,6 +673,19 @@ 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_changed, options::TWO_DASHES, '\0',
+                 N_("Assume files changed"), NULL);
+
+  DEFINE_special(incremental_unchanged, options::TWO_DASHES, '\0',
+                 N_("Assume files didn't change"), NULL);
+
+  DEFINE_special(incremental_unknown, options::TWO_DASHES, '\0',
+                 N_("Use timestamps to check files (default)"), NULL);
+
   DEFINE_special(just_symbols, options::TWO_DASHES, '\0',
                  N_("Read only symbol values from FILE"), N_("FILE"));
 
@@ -769,11 +795,11 @@ class General_options
                  N_("Do not link against shared libraries"), NULL);
 
   DEFINE_bool(gc_sections, options::TWO_DASHES, '\0', false,
-              N_("Remove unused sections"), 
+              N_("Remove unused sections"),
               N_("Don't remove unused sections (default)"));
- 
+
   DEFINE_bool(print_gc_sections, options::TWO_DASHES, '\0', false,
-              N_("List removed unused sections on stderr"), 
+              N_("List removed unused sections on stderr"),
               N_("Do not list removed unused sections"));
 
   DEFINE_bool(stats, options::TWO_DASHES, '\0', false,
@@ -1026,6 +1052,10 @@ 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_;
+  // Wheater we have seen one of the options that require incremental
+  // build (--incremental-changed, --incremental-unchanged or
+  // --incremental-unknown)
+  bool implicit_incremental_;
 };
 
 // The position-dependent options.  We use this to store the state of
@@ -1099,9 +1129,11 @@ class Input_file_argument
   Input_file_argument(const char* name, bool is_lib,
                       const char* extra_search_path,
                       bool just_symbols,
-                      const Position_dependent_options& options)
+                      const Position_dependent_options& options,
+                      Incremental_disposition incremental_disposition)
     : name_(name), is_lib_(is_lib), extra_search_path_(extra_search_path),
-      just_symbols_(just_symbols), options_(options)
+      just_symbols_(just_symbols), options_(options),
+      incremental_disposition_(incremental_disposition)
   { }
 
   // You can also pass in a General_options instance instead of a
@@ -1111,9 +1143,11 @@ class Input_file_argument
   Input_file_argument(const char* name, bool is_lib,
                       const char* extra_search_path,
                       bool just_symbols,
-                      const General_options& options)
+                      const General_options& options,
+                      Incremental_disposition& incremental_disposition)
     : name_(name), is_lib_(is_lib), extra_search_path_(extra_search_path),
-      just_symbols_(just_symbols), options_(options)
+      just_symbols_(just_symbols), options_(options),
+      incremental_disposition_(incremental_disposition)
   { }
 
   const char*
@@ -1147,6 +1181,12 @@ class Input_file_argument
   may_need_search() const
   { return this->is_lib_ || !this->extra_search_path_.empty(); }
 
+  // Return whether, in an incremental build, we should assume the files
+  // changed/didn't change or check it.
+  Incremental_disposition
+  incremental_disposition() const
+  { return this->incremental_disposition_; }
+
  private:
   // We use std::string, not const char*, here for convenience when
   // using script files, so that we do not have to preserve the string
@@ -1156,6 +1196,7 @@ class Input_file_argument
   std::string extra_search_path_;
   bool just_symbols_;
   Position_dependent_options options_;
+  Incremental_disposition incremental_disposition_;
 };
 
 // A file or library, or a group, from the command line.
@@ -1253,7 +1294,8 @@ class Input_arguments
   typedef Input_argument_list::const_iterator const_iterator;
 
   Input_arguments()
-    : input_argument_list_(), in_group_(false)
+    : input_argument_list_(), in_group_(false),
+      current_incremental_disposition_(INCREMENTAL_CHECK)
   { }
 
   // Add a file.
@@ -1268,6 +1310,16 @@ class Input_arguments
   void
   end_group();
 
+  // Specify what incremental build action should be applied to the following
+  // files.
+  void
+  set_incremental_disposition(Incremental_disposition disposition);
+
+  // Return the incremental build action that should be applied to current file
+  Incremental_disposition
+  current_incremental_disposition()
+  { return this->current_incremental_disposition_; }
+
   // Return whether we are currently in a group.
   bool
   in_group() const
@@ -1296,6 +1348,8 @@ class Input_arguments
  private:
   Input_argument_list input_argument_list_;
   bool in_group_;
+  // The Incremental_disposition at this point of prasing the command line.
+  Incremental_disposition current_incremental_disposition_;
 };
 
 
diff --git a/gold/plugin.cc b/gold/plugin.cc
index aeddcc1..0d6b907 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -403,7 +403,8 @@ Plugin_manager::release_input_file(unsigned int handle)
 ld_plugin_status
 Plugin_manager::add_input_file(char *pathname)
 {
-  Input_file_argument file(pathname, false, "", false, this->options_);
+  Input_file_argument file(pathname, false, "", false, this->options_,
+      INCREMENTAL_CHECK);
   Input_argument* input_argument = new Input_argument(file);
   Task_token* next_blocker = new Task_token(true);
   next_blocker->add_blocker();
diff --git a/gold/script.cc b/gold/script.cc
index 442c412..90150a1 100644
--- a/gold/script.cc
+++ b/gold/script.cc
@@ -1396,7 +1396,8 @@ read_script_file(const char* filename, Command_line* cmdline,
   Position_dependent_options posdep = cmdline->position_dependent_options();
   if (posdep.format_enum() == General_options::OBJECT_FORMAT_BINARY)
     posdep.set_format_enum(General_options::OBJECT_FORMAT_ELF);
-  Input_file_argument input_argument(filename, false, "", false, posdep);
+  Input_file_argument input_argument(filename, false, "", false, posdep,
+      INCREMENTAL_CHECK);
   Input_file input_file(&input_argument);
   if (!input_file.open(cmdline->options(), dirsearch, task))
     return false;
@@ -2109,7 +2110,8 @@ script_add_file(void* closurev, const char* name, size_t length)
     }
 
   Input_file_argument file(name_string.c_str(), false, extra_search_path,
-			   false, closure->position_dependent_options());
+			   false, closure->position_dependent_options(),
+			   INCREMENTAL_CHECK);
   closure->inputs()->add_file(file);
 }
 
-- 
1.5.4.5


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