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.

From-SVN: r155591
This commit is contained in:
H.J. Lu 2010-01-03 17:03:38 +00:00 committed by H.J. Lu
parent eb07a8f567
commit d7fb0a6db1
10 changed files with 129 additions and 29 deletions

View File

@ -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

View File

@ -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

View File

@ -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},

View File

@ -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. */

View File

@ -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. */

View File

@ -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

View File

@ -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)

View File

@ -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);
const char *aux_base;
/* 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;
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;

View File

@ -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)

View File

@ -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;