📄 spec-files.html
字号:
<br><dt><code>%O</code> <dd>Substitutes the suffix for object files. Note that this ishandled specially when it immediately follows <code>%g, %u, or %U</code>,because of the need for those to form complete file names. Thehandling is such that <code>%O</code> is treated exactly as if it had alreadybeen substituted, except that <code>%g, %u, and %U</code> do not currentlysupport additional <var>suffix</var> characters following <code>%O</code> as they wouldfollowing, for example, <code>.o</code>. <br><dt><code>%p</code> <dd>Substitutes the standard macro predefinitions for thecurrent target machine. Use this when running <code>cpp</code>. <br><dt><code>%P</code> <dd>Like <code>%p</code>, but puts <code>__</code> before and after the name of eachpredefined macro, except for macros that start with <code>__</code> or with<code>_</code><var>L</var><code></code>, where <var>L</var> is an uppercase letter. This is for ISOC. <br><dt><code>%I</code> <dd>Substitute any of <code>-iprefix</code> (made from <code>GCC_EXEC_PREFIX</code>),<code>-isysroot</code> (made from <code>TARGET_SYSTEM_ROOT</code>), and<code>-isystem</code> (made from <code>COMPILER_PATH</code> and <code>-B</code> options)as necessary. <br><dt><code>%s</code> <dd>Current argument is the name of a library or startup file of some sort. Search for that file in a standard list of directories and substitutethe full name found. <br><dt><code>%e</code><var>str</var><code></code> <dd>Print <var>str</var> as an error message. <var>str</var> is terminated by a newline. Use this when inconsistent options are detected. <br><dt><code>%(</code><var>name</var><code>)</code> <dd>Substitute the contents of spec string <var>name</var> at this point. <br><dt><code>%[</code><var>name</var><code>]</code> <dd>Like <code>%(...)</code> but put <code>__</code> around <code>-D</code> arguments. <br><dt><code>%x{</code><var>option</var><code>}</code> <dd>Accumulate an option for <code>%X</code>. <br><dt><code>%X</code> <dd>Output the accumulated linker options specified by <code>-Wl</code> or a <code>%x</code>spec string. <br><dt><code>%Y</code> <dd>Output the accumulated assembler options specified by <code>-Wa</code>. <br><dt><code>%Z</code> <dd>Output the accumulated preprocessor options specified by <code>-Wp</code>. <br><dt><code>%a</code> <dd>Process the <code>asm</code> spec. This is used to compute theswitches to be passed to the assembler. <br><dt><code>%A</code> <dd>Process the <code>asm_final</code> spec. This is a spec string forpassing switches to an assembler post-processor, if such a program isneeded. <br><dt><code>%l</code> <dd>Process the <code>link</code> spec. This is the spec for computing thecommand line passed to the linker. Typically it will make use of the<code>%L %G %S %D and %E</code> sequences. <br><dt><code>%D</code> <dd>Dump out a <code>-L</code> option for each directory that GCC believes mightcontain startup files. If the target supports multilibs then thecurrent multilib directory will be prepended to each of these paths. <br><dt><code>%M</code> <dd>Output the multilib directory with directory separators replaced with<code>_</code>. If multilib directories are not set, or the multilib directory is<code>.</code> then this option emits nothing. <br><dt><code>%L</code> <dd>Process the <code>lib</code> spec. This is a spec string for deciding whichlibraries should be included on the command line to the linker. <br><dt><code>%G</code> <dd>Process the <code>libgcc</code> spec. This is a spec string for decidingwhich GCC support library should be included on the command line to the linker. <br><dt><code>%S</code> <dd>Process the <code>startfile</code> spec. This is a spec for deciding whichobject files should be the first ones passed to the linker. Typicallythis might be a file named <code>crt0.o</code>. <br><dt><code>%E</code> <dd>Process the <code>endfile</code> spec. This is a spec string that specifiesthe last object files that will be passed to the linker. <br><dt><code>%C</code> <dd>Process the <code>cpp</code> spec. This is used to construct the argumentsto be passed to the C preprocessor. <br><dt><code>%c</code> <dd>Process the <code>signed_char</code> spec. This is intended to be usedto tell cpp whether a char is signed. It typically has the definition: <pre class="smallexample"> %{funsigned-char:-D__CHAR_UNSIGNED__} </pre> <br><dt><code>%1</code> <dd>Process the <code>cc1</code> spec. This is used to construct the options to bepassed to the actual C compiler (<code>cc1</code>). <br><dt><code>%2</code> <dd>Process the <code>cc1plus</code> spec. This is used to construct the options to bepassed to the actual C++ compiler (<code>cc1plus</code>). <br><dt><code>%*</code> <dd>Substitute the variable part of a matched option. See below. Note that each comma in the substituted string is replaced bya single space. <br><dt><code>%<S</code> <dd>Remove all occurrences of <code>-S</code> from the command line. Note--thiscommand is position dependent. <code>%</code> commands in the spec stringbefore this one will see <code>-S</code>, <code>%</code> commands in the spec stringafter this one will not. <br><dt><code>%:</code><var>function</var><code>(</code><var>args</var><code>)</code> <dd>Call the named function <var>function</var>, passing it <var>args</var>. <var>args</var> is first processed as a nested spec string, then splitinto an argument vector in the usual fashion. The function returnsa string which is processed as if it had appeared literally as partof the current spec. <p>The following built-in spec functions are provided: <dl><dt><code>if-exists</code> <dd>The <code>if-exists</code> spec function takes one argument, an absolutepathname to a file. If the file exists, <code>if-exists</code> returns thepathname. Here is a small example of its usage: <pre class="smallexample"> *startfile: crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s </pre> <br><dt><code>if-exists-else</code> <dd>The <code>if-exists-else</code> spec function is similar to the <code>if-exists</code>spec function, except that it takes two arguments. The first argument isan absolute pathname to a file. If the file exists, <code>if-exists-else</code>returns the pathname. If it does not exist, it returns the second argument. This way, <code>if-exists-else</code> can be used to select one file or another,based on the existence of the first. Here is a small example of its usage: <pre class="smallexample"> *startfile: crt0%O%s %:if-exists(crti%O%s) \ %:if-exists-else(crtbeginT%O%s crtbegin%O%s) </pre> </dl> <br><dt><code>%{S}</code> <dd>Substitutes the <code>-S</code> switch, if that switch was given to GCC. If that switch was not specified, this substitutes nothing. Note thatthe leading dash is omitted when specifying this option, and it isautomatically inserted if the substitution is performed. Thus the specstring <code>%{foo}</code> would match the command-line option <code>-foo</code>and would output the command line option <code>-foo</code>. <br><dt><code>%W{S}</code> <dd>Like %{<code>S</code>} but mark last argument supplied within as a file to bedeleted on failure. <br><dt><code>%{S*}</code> <dd>Substitutes all the switches specified to GCC whose names startwith <code>-S</code>, but which also take an argument. This is used forswitches like <code>-o</code>, <code>-D</code>, <code>-I</code>, etc. GCC considers <code>-o foo</code> as beingone switch whose names starts with <code>o</code>. %{o*} would substitute thistext, including the space. Thus two arguments would be generated. <br><dt><code>%{S*&T*}</code> <dd>Like %{<code>S</code>*}, but preserve order of <code>S</code> and <code>T</code> options(the order of <code>S</code> and <code>T</code> in the spec is not significant). There can be any number of ampersand-separated variables; for each thewild card is optional. Useful for CPP as <code>%{D*&U*&A*}</code>. <br><dt><code>%{S:X}</code> <dd>Substitutes <code>X</code>, if the <code>-S</code> switch was given to GCC. <br><dt><code>%{!S:X}</code> <dd>Substitutes <code>X</code>, if the <code>-S</code> switch was <em>not</em> given to GCC. <br><dt><code>%{S*:X}</code> <dd>Substitutes <code>X</code> if one or more switches whose names start with<code>-S</code> are specified to GCC. Normally <code>X</code> is substituted onlyonce, no matter how many such switches appeared. However, if <code>%*</code>appears somewhere in <code>X</code>, then <code>X</code> will be substituted oncefor each matching switch, with the <code>%*</code> replaced by the part ofthat switch that matched the <code>*</code>. <br><dt><code>%{.S:X}</code> <dd>Substitutes <code>X</code>, if processing a file with suffix <code>S</code>. <br><dt><code>%{!.S:X}</code> <dd>Substitutes <code>X</code>, if <em>not</em> processing a file with suffix <code>S</code>. <br><dt><code>%{S|P:X}</code> <dd>Substitutes <code>X</code> if either <code>-S</code> or <code>-P</code> was given to GCC. This may be combined with <code>!</code>, <code>.</code>, and <code>*</code> sequences as well,although they have a stronger binding than the <code>|</code>. If <code>%*</code>appears in <code>X</code>, all of the alternatives must be starred, and onlythe first matching alternative is substituted. <p>For example, a spec string like this: <pre class="smallexample"> %{.c:-foo} %{!.c:-bar} %{.c|d:-baz} %{!.c|d:-boggle} </pre> <p>will output the following command-line options from the following inputcommand-line options: <pre class="smallexample"> fred.c -foo -baz jim.d -bar -boggle -d fred.c -foo -baz -boggle -d jim.d -bar -baz -boggle </pre> <br><dt><code>%{S:X; T:Y; :D}</code> <dd>If <code>S</code> was given to GCC, substitutes <code>X</code>; else if <code>T</code> wasgiven to GCC, substitutes <code>Y</code>; else substitutes <code>D</code>. There canbe as many clauses as you need. This may be combined with <code>.</code>,<code>!</code>, <code>|</code>, and <code>*</code> as needed. </dl> <p>The conditional text <code>X</code> in a %{<code>S</code>:<code>X</code>} or similarconstruct may contain other nested <code>%</code> constructs or spaces, oreven newlines. They are processed as usual, as described above. Trailing white space in <code>X</code> is ignored. White space may alsoappear anywhere on the left side of the colon in these constructs,except between <code>.</code> or <code>*</code> and the corresponding word. <p>The <code>-O</code>, <code>-f</code>, <code>-m</code>, and <code>-W</code> switches arehandled specifically in these constructs. If another value of<code>-O</code> or the negated form of a <code>-f</code>, <code>-m</code>, or<code>-W</code> switch is found later in the command line, the earlierswitch value is ignored, except with {<code>S</code>*} where <code>S</code> isjust one letter, which passes all matching options. <p>The character <code>|</code> at the beginning of the predicate text is used toindicate that a command should be piped to the following command, butonly if <code>-pipe</code> is specified. <p>It is built into GCC which switches take arguments and which do not. (You might think it would be useful to generalize this to allow eachcompiler's spec to say which switches take arguments. But this cannotbe done in a consistent fashion. GCC cannot even decide which inputfiles have been specified without knowing which switches take arguments,and it must know which input files to compile in order to tell whichcompilers to run). <p>GCC also knows implicitly that arguments starting in <code>-l</code> are to betreated as compiler output files, and passed to the linker in theirproper position among the other output files. </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -