This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
-d options and --save-temps
- From: Matthew Woodcraft <mattheww at chiark dot greenend dot org dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 12 May 2002 18:50:25 +0100
- Subject: -d options and --save-temps
There's trouble trying to use certain debugging dump options with
--save-temps. Eg,
% gcc --save-temps -dM file.c
/usr/lib/gcc-lib/i386-linux/3.0.4/../../../crt1.o: In function `_start':
/usr/lib/gcc-lib/i386-linux/3.0.4/../../../crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
The problem is that as well as -dM going to cc1 for the main
compilation, it gets passed to the preprocessor, to which it means
something quite different. I see essentially this behaviour with all
versions back to at least 2.95.
I think the best solution is for the driver to pass "-d" options to the
preprocessor only in circumstances when it's not going to carry on and
compile the preprocessor's output -- most of the "-d" options to the
preprocessor result in uncompilable output anyway.
This is what I'm running locally.
-M-
* gcc.c (cpp_unique_options): remove "-d" options.
(cpp_debug_options): new spec string.
(default_compilers): use cpp_debug_options.
* cp/lang-specs.h, f/lang_specs.h, objc/lang_specs.h:
Use cpp_debug_options.
Index: gcc/gcc.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.313
diff -u -d -c -3 -p -r1.313 gcc.c
*** gcc/gcc.c 9 May 2002 22:48:33 -0000 1.313
--- gcc/gcc.c 12 May 2002 14:21:07 -0000
*************** static const char *cpp_unique_options =
*** 690,701 ****
/* This contains cpp options which are common with cc1_options and are passed
only when preprocessing only to avoid duplication. */
static const char *cpp_options =
! "%(cpp_unique_options) %{std*} %{d*} %{W*&pedantic*} %{w}\
%{fshow-column} %{fno-show-column}\
%{fsigned-char&funsigned-char}\
%{fleading-underscore} %{fno-leading-underscore}\
%{fno-operator-names} %{ftabstop=*}";
/* NB: This is shared amongst all front-ends. */
static const char *cc1_options =
"%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
--- 690,705 ----
/* This contains cpp options which are common with cc1_options and are passed
only when preprocessing only to avoid duplication. */
static const char *cpp_options =
! "%(cpp_unique_options) %{std*} %{W*&pedantic*} %{w}\
%{fshow-column} %{fno-show-column}\
%{fsigned-char&funsigned-char}\
%{fleading-underscore} %{fno-leading-underscore}\
%{fno-operator-names} %{ftabstop=*}";
+ /* This contains cpp options which are not passed when the preprocessor output
+ will be used by another program. */
+ static const char *cpp_debug_options = "%{d*}";
+
/* NB: This is shared amongst all front-ends. */
static const char *cc1_options =
"%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
*************** static const struct compiler default_com
*** 832,838 ****
{"@c",
/* cc1 has an integrated ISO C preprocessor. We should invoke the
external preprocessor if -save-temps is given. */
! "%{E|M|MM:%(trad_capable_cpp) -lang-c %{ansi:-std=c89} %(cpp_options)}\
%{!E:%{!M:%{!MM:\
%{traditional|ftraditional:\
%eGNU C no longer supports -traditional without -E}\
--- 836,843 ----
{"@c",
/* cc1 has an integrated ISO C preprocessor. We should invoke the
external preprocessor if -save-temps is given. */
! "%{E|M|MM:%(trad_capable_cpp)\
! -lang-c %{ansi:-std=c89} %(cpp_options) %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
%{traditional|ftraditional:\
%eGNU C no longer supports -traditional without -E}\
*************** static const struct compiler default_com
*** 844,854 ****
%{!fsyntax-only:%(invoke_as)}}}}", 0},
{"-",
"%{!E:%e-E required when input is from standard input}\
! %(trad_capable_cpp) -lang-c %{ansi:-std=c89} %(cpp_options)", 0},
{".h", "@c-header", 0},
{"@c-header",
"%{!E:%ecompilation of header file requested} \
! %(trad_capable_cpp) -lang-c %{ansi:-std=c89} %(cpp_options)", 0},
{".i", "@cpp-output", 0},
{"@cpp-output",
"%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0},
--- 849,861 ----
%{!fsyntax-only:%(invoke_as)}}}}", 0},
{"-",
"%{!E:%e-E required when input is from standard input}\
! %(trad_capable_cpp)\
! -lang-c %{ansi:-std=c89} %(cpp_options) %(cpp_debug_options)", 0},
{".h", "@c-header", 0},
{"@c-header",
"%{!E:%ecompilation of header file requested} \
! %(trad_capable_cpp)\
! -lang-c %{ansi:-std=c89} %(cpp_options) %(cpp_debug_options)", 0},
{".i", "@cpp-output", 0},
{"@cpp-output",
"%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0},
*************** static const struct compiler default_com
*** 858,863 ****
--- 865,871 ----
{".S", "@assembler-with-cpp", 0},
{"@assembler-with-cpp",
"%(trad_capable_cpp) -lang-asm %(cpp_options)\
+ %{E|M|MM:%(cpp_debug_options)}\
%{!M:%{!MM:%{!E:%{!S:-o %{|!pipe:%g.s} |\n\
as %(asm_debug) %(asm_options) %{!pipe:%g.s} %A }}}}", 0},
#include "specs.h"
*************** static struct spec_list static_specs[] =
*** 1369,1374 ****
--- 1377,1383 ----
INIT_STATIC_SPEC ("invoke_as", &invoke_as),
INIT_STATIC_SPEC ("cpp", &cpp_spec),
INIT_STATIC_SPEC ("cpp_options", &cpp_options),
+ INIT_STATIC_SPEC ("cpp_debug_options", &cpp_debug_options),
INIT_STATIC_SPEC ("cpp_unique_options", &cpp_unique_options),
INIT_STATIC_SPEC ("trad_capable_cpp", &trad_capable_cpp),
INIT_STATIC_SPEC ("cc1", &cc1_spec),
Index: gcc/cp/lang-specs.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/lang-specs.h,v
retrieving revision 1.47
diff -u -d -c -3 -p -r1.47 lang-specs.h
*** gcc/cp/lang-specs.h 24 Mar 2002 12:27:42 -0000 1.47
--- gcc/cp/lang-specs.h 12 May 2002 14:21:09 -0000
*************** Boston, MA 02111-1307, USA. */
*** 39,45 ****
%{!Wno-deprecated:-D__DEPRECATED}\
%{!fno-exceptions:-D__EXCEPTIONS}\
-D__GXX_ABI_VERSION=100\
! %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)}\
%{!E:%{!M:%{!MM:\
%{save-temps:cc1plus -E -lang-c++ \
%{!no-gcc:-D__GNUG__=%v1}\
--- 39,46 ----
%{!Wno-deprecated:-D__DEPRECATED}\
%{!fno-exceptions:-D__EXCEPTIONS}\
-D__GXX_ABI_VERSION=100\
! %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)\
! %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
%{save-temps:cc1plus -E -lang-c++ \
%{!no-gcc:-D__GNUG__=%v1}\
Index: gcc/f/lang-specs.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/f/lang-specs.h,v
retrieving revision 1.31
diff -u -d -c -3 -p -r1.31 lang-specs.h
*** gcc/f/lang-specs.h 7 Apr 2002 03:12:23 -0000 1.31
--- gcc/f/lang-specs.h 12 May 2002 14:21:10 -0000
*************** the Free Software Foundation, 59 Temple
*** 28,34 ****
{".fpp", "@f77-cpp-input", 0},
{".FPP", "@f77-cpp-input", 0},
{"@f77-cpp-input",
! "tradcpp0 -lang-fortran %(cpp_options) %{!M:%{!MM:%{!E:%{!pipe:%g.f} |\n\
f771 %{!pipe:%g.f} %(cc1_options) %{I*} %{!fsyntax-only:%(invoke_as)}}}}", 0},
{".r", "@ratfor", 0},
{"@ratfor",
--- 28,36 ----
{".fpp", "@f77-cpp-input", 0},
{".FPP", "@f77-cpp-input", 0},
{"@f77-cpp-input",
! "tradcpp0 -lang-fortran %(cpp_options) \
! %{E|M|MM:%(cpp_debug_options)}\
! %{!M:%{!MM:%{!E:%{!pipe:%g.f} |\n\
f771 %{!pipe:%g.f} %(cc1_options) %{I*} %{!fsyntax-only:%(invoke_as)}}}}", 0},
{".r", "@ratfor", 0},
{"@ratfor",
Index: gcc/objc/lang-specs.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/objc/lang-specs.h,v
retrieving revision 1.23
diff -u -d -c -3 -p -r1.23 lang-specs.h
*** gcc/objc/lang-specs.h 24 Mar 2002 12:27:45 -0000 1.23
--- gcc/objc/lang-specs.h 12 May 2002 14:21:10 -0000
*************** Boston, MA 02111-1307, USA. */
*** 25,31 ****
{"@objective-c",
/* cc1obj has an integrated ISO C preprocessor. We should invoke the
external preprocessor if -save-temps or -traditional is given. */
! "%{E|M|MM:%(trad_capable_cpp) -lang-objc %{ansi:-std=c89} %(cpp_options)}\
%{!E:%{!M:%{!MM:\
%{traditional|ftraditional|traditional-cpp:\
%eGNU Objective C no longer supports traditional compilation}\
--- 25,32 ----
{"@objective-c",
/* cc1obj has an integrated ISO C preprocessor. We should invoke the
external preprocessor if -save-temps or -traditional is given. */
! "%{E|M|MM:%(trad_capable_cpp)\
! -lang-objc %{ansi:-std=c89} %(cpp_options) %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
%{traditional|ftraditional|traditional-cpp:\
%eGNU Objective C no longer supports traditional compilation}\