summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-03 17:03:38 +0000
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-03 17:03:38 +0000
commit50ca7c37d48ffd4d930263e44fa166af53931556 (patch)
tree12c1666e709c28de90b30106f5254dc8d2850417
parent6fa5613817047cd67068c5750e689ed5a50ec01e (diff)
downloadgcc-50ca7c37d48ffd4d930263e44fa166af53931556.tar.gz
Pass -dumpbase and -dumpdir to gcc for LTO
gcc/ 2010-01-03 H.J. Lu <hongjiu.lu@intel.com> PR lto/41564 * common.opt: Add dumpdir. * gcc.c (cc1_options): Add "-dumpbase %B" only if -dumpbase isn't specified. (option_map): Add --dumpdir. * gcc.h (DEFAULT_WORD_SWITCH_TAKES_ARG): Add dumpdir. * lto-wrapper.c (run_gcc): Add -dumpbase and -dumpdir for -o. * opts.c (decode_options): Try dump_dir_name first if dump_base_name isn't an absolute path. (common_handle_option): Handle OPT_dumpdir. * toplev.c (dump_dir_name): New. (print_switch_values): Also ignore -dumpdir. * toplev.h (dump_dir_name): New. gcc/lto/ 2010-01-03 H.J. Lu <hongjiu.lu@intel.com> PR lto/41564 * lto.c (DUMPBASE_SUFFIX): New. (lto_execute_ltrans): Append a sequence number to -dumpbase for LTRANS. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155591 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog22
-rw-r--r--gcc/common.opt6
-rw-r--r--gcc/gcc.c6
-rw-r--r--gcc/gcc.h5
-rw-r--r--gcc/lto-wrapper.c30
-rw-r--r--gcc/lto/ChangeLog7
-rw-r--r--gcc/lto/lto.c28
-rw-r--r--gcc/opts.c45
-rw-r--r--gcc/toplev.c5
-rw-r--r--gcc/toplev.h6
10 files changed, 130 insertions, 30 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cb0ecfa8fea..414dc2c56b4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-03 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR lto/41564
+ * common.opt: Add dumpdir.
+
+ * gcc.c (cc1_options): Add "-dumpbase %B" only if -dumpbase
+ isn't specified.
+ (option_map): Add --dumpdir.
+
+ * gcc.h (DEFAULT_WORD_SWITCH_TAKES_ARG): Add dumpdir.
+
+ * lto-wrapper.c (run_gcc): Add -dumpbase and -dumpdir for -o.
+
+ * opts.c (decode_options): Try dump_dir_name first if
+ dump_base_name isn't an absolute path.
+ (common_handle_option): Handle OPT_dumpdir.
+
+ * toplev.c (dump_dir_name): New.
+ (print_switch_values): Also ignore -dumpdir.
+
+ * toplev.h (dump_dir_name): New.
+
2010-01-03 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42589
diff --git a/gcc/common.opt b/gcc/common.opt
index 77967f89dfd..ac942ee6a1f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1,6 +1,6 @@
; Options for the language- and target-independent parts of the compiler.
-; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
; Free Software Foundation, Inc.
;
; This file is part of GCC.
@@ -253,6 +253,10 @@ dumpbase
Common Separate
-dumpbase <file> Set the file basename to be used for dumps
+dumpdir
+Common Separate
+-dumpdir <dir> Set the directory name to be used for dumps
+
; The version of the C++ ABI in use. The following values are allowed:
;
; 0: The version of the ABI believed most conformant with the C++ ABI
diff --git a/gcc/gcc.c b/gcc/gcc.c
index ad69de7bd22..068671dd725 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1,6 +1,7 @@
/* Compiler driver program that can handle many languages.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+ 2010
Free Software Foundation, Inc.
This file is part of GCC.
@@ -891,7 +892,7 @@ static const char *cpp_debug_options = "%{d*}";
/* NB: This is shared amongst all front-ends, except for Ada. */
static const char *cc1_options =
"%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
- %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\
+ %1 %{!Q:-quiet} %{!dumpbase:-dumpbase %B} %{d*} %{m*} %{a*}\
%{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} \
%{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \
%{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\
@@ -1188,6 +1189,7 @@ static const struct option_map option_map[] =
{"--dependencies", "-M", 0},
{"--dump", "-d", "a"},
{"--dumpbase", "-dumpbase", "a"},
+ {"--dumpdir", "-dumpdir", "a"},
{"--encoding", "-fencoding=", "aj"},
{"--entry", "-e", 0},
{"--extra-warnings", "-W", 0},
diff --git a/gcc/gcc.h b/gcc/gcc.h
index 560c7f91488..e62b11eafc5 100644
--- a/gcc/gcc.h
+++ b/gcc/gcc.h
@@ -1,5 +1,5 @@
/* Header file for modules that link with gcc.c
- Copyright (C) 1999, 2000, 2001, 2003, 2004, 2007, 2008
+ Copyright (C) 1999, 2000, 2001, 2003, 2004, 2007, 2008, 2010
Free Software Foundation, Inc.
This file is part of GCC.
@@ -52,7 +52,8 @@ struct spec_function
|| !strcmp (STR, "isysroot") \
|| !strcmp (STR, "-param") || !strcmp (STR, "specs") \
|| !strcmp (STR, "MF") || !strcmp (STR, "MT") || !strcmp (STR, "MQ") \
- || !strcmp (STR, "fintrinsic-modules-path") || !strcmp (STR, "dumpbase"))
+ || !strcmp (STR, "fintrinsic-modules-path") \
+ || !strcmp (STR, "dumpbase") || !strcmp (STR, "dumpdir"))
/* These are exported by gcc.c. */
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 5f24f59564d..ec0a96ea2b6 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1,5 +1,5 @@
/* Wrapper to call lto. Used by collect2 and the linker plugin.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
Factored out of collect2 by Rafael Espindola <espindola@google.com>
@@ -258,7 +258,7 @@ run_gcc (unsigned argc, char *argv[])
const char **argv_ptr;
char *list_option_full = NULL;
- new_argc += 8;
+ new_argc += 12;
new_argv = (const char **) xcalloc (sizeof (char *), new_argc);
argv_ptr = new_argv;
@@ -316,7 +316,31 @@ run_gcc (unsigned argc, char *argv[])
temporary file for the LTO output. The `-o' option
will be interpreted by the linker. */
if (s[2] == '\0')
- i++;
+ {
+ char *output_dir, *base, *name;
+
+ i++;
+ output_dir = xstrdup (argv[i]);
+ base = output_dir;
+ for (name = base; *name; name++)
+ if (IS_DIR_SEPARATOR (*name))
+ base = name + 1;
+ *base = '\0';
+
+ *argv_ptr++ = "-dumpbase";
+ if (*output_dir == '\0')
+ {
+ static char current_dir[] =
+ { '.', DIR_SEPARATOR, '\0' };
+ output_dir = current_dir;
+ *argv_ptr++ = argv[i];
+ }
+ else
+ *argv_ptr++ = &argv[i][base - output_dir];
+
+ *argv_ptr++ = "-dumpdir";
+ *argv_ptr++ = output_dir;
+ }
}
else
/* Pass the option or argument to LTO. */
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 2aa86db9d07..92e595fac67 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,10 @@
+2010-01-03 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR lto/41564
+ * lto.c (DUMPBASE_SUFFIX): New.
+ (lto_execute_ltrans): Append a sequence number to -dumpbase
+ for LTRANS.
+
2010-01-02 H.J. Lu <hongjiu.lu@intel.com>
PR lto/42580
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index e62bc02fe48..1608e56e158 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -1,5 +1,5 @@
/* Top-level LTO routines.
- Copyright 2009 Free Software Foundation, Inc.
+ Copyright 2009, 2010 Free Software Foundation, Inc.
Contributed by CodeSourcery, Inc.
This file is part of GCC.
@@ -1069,6 +1069,8 @@ lto_wpa_write_files (void)
return output_files;
}
+/* Template of LTRANS dumpbase suffix. */
+#define DUMPBASE_SUFFIX ".ltrans18446744073709551615"
/* Perform local transformations (LTRANS) on the files in the NULL-terminated
FILES array. These should have been written previously by
@@ -1088,6 +1090,8 @@ lto_execute_ltrans (char *const *files)
int err;
int status;
FILE *ltrans_output_list_stream = NULL;
+ bool seen_dumpbase = false;
+ char *dumpbase_suffix = NULL;
timevar_push (TV_WHOPR_WPA_LTRANS_EXEC);
@@ -1126,13 +1130,26 @@ lto_execute_ltrans (char *const *files)
++j;
obstack_init (&env_obstack);
obstack_grow (&env_obstack, &collect_gcc_options[i], j - i);
- obstack_1grow (&env_obstack, 0);
+ if (seen_dumpbase)
+ obstack_grow (&env_obstack, DUMPBASE_SUFFIX,
+ sizeof (DUMPBASE_SUFFIX));
+ else
+ obstack_1grow (&env_obstack, 0);
option = XOBFINISH (&env_obstack, char *);
+ if (seen_dumpbase)
+ {
+ dumpbase_suffix = option + 7 + j - i;
+ seen_dumpbase = false;
+ }
/* LTRANS does not need -fwpa nor -fltrans-*. */
if (strncmp (option, "-fwpa", 5) != 0
&& strncmp (option, "-fltrans-", 9) != 0)
- *argv_ptr++ = option;
+ {
+ if (strncmp (option, "-dumpbase", 9) == 0)
+ seen_dumpbase = true;
+ *argv_ptr++ = option;
+ }
}
*argv_ptr++ = "-fltrans";
@@ -1190,6 +1207,11 @@ lto_execute_ltrans (char *const *files)
argv_ptr[2] = files[i];
argv_ptr[3] = NULL;
+ /* Append a sequence number to -dumpbase for LTRANS. */
+ if (dumpbase_suffix)
+ snprintf (dumpbase_suffix, sizeof (DUMPBASE_SUFFIX) - 7,
+ "%lu", (unsigned long) i);
+
/* Execute the driver. */
pex = pex_init (0, "lto1", NULL);
if (pex == NULL)
diff --git a/gcc/opts.c b/gcc/opts.c
index 540752769bf..4ba0d7fd0bf 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1,5 +1,5 @@
/* Command line option handling.
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Neil Booth.
@@ -971,24 +971,31 @@ decode_options (unsigned int argc, const char **argv)
handle_options (argc, argv, lang_mask);
- /* Make DUMP_BASE_NAME relative to the AUX_BASE_NAME directory,
- typically the directory to contain the object file. */
- if (aux_base_name && ! IS_ABSOLUTE_PATH (dump_base_name))
+ if (dump_base_name && ! IS_ABSOLUTE_PATH (dump_base_name))
{
- const char *aux_base;
-
- base_of_path (aux_base_name, &aux_base);
- if (aux_base_name != aux_base)
+ /* First try to make DUMP_BASE_NAME relative to the DUMP_DIR_NAME
+ directory. Then try to make DUMP_BASE_NAME relative to the
+ AUX_BASE_NAME directory, typically the directory to contain
+ the object file. */
+ if (dump_dir_name)
+ dump_base_name = concat (dump_dir_name, dump_base_name, NULL);
+ else if (aux_base_name)
{
- int dir_len = aux_base - aux_base_name;
- char *new_dump_base_name =
- XNEWVEC (char, strlen(dump_base_name) + dir_len + 1);
-
- /* Copy directory component from AUX_BASE_NAME. */
- memcpy (new_dump_base_name, aux_base_name, dir_len);
- /* Append existing DUMP_BASE_NAME. */
- strcpy (new_dump_base_name + dir_len, dump_base_name);
- dump_base_name = new_dump_base_name;
+ const char *aux_base;
+
+ base_of_path (aux_base_name, &aux_base);
+ if (aux_base_name != aux_base)
+ {
+ int dir_len = aux_base - aux_base_name;
+ char *new_dump_base_name =
+ XNEWVEC (char, strlen(dump_base_name) + dir_len + 1);
+
+ /* Copy directory component from AUX_BASE_NAME. */
+ memcpy (new_dump_base_name, aux_base_name, dir_len);
+ /* Append existing DUMP_BASE_NAME. */
+ strcpy (new_dump_base_name + dir_len, dump_base_name);
+ dump_base_name = new_dump_base_name;
+ }
}
}
@@ -1701,6 +1708,10 @@ common_handle_option (size_t scode, const char *arg, int value,
dump_base_name = arg;
break;
+ case OPT_dumpdir:
+ dump_dir_name = arg;
+ break;
+
case OPT_falign_functions_:
align_functions = value;
break;
diff --git a/gcc/toplev.c b/gcc/toplev.c
index e916c8de88c..224b28892d2 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -152,6 +152,10 @@ struct line_maps *line_table;
const char *dump_base_name;
+/* Directory used for dump output files. */
+
+const char *dump_dir_name;
+
/* Name to use as a base for auxiliary output files. */
const char *aux_base_name;
@@ -1388,6 +1392,7 @@ print_switch_values (print_switch_fn_type print_fn)
/* Ignore these. */
if (strcmp (*p, "-o") == 0
|| strcmp (*p, "-dumpbase") == 0
+ || strcmp (*p, "-dumpdir") == 0
|| strcmp (*p, "-auxbase") == 0)
{
if (p[1] != NULL)
diff --git a/gcc/toplev.h b/gcc/toplev.h
index 53f981c7141..983022eff69 100644
--- a/gcc/toplev.h
+++ b/gcc/toplev.h
@@ -1,6 +1,7 @@
/* toplev.h - Various declarations for functions found in toplev.c
- Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008,
- 2009 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
+ 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of GCC.
@@ -116,6 +117,7 @@ extern unsigned local_tick;
extern const char *progname;
extern const char *dump_base_name;
+extern const char *dump_dir_name;
extern const char *aux_base_name;
extern const char *aux_info_file_name;
extern const char *profile_data_prefix;