This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Having the driver output environment variables when using -v -v?
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 23 Aug 2007 17:44:15 +0100
- Subject: Having the driver output environment variables when using -v -v?
Hi all,
As part of a recent debugging, I modified gcc/gcc.c so that when -v is
used twice, environment variables modification are output, such as:
$ gfortran.exe -v -v a.f90
Driving: C:\msys\1.0.10\home\FX\irun\mingw\bin\gfortran.exe -v -v
a.f90 -lgfortranbegin -lgfortran
Using built-in specs.
Target: i386-pc-mingw32
Configured with: ../trunk/configure --prefix=/mingw
--enable-languages=c,fortran --with-gmp=/home/FX/local
--with-ld=/mingw/bin/ld --with-as=/mingw/bin/as --disable-werror
--enable-bootstrap --enable-threads --disable-nls
--build=i386-pc-mingw32 --enable-libgomp
Thread model: win32
gcc version 4.3.0 20070822 (experimental) (GCC)
Setting environment variable COLLECT_GCC_OPTIONS='-v' '-v' '-mtune=i386'
c:/msys/1.0.10/home/fx/irun/mingw/bin/../libexec/gcc/i386-pc-mingw32/4.3.0/f951.exe
a.f90 -quiet -dumpbase a.f90 -mtune=i386 -auxbase a -version
-fintrinsic-modules-path
c:/msys/1.0.10/home/fx/irun/mingw/bin/../lib/gcc/i386-pc-mingw32/4.3.0/finclude
-o C:/DOCUME~1/FX/LOCALS~1/Temp/ccpEQksF.s
[...]
I thought it would be nice to have in mainline; what do you think?
FX
Index: gcc.c
===================================================================
--- gcc.c (revision 127707)
+++ gcc.c (working copy)
@@ -2632,7 +2632,12 @@
putenv_from_prefixes (const struct path_prefix *paths, const char *env_var,
bool do_multi)
{
- putenv (build_search_list (paths, env_var, true, do_multi));
+ const char *str;
+
+ str = build_search_list (paths, env_var, true, do_multi);
+ putenv (str);
+ if (verbose_flag >= 2)
+ notice ("Setting environment variable %s\n", str);
}
/* Check whether NAME can be accessed in MODE. This is like access,
@@ -3413,7 +3418,12 @@
standard_bindir_prefix,
standard_libexec_prefix);
if (gcc_exec_prefix)
- putenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
+ {
+ const char *str = concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL);
+ putenv (str);
+ if (verbose_flag >= 2)
+ notice ("Setting environment variable %s\n", str);
+ }
}
else
{
@@ -4286,6 +4296,7 @@
{
int i;
int first_time;
+ const char *str;
/* Build COLLECT_GCC_OPTIONS to have all of the options specified to
the compiler. */
@@ -4332,7 +4343,10 @@
}
}
obstack_grow (&collect_obstack, "\0", 1);
- putenv (XOBFINISH (&collect_obstack, char *));
+ str = XOBFINISH (&collect_obstack, char *);
+ putenv (str);
+ if (verbose_flag >= 2)
+ notice ("Setting environment variable %s\n", str);
}
/* Process a spec string, accumulating and running commands. */
@@ -6118,6 +6132,7 @@
int num_linker_inputs = 0;
char *explicit_link_files;
char *specs_file;
+ const char *str;
const char *p;
struct user_specs *uptr;
char **old_argv = argv;
@@ -6218,11 +6233,16 @@
obstack_init (&collect_obstack);
obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=") - 1);
obstack_grow (&collect_obstack, argv[0], strlen (argv[0]) + 1);
- putenv (XOBFINISH (&collect_obstack, char *));
+ str = XOBFINISH (&collect_obstack, char *);
+ putenv (str);
+ if (verbose_flag >= 2)
+ notice ("Setting environment variable %s\n", str);
#ifdef INIT_ENVIRONMENT
/* Set up any other necessary machine specific environment variables. */
putenv (INIT_ENVIRONMENT);
+ if (verbose_flag >= 2)
+ notice ("Setting environment variable %s\n", INIT_ENVIRONMENT);
#endif
/* Make a table of what switches there are (switches, n_switches).