lazy_linux 发表于 2015-01-16 10:04

GCC中spec的问题

在gcc/gcc.c中有如下代码:
static const struct compiler default_compilers[] =
{
/* Add lists of suffixes of known languages here.If those languages
   were not present when we built the driver, we will hit these copies
   and be given a more meaningful error than "file not used since
   linking is not done".*/
{".m","#Objective-C", 0, 0, 0}, {".mi","#Objective-C", 0, 0, 0},
{".mm", "#Objective-C++", 0, 0, 0}, {".M", "#Objective-C++", 0, 0, 0},
{".mii", "#Objective-C++", 0, 0, 0},
{".cc", "#C++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0},
{".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0},
{".c++", "#C++", 0, 0, 0}, {".C", "#C++", 0, 0, 0},
{".CPP", "#C++", 0, 0, 0}, {".ii", "#C++", 0, 0, 0},
{".ads", "#Ada", 0, 0, 0}, {".adb", "#Ada", 0, 0, 0},
{".f", "#Fortran", 0, 0, 0}, {".F", "#Fortran", 0, 0, 0},
{".for", "#Fortran", 0, 0, 0}, {".FOR", "#Fortran", 0, 0, 0},
{".ftn", "#Fortran", 0, 0, 0}, {".FTN", "#Fortran", 0, 0, 0},
{".fpp", "#Fortran", 0, 0, 0}, {".FPP", "#Fortran", 0, 0, 0},
{".f90", "#Fortran", 0, 0, 0}, {".F90", "#Fortran", 0, 0, 0},
{".f95", "#Fortran", 0, 0, 0}, {".F95", "#Fortran", 0, 0, 0},
{".f03", "#Fortran", 0, 0, 0}, {".F03", "#Fortran", 0, 0, 0},
{".f08", "#Fortran", 0, 0, 0}, {".F08", "#Fortran", 0, 0, 0},
{".r", "#Ratfor", 0, 0, 0},
{".p", "#Pascal", 0, 0, 0}, {".pas", "#Pascal", 0, 0, 0},
{".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0},
{".zip", "#Java", 0, 0, 0}, {".jar", "#Java", 0, 0, 0},
/* Next come the entries for C.*/
{".c", "@c", 0, 1, 1},
{"@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) %(cpp_options) %(cpp_debug_options)}\
      %{!E:%{!M:%{!MM:\
          %{traditional|ftraditional:\
%eGNU C no longer supports -traditional without -E}\
       %{!combine:\
      %{save-temps|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
      %(cpp_options) -o %{save-temps:%b.i} %{!save-temps:%g.i} \n\
            cc1 -fpreprocessed %{save-temps:%b.i} %{!save-temps:%g.i} \
            %(cc1_options)}\
      %{!save-temps:%{!traditional-cpp:%{!no-integrated-cpp:\
      cc1 %(cpp_unique_options) %(cc1_options)}}}\
          %{!fsyntax-only:%(invoke_as)}} \
      %{combine:\
      %{save-temps|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
      %(cpp_options) -o %{save-temps:%b.i} %{!save-temps:%g.i}}\
      %{!save-temps:%{!traditional-cpp:%{!no-integrated-cpp:\
      cc1 %(cpp_unique_options) %(cc1_options)}}\
                %{!fsyntax-only:%(invoke_as)}}}}}}", 0, 1, 1},
{"-",
   "%{!E:%e-E or -x required when input is from standard input}\
    %(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)", 0, 0, 0},
{".h", "@c-header", 0, 0, 0},
{"@c-header",
   /* cc1 has an integrated ISO C preprocessor.We should invoke the
      external preprocessor if -save-temps is given.*/
   "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\
      %{!E:%{!M:%{!MM:\
          %{save-temps|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
                %(cpp_options) -o %{save-temps:%b.i} %{!save-temps:%g.i} \n\
                  cc1 -fpreprocessed %{save-temps:%b.i} %{!save-temps:%g.i} \
                        %(cc1_options)\
                        -o %g.s %{!o*:--output-pch=%i.gch}\
                        %W{o*:--output-pch=%*}%V}\
          %{!save-temps:%{!traditional-cpp:%{!no-integrated-cpp:\
                cc1 %(cpp_unique_options) %(cc1_options)\
                  -o %g.s %{!o*:--output-pch=%i.gch}\
                  %W{o*:--output-pch=%*}%V}}}}}}", 0, 0, 0},
{".i", "@cpp-output", 0, 1, 0},
{"@cpp-output",
   "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 1, 0},
{".s", "@assembler", 0, 1, 0},
{"@assembler",
   "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 1, 0},
{".sx", "@assembler-with-cpp", 0, 1, 0},
{".S", "@assembler-with-cpp", 0, 1, 0},
{"@assembler-with-cpp",
#ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT
   "%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\
      %{E|M|MM:%(cpp_debug_options)}\
      %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\
       as %(asm_debug) %(asm_options) %|.s %A }}}}"
#else
   "%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\
      %{E|M|MM:%(cpp_debug_options)}\
      %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\
       as %(asm_debug) %(asm_options) %m.s %A }}}}"
#endif
   , 0, 1, 0},

#include "specs.h"   /* Mark end of table.*/
{0, 0, 0, 0, 0}        //结束标识
};

现在的问题是:
1.{".m","#Objective-C", 0, 0, 0}中"#Objective-C"表示什么意思?#有什么特殊意义吗?
2.{".h", "@c-header", 0, 0, 0},
{"@c-header",
   //省略
},
中"@c-header"好像表示的是一个SPEC的“名称”,其中的@符号有什么特殊含义?

上述这些问题需要从哪里获取帮助?请各位指点。

EricFisher 发表于 2015-01-16 11:38

回复 1# lazy_linux

https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html#Spec-Files


   

lazy_linux 发表于 2015-01-16 11:54

回复 2# EricFisher

谢谢版主,看到了如下的描述:


@language:表示该后缀是某个已知语言language的别名,例如:
.ZZ:
@c++
表示.ZZ文件实际上是一个c++的源文件
#name :用来生成“name compiler not installed on this system.”的错误信息。

感谢!
页: [1]
查看完整版本: GCC中spec的问题