* gold/gold.cc (queue_initial_tasks): Move option checks ...
authorCary Coutant <ccoutant@google.com>
Mon, 26 Sep 2011 23:42:06 +0000 (23:42 +0000)
committerCary Coutant <ccoutant@google.com>
Mon, 26 Sep 2011 23:42:06 +0000 (23:42 +0000)
* gold/options.cc (General_options::finalize): ... to here. Disable
some options; make others fatal.

gold/ChangeLog
gold/gold.cc
gold/options.cc

index 6740d8290e0ca12be978d3e41d076f312c9d2097..f216595fbbefaa6821f26224744a42a472bf91e5 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-26  Cary Coutant  <ccoutant@google.com>
+
+       * gold/gold.cc (queue_initial_tasks): Move option checks ...
+       * gold/options.cc (General_options::finalize): ... to here. Disable
+       some options; make others fatal.
+
 2011-09-26  Cary Coutant  <ccoutant@google.com>
 
        gcc PR lto/47247
index 12f25b7c41a8363e4c2c7bb6e23b142d79e9e679..693ff79b28bea1d4b0e3910bc0ccd7d3abd5540c 100644 (file)
@@ -197,46 +197,29 @@ queue_initial_tasks(const General_options& options,
   // For incremental links, the base output file.
   Incremental_binary* ibase = NULL;
 
-  if (parameters->incremental())
-    {
-      if (options.relocatable())
-       gold_error(_("incremental linking is incompatible with -r"));
-      if (options.emit_relocs())
-       gold_error(_("incremental linking is incompatible with --emit-relocs"));
-      if (options.gc_sections())
-       gold_error(_("incremental linking is incompatible with --gc-sections"));
-      if (options.icf_enabled())
-       gold_error(_("incremental linking is incompatible with --icf"));
-      if (options.has_plugins())
-       gold_error(_("incremental linking is incompatible with --plugin"));
-      if (strcmp(options.compress_debug_sections(), "none") != 0)
-       gold_error(_("incremental linking is incompatible with "
-                    "--compress-debug-sections"));
-
-      if (parameters->incremental_update())
+  if (parameters->incremental_update())
+    {
+      Output_file* of = new Output_file(options.output_file_name());
+      if (of->open_base_file(options.incremental_base(), true))
        {
-         Output_file* of = new Output_file(options.output_file_name());
-         if (of->open_base_file(options.incremental_base(), true))
-           {
-             ibase = open_incremental_binary(of);
-             if (ibase != NULL
-                 && ibase->check_inputs(cmdline, layout->incremental_inputs()))
-               ibase->init_layout(layout);
-             else
-               {
-                 delete ibase;
-                 ibase = NULL;
-                 of->close();
-               }
-           }
-         if (ibase == NULL)
+         ibase = open_incremental_binary(of);
+         if (ibase != NULL
+             && ibase->check_inputs(cmdline, layout->incremental_inputs()))
+           ibase->init_layout(layout);
+         else
            {
-             if (set_parameters_incremental_full())
-               gold_info(_("linking with --incremental-full"));
-             else
-               gold_fallback(_("restart link with --incremental-full"));
+             delete ibase;
+             ibase = NULL;
+             of->close();
            }
        }
+      if (ibase == NULL)
+       {
+         if (set_parameters_incremental_full())
+           gold_info(_("linking with --incremental-full"));
+         else
+           gold_fallback(_("restart link with --incremental-full"));
+       }
     }
 
   // Read the input files.  We have to add the symbols to the symbol
index be3264554a416c6eb7b448208b569a0afd4663cd..d91a8343f9feb83c710d3f360f73518ce14d7501 100644 (file)
@@ -1224,6 +1224,37 @@ General_options::finalize()
     gold_fatal(_("Options --incremental-changed, --incremental-unchanged, "
                  "--incremental-unknown require the use of --incremental"));
 
+  // 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.
+
+  if (this->incremental_mode_ != INCREMENTAL_OFF)
+    {
+      if (this->relocatable())
+       gold_fatal(_("incremental linking is not compatible with -r"));
+      if (this->emit_relocs())
+       gold_fatal(_("incremental linking is not compatible with "
+                    "--emit-relocs"));
+      if (this->has_plugins())
+       gold_fatal(_("incremental linking is not compatible with --plugin"));
+      if (this->gc_sections())
+       {
+         gold_warning(_("ignoring --gc-sections for an incremental link"));
+         this->set_gc_sections(false);
+       }
+      if (this->icf_enabled())
+       {
+         gold_warning(_("ignoring --icf for an incremental link"));
+         this->set_icf_status(ICF_NONE);
+       }
+      if (strcmp(this->compress_debug_sections(), "none") != 0)
+       {
+         gold_warning(_("ignoring --compress-debug-sections for an "
+                        "incremental link"));
+         this->set_compress_debug_sections("none");
+       }
+    }
+
   // FIXME: we can/should be doing a lot more sanity checking here.
 }