summaryrefslogtreecommitdiff
path: root/lto-plugin
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2018-05-30 18:34:54 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2018-05-30 16:34:54 +0000
commitde54061dccca2c469bc77502743f8a0e0aa49287 (patch)
treed7aa0117be471f20bd08ddc22d5a32a969955e08 /lto-plugin
parent3d63e711a882a42e2812e680ff0b8285f508a5ed (diff)
lto-plugin.c: (non_claimed_files): New static var.
* lto-plugin.c: (non_claimed_files): New static var. (linker_ouput_known): New static var. (all_symbols_read_handler): When user specifies linker output do not imply it; output warning when nonlto-rel mode is forced. (claim_file_header): Record number of nonclaimed files. (process_option): Remember if linker output is known From-SVN: r260960
Diffstat (limited to 'lto-plugin')
-rw-r--r--lto-plugin/ChangeLog9
-rw-r--r--lto-plugin/lto-plugin.c62
2 files changed, 50 insertions, 21 deletions
diff --git a/lto-plugin/ChangeLog b/lto-plugin/ChangeLog
index 04dc03c0751..c3a08236831 100644
--- a/lto-plugin/ChangeLog
+++ b/lto-plugin/ChangeLog
@@ -1,3 +1,12 @@
+2018-05-30 Jan Hubicka <jh@suse.cz>
+
+ * lto-plugin.c: (non_claimed_files): New static var.
+ (linker_ouput_known): New static var.
+ (all_symbols_read_handler): When user specifies linker output do not
+ imply it; output warning when nonlto-rel mode is forced.
+ (claim_file_header): Record number of nonclaimed files.
+ (process_option): Remember if linker output is known
+
2018-04-18 David Malcolm <dmalcolm@redhat.com>
PR jit/85384
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index bf9f6a04ae4..2361fe55803 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -27,10 +27,13 @@ along with this program; see the file COPYING3. If not see
More information at http://gcc.gnu.org/wiki/whopr/driver.
This plugin should be passed the lto-wrapper options and will forward them.
- It also has 2 options of its own:
+ It also has options at his own:
-debug: Print the command line used to run lto-wrapper.
-nop: Instead of running lto-wrapper, pass the original to the plugin. This
- only works if the input files are hybrid. */
+ only works if the input files are hybrid.
+ -linker-output-known: Do not determine linker output
+ -sym-style={none,win32,underscore|uscore}
+ -pass-through */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -159,6 +162,7 @@ static ld_plugin_add_symbols add_symbols;
static struct plugin_file_info *claimed_files = NULL;
static unsigned int num_claimed_files = 0;
+static unsigned int non_claimed_files = 0;
/* List of files with offloading. */
static struct plugin_offload_file *offload_files;
@@ -185,6 +189,7 @@ static char nop;
static char *resolution_file = NULL;
static enum ld_plugin_output_file_type linker_output;
static int linker_output_set;
+static int linker_output_known;
/* The version of gold being used, or -1 if not gold. The number is
MAJOR * 100 + MINOR. */
@@ -637,7 +642,8 @@ static enum ld_plugin_status
all_symbols_read_handler (void)
{
unsigned i;
- unsigned num_lto_args = num_claimed_files + lto_wrapper_num_args + 3;
+ unsigned num_lto_args = num_claimed_files + lto_wrapper_num_args + 2
+ + !linker_output_known;
char **lto_argv;
const char *linker_output_str = NULL;
const char **lto_arg_ptr;
@@ -661,26 +667,37 @@ all_symbols_read_handler (void)
for (i = 0; i < lto_wrapper_num_args; i++)
*lto_arg_ptr++ = lto_wrapper_argv[i];
- assert (linker_output_set);
- switch (linker_output)
+ if (!linker_output_known)
{
- case LDPO_REL:
- linker_output_str = "-flinker-output=rel";
- break;
- case LDPO_DYN:
- linker_output_str = "-flinker-output=dyn";
- break;
- case LDPO_PIE:
- linker_output_str = "-flinker-output=pie";
- break;
- case LDPO_EXEC:
- linker_output_str = "-flinker-output=exec";
- break;
- default:
- message (LDPL_FATAL, "unsupported linker output %i", linker_output);
- break;
+ assert (linker_output_set);
+ switch (linker_output)
+ {
+ case LDPO_REL:
+ if (non_claimed_files)
+ {
+ message (LDPL_WARNING, "incremental linking of LTO and non-LTO "
+ "objects; using -flinker-output=nolto-rel which will "
+ "bypass whole program optimization");
+ linker_output_str = "-flinker-output=nolto-rel";
+ }
+ else
+ linker_output_str = "-flinker-output=rel";
+ break;
+ case LDPO_DYN:
+ linker_output_str = "-flinker-output=dyn";
+ break;
+ case LDPO_PIE:
+ linker_output_str = "-flinker-output=pie";
+ break;
+ case LDPO_EXEC:
+ linker_output_str = "-flinker-output=exec";
+ break;
+ default:
+ message (LDPL_FATAL, "unsupported linker output %i", linker_output);
+ break;
+ }
+ *lto_arg_ptr++ = xstrdup (linker_output_str);
}
- *lto_arg_ptr++ = xstrdup (linker_output_str);
if (num_offload_files > 0)
{
@@ -1108,6 +1125,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
goto cleanup;
err:
+ non_claimed_files++;
free (lto_file.name);
cleanup:
@@ -1122,6 +1140,8 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
static void
process_option (const char *option)
{
+ if (strcmp (option, "-linker-output-known") == 0)
+ linker_output_known = 1;
if (strcmp (option, "-debug") == 0)
debug = 1;
else if (strcmp (option, "-nop") == 0)