(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-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
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
{ "script", DEBUG_SCRIPT },
{ "files", DEBUG_FILES },
{ "relaxation", DEBUG_RELAXATION },
+ { "incremental", DEBUG_INCREMENTAL },
{ "all", DEBUG_ALL }
};
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(),
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;
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
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*)
do_demangle_(false),
plugins_(NULL),
dynamic_list_(),
+ incremental_mode_(INCREMENTAL_OFF),
incremental_disposition_(INCREMENTAL_CHECK),
implicit_incremental_(false),
excluded_libs_(),
"[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"));
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);
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.
// 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.
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)
{
}
// 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;
}
}
+// 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); }
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
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
bool doing_static_link_valid_;
bool doing_static_link_;
int debug_;
+ int incremental_mode_;
Set_parameters_target_once* set_parameters_target_once_;
};
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.
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_,
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_)
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);
}
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 > $@
@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
# 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.