Options Controlling the Kind of Output ( 控制輸出種類的選項 )

翻譯這篇文章時明顯感覺到難度加大,個別句子暫時無法理解,已用大號字體標出,希望以後能夠補上

Using the GNU Compiler Collection

3 GCC Command Options

3.2 Options Controlling the Kind of Output

控制輸出種類的選項

Compilation can involve up to four stages: preprocessing, compilation proper, assembly and linking, always in that order.

編譯可以包括多達4個階段:按順序 預處理,編譯本身,裝配(彙編)和鏈接

GCC is capable of preprocessing and compiling several files either into several assembler input files, or into one assembler input file;

GCC 能夠將幾個文件通過預處理和編譯生成一個或多個彙編輸入文件

then each assembler input file produces an object file,

然後每個彙編器輸入文件都會生成一個目標文件

and linking combines all the object files (those newly compiled, and those specified as input) into an executable file.

並且所有目標文件將鏈接(新編譯的文件和指定爲輸入的文件)組合到一個可執行文件中。

For any given input file, the fle name suffix determines what kind of compilation is done:

對於任何給定的輸入文件,文件名後綴決定了完成編譯的方式:

後綴名
file.c C source code that must be preprocessed.
file.i C source code that should not be preprocessed.
file.ii C++ source code that should not be preprocessed.
file.m Objective-C source code. Note that you must link with the ‘libobjc’ library to make an Objective-C program work.
file.mi Objective-C source code that should not be preprocessed.
file.mm
file.M
Objective-C++ source code. Note that you must link with the ‘libobjc’ library to make an Objective-C++ program work. Note that ‘.M’ refers to a literal capital M.
Objective-C++ source code that must be preprocessed.
file.mii Objective-C++ source code that should not be preprocessed.
file.h C, C++, Objective-C or Objective-C++ header fle to be turned into a precompiled header (default), or C, C++ header fle to be turned into an Ada spec (via the ‘-fdump-ada-spec’ switch).
file.cc
file.cp
file.cxx
file.cpp
file.CPP
file.c++
file.C
C++ source code that must be preprocessed. Note that in ‘.cxx’, the last two letters must both be literally ‘x’. Likewise, ‘.C’ refers to a literal capital C
file.hh
file.H
file.hp
file.hxx
file.hpp
file.HPP
file.h++
file.tc
C++ header fle to be turned into a precompiled header or Ada spec.
file.f
file.for
file.ftn
Fixed form Fortran source code that should not be preprocessed.
file.F
file.FOR
file.fpp
file.FPP
file.FTN
Fixed form Fortran source code that must be preprocessed (with the traditional preprocessor).
file.f90
file.f95
file.f03
file.f08
Free form Fortran source code that must be preprocessed (with the traditional preprocessor).
file.go Go source code.
file.brig BRIG files (binary representation of HSAIL).
file.ads Ada source code fle that contains a library unit declaration (a declaration of a package, subprogram, or generic, or a generic instantiation), or a library unit renaming declaration (a package, generic, or subprogram renaming declaration). Such fles are also called specs.
file.adb Ada source code fle containing a library unit body (a subprogram or package body). Such fles are also called bodies.
file.s
file.S
file.sx
Assembler code that must be preprocessed.
other Any fle name with no recognized suffix is treated this way.

You can specify the input language explicitly with the ‘-x’ option:

您可以使用 ‘-x’ 選項明確指定輸入語言:

-x language

Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix).

明確指定以下輸入文件的語言(而不是讓編譯器根據文件名後綴選擇默認值)。

This option applies to all following input files until the next ‘-x’ option.

此選項適用於所有以下輸入文件,直到下一個“-x”選項。

Possible values for language are:

language 可取值爲:

c c-header cpp-output
c++ c++-header c++-cpp-output
objective-c objective-c-header objective-c-cpp-output
objective-c++ objective-c++-header objective-c++-cpp-output
assembler assembler-with-cpp
ada
f77 f77-cpp-input f95 f95-cpp-input
go
brig

-x none

Turn off any specifcation of a language,
so that subsequent files are handled according to their file name suffixes (as they are if ‘-x’ has not been used at all).

關閉語言規範,以便後續文件根據文件名後綴進行處理(如果沒有再次使用’-x’)。

If you only want some of the stages of compilation, you can use ‘-x’ (or filename suffixes) to tell gcc where to start,
and one of the options ‘-c’, ‘-S’, or ‘-E’ to say where gcc is to stop.

如果只需要編譯某些階段,可以使用’-x’(或文件名後綴)來告訴gcc從哪裏開始,在加上一個選項’-c’,’-S’ 或 ‘-E’ 來說明gcc要停止的位置。

Note that some combinations (for example, ‘-x cpp-output -E’) instruct gcc to do nothing at all.

請注意,某些組合指令(如,’-x cpp-output -E’) gcc 完全不執行任何操作。

-c

Compile or assemble the source files, but do not link. The linking stage simply is not done.

編譯或彙編源文件,但不鏈接。 連接階段還沒有完成。

The ultimate output is in the form of an object file for each source file.

最終的輸出是每個源文件的目標文件格式。

By default, the object file name for a source file is made by replacing the suffix ‘.c’, ‘.i’, ‘.s’, etc., with ‘.o’.

默認情況下,源文件的目標文件名後綴用’.o’ 來替換 ‘.c’,’.i’,’.s’等。

Unrecognized input files, not requiring compilation or assembly, are ignored.

對於無法識別的輸入文件,不會編譯或彙編,將被忽略。

-s

Stop after the stage of compilation proper; do not assemble.

編譯階段後停止; 不進行彙編

The output is in the form of an assembler code file for each non-assembler input file specified.

輸出的是指定的每個非彙編器輸入文件的彙編代碼文件的形式。

By default, the assembler file name for a source file is made by replacing the suffix ‘.c’, ‘.i’, etc., with ‘.s’.

默認情況下,源文件的彙編文件名後綴用 ‘.s’ 來替換 ‘.c’, ‘.i’ 等

Input files that don’t require compilation are ignored.

輸入不需要編譯的文件將被忽略。

-E

Stop after the preprocessing stage; do not run the compiler proper.

預處理階段後停止; 不進行編譯。

The output is in the form of preprocessed source code, which is sent to the standard output.

輸出的形式是預處理過的源代碼,它會被髮送到標準輸出。

Input files that don’t require preprocessing are ignored.

不需要預處理的輸入文件將被忽略。

-o file

Place output in file file.

將輸出放在文件 file

This applies to whatever sort of output is being produced,
whether it be an executable file, an object file, an assembler file or preprocessed C code.

這適用於正在生產的任何類型的輸出,無論是可執行文件,目標文件,彙編程序文件還是預處理的C代碼。

If ‘-o’ is not specifed, the default is to put an executable file in ‘a.out’, the object file for ‘source.suffix’ in ‘source.o’,

如果沒有指定’-o’,那麼默認情況是都放在可執行文件’a.out’中, ‘source.o’中的’source.suffix’對象文件

its assembler file in ‘source.s’, a precompiled header file in ‘source.suffix.gch’, and all preprocessed C source on standard output.

‘source.s’中的彙編文件,’source.suffix.gch’中的預編譯頭文件,以及標準輸出上的所有預處理C源。

-v

Print (on standard error output) the commands executed to run the stages of compilation.

Also print the version number of the compiler driver program and of the preprocessor and the compiler proper.

還要打印編譯器驅動程序的版本號以及預處理器和編譯器的版本號。

-###

Like ‘-v’ except the commands are not executed and arguments are quoted unless they contain only alphanumeric characters or ./-_.

可以理解爲同 -v 選項一樣,但更適合 shell 腳本使用

This is useful for shell scripts to capture the driver-generated command lines.

這對於shell腳本來捕獲驅動程序生成的命令行非常有用。

--help

Print (on the standard output) a description of the command-line options understood by gcc.

打印(在標準輸出上)gcc支持的命令行選項的描述。

If the ‘-v’ option is also specified then ‘–help’ is also passed on to the various processes invoked by gcc,
so that they can display the commandline options they accept.

如果還指定了 ‘-v’ 選項,’–help’ 也會被傳遞給gcc調用的各種進程,以便他們可以顯示他們能接受的命令行選項。

If the ‘-Wextra’ option has also been specifed (prior to the ‘–help’ option),
then command-line options that have no documentation associated with them are also displayed.

如果還指定了 ‘-Wextra’ 選項(在’–help’選項之前),那麼沒有文檔關聯的命令行選項也會顯示。

--target-help

Print (on the standard output) a description of target-specifc command-line options for each tool.

打印(在標準輸出上)每個工具的指定的命令行選項的描述。

For some targets extra target-specifc information may also be printed.

對於某些目標選項,還可以打印額外信息。

--help={class|[^]qualifier}[,...]

Print (on the standard output) a description of the command-line options understood by the compiler that fit into all specified classes and qualifiers.

打印(在標準輸出上)編譯器支持的符合所有指定類和限定符的命令行選項說明。

These are the supported classes: //一些支持的類

'optimizers'
        Display all of the optimization options supported by the compiler
        //顯示編譯器支持的所有優化選項
'warnings'
        Display all of the options controlling warning messages produced by the compiler.
        //顯示控制編譯器生成警告消息的所有選項。
'target'
        Display target-specifc options. Unlike the ‘--target-help’ option however, 
        target-specifc options of the linker and assembler are not displayed. 
        //顯示目標特定選項。 與'--target-help'選項不同,鏈接器和彙編器的 target-specifc 選項是不顯示的。
        This is because those tools do not currently support the extended ‘--help=’ syntax.
        //這是因爲這些工具當前不支持擴展的 '--help=' 語法。
'params'
        Display the values recognized by the ‘--param’ option.
        //顯示“--param”選項識別的值。
'language'
        Display the options supported for language, where language is the name of one of 
        the languages supported in this version of GCC.
        //顯示語言支持的選項,其中language是此版本的GCC中支持的其中一種語言的名稱
'common'
        Display the options that are common to all languages.
        //顯示所有語言通用的選項。

These are the supported qualifiers:
//這些是支持的限定詞:

'undocumented'
        Display only those options that are undocumented.
        //僅顯示那些沒有文檔的選項。
'joined'
        Display options taking an argument that appears after an equal sign in 
        the same continuous piece of text, such as: ‘--help=target’.
        //顯示選項,採用在同一連續文本中等號後出現的參數,例如:'--help=target'。
'separate'
        Display options taking an argument that appears as a separate word following 
        the original option, such as: ‘-o output-file’.
        //顯示選項採用在原始選項之後顯示爲單獨單詞的參數,例如:'-o output-file'。

Thus for example to display all the undocumented target-specifc switches 
supported by the compiler, use:
//因此,例如顯示編譯器支持的所有未記錄 target-specifc 開關 使用:

    --help=target,undocumented

The sense of a qualifier can be inverted by prefixing it with the ‘^’ character,
//限定詞的含義可以通過用 '^' 字符前綴來反轉
so for example to display all binary warning options 
//例如顯示所有二進制警告選項
(i.e., ones that are either on or off and that do not take an argument) 
//(即,打開或關閉且不採用參數的二進制警告選項)
that have a description, use:
//可以描述爲,使用:

    --help=warnings,^joined,^undocumented

The argument to ‘--help=’ should not consist solely of inverted qualifiers.
//'--help ='的參數不可以僅由 '^' 限定符組成。
Combining several classes is possible, 
although this usually restricts the output so much that there is nothing to display. 
//組合幾類是可以的,儘管這通常會限制輸出以至於無法顯示。
One case where it does work, however,is when one of the classes is target. 
//然而,其中一個類是目標的情況是可以的。
For example, to display all the target-specifc optimization options, use:
//例如,要顯示所有 target-specifc 的優化選項,請使用:

    --help=target,optimizers

The ‘--help=’ option can be repeated on the command line. 
//'--help=' 選項可以在命令行中重複。
Each successive use displays its requested class of options, 
skipping those that have already been displayed.
//每個連續使用顯示其所請求的類別的選項,跳過已經顯示的選項。
If the ‘-Q’ option appears on the command line before the ‘--help=’ option, 
then the descriptive text displayed by ‘--help=’ is changed. 
//如果命令行上在'-help='選項之前出現'-Q'選項,那麼'--help='顯示的描述性文本會被改變。
Instead of describing the displayed options, 
an indication is given as to whether the option is enabled, disabled or set to a specifc value (assuming that the compiler knows this at the point where the ‘--help=’ option is used)
//不是描述顯示的選項,而是給出了該選項是啓用,禁用還是設置爲特定值的指示(假設編譯器在使用'--help='選項的時候知道這一點)

Here is a truncated example from the ARM port of gcc:
//這是gcc的ARM端口的截斷示例

    % gcc -Q -mabi=2 --help=target -c
    The following options are target specific:
        -mabi=              2
        -mabort-on-noreturn [disabled]
        -mapcs              [disabled]

The output is sensitive to the effects of previous command-line options, 
so for example it is possible to find out which optimizations are enabled at ‘-O2’ by using:
//輸出對以前的命令行選項的影響很敏感,因此,例如,可以通過使用以下方式找出在“-O2”中啓用哪些優化:

    -Q -O2 --help=optimizers

Alternatively you can discover which binary optimizations are enabled by ‘-O3’ by using:
//或者,您可以通過使用以下方式來發現“-O3”啓用哪些二進制優化:

    gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
    gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts

--version

Display the version number and copyrights of the invoked GCC.

顯示調用的GCC的版本號和版權

-pass-exit-codes

Normally the gcc program exits with the code of 1 if any phase of the compiler returns a non-success return code.

如果編譯器的任何階段返回一個非成功的返回碼, 通常, gcc返回1並退出程序

If you specify ‘-pass-exit-codes’, the gcc program instead returns with the numerically highest error produced by any phase returning an error indication.

如果指定 ‘-pass-exit-codes’,gcc程序將返回任何階段產生的數字最高的錯誤。

The C, C++, and Fortran front ends return 4 if an internal compiler error is encountered.

如果遇到內部編譯器錯誤,C,C ++和Fortran的前端將返回4。

-pipe

Use pipes rather than temporary files for communication between the various stages of compilation.

使用管道而不是臨時文件進行編譯的各個階段之間的通信。

This fails to work on some systems where the assembler is unable to read from a pipe;

在某些系統上彙編器無法從管道上讀取

but the GNU assembler has no trouble.

但是GNU彙編器是沒有問題的

-specs=file

Process file after the compiler reads in the standard ‘specs’ file,

編譯器讀入標準“specs”文件後,

in order to override the defaults which the gcc driver program uses when determining what switches to pass to cc1, cc1plus, as, ld, etc.

More than one ‘-specs=file’can be specifed on the command line, and they are processed in order, from left to right.

可以在命令行中指定多個’-specs = file’,並按順序從左到右處理。

See Section 3.19 [Spec Files], page 380, for information about the format of the file.

有關文件格式的信息,請參見第3.19節[規格文件],第380頁。

-wrapper

Invoke all subcommands under a wrapper program.

調用 wrapper 程序的指令

The name of the wrapper program and its parameters are passed as a comma separated list.

wrapper 程序的名稱及其參數以逗號分隔的列表形式傳遞。

    gcc -c t.c -wrapper gdb,--args

This invokes all subprograms of gcc under ‘gdb –args’, thus the invocation of cc1 is ‘gdb –args cc1 …’.

這將調用gcc下的所有子程序 ‘gdb –args’ , 因此對於 cc1 的調用是 ‘gdb –args cc1 …’

-fplugin=name.so

Load the plugin code in file name.so, assumed to be a shared object to be dlopen’d by the compiler.

The base name of the shared object file is used to identify the plugin for the purposes of argument parsing (See ‘-fplugin-arg-name-key=value’ below).

共享對象文件的基本名稱用於標識插件以進行參數解析(參見下面的 ‘-fplugin-arg-name-key = value’)。

Each plugin should define the callback functions specifed in the Plugins API.

每個插件應該定義插件API中指定的回調函數。

-fplugin-arg-name-key=value

Define an argument called key with a value of value for the plugin called name.

定義一個名爲key的參數,其值爲名爲name的插件。

-fdump-ada-spec[-slim]

For C and C++ source and include files, generate corresponding Ada specs.

對於C和C ++源代碼和include文件,生成相應的Ada規範。

See Section ‘Generating Ada Bindings for C and C++ headers’ in GNAT User’s Guide, which provides detailed documentation on this feature.

請參見“GNAT用戶指南”中的“爲C和C ++標頭生成Ada綁定”一節,其中提供了有關此功能的詳細文檔。

-fada-spec-parent=unit

In conjunction with ‘-fdump-ada-spec[-slim]’ above, generate Ada specs as child units of parent unit.

結合上述 '-fdump-ada-spec [-slim]',生成Ada規範作爲父單元的子單位。

-fdump-go-spec=file

For input files in any language, generate corresponding Go declarations in file.

對於任何語言的輸入文件,在文件中生成相應的Go聲明。

This generates Go const, type, var,
and func declarations which may be a useful way to start writing a Go interface to code written in some other language.

這會生成Go 常量,類型,變量,和方法聲明,這對於開始用其他語言給 Go 編寫接口是很有用的

@file

Read command-line options from file. The options read are inserted in place of the original @file option.

從文件讀取命令行選項。 讀取的選項將插入到原@file選項的位置。

If file does not exist, or cannot be read, then the option will be treated literally, and not removed.

如果文件不存在或無法讀取,則將該選項作爲literally來對待,而不會被刪除。

Options in file are separated by whitespace.

文件中的選項由空格分隔。

A whitespace character may be included in an option by surrounding the entire option in either single or double quotes.

通過給整個選項周圍添加單引號或雙引號的方式可以將空格字符也包含在選項中。

Any character (including a backslash) may be included by prefixing the character to be included with a backslash.

任何字符( 包括反斜槓 )都可以通過添加反斜槓字符前綴來被包含在內

The file may itself contain additional @file options; any such options will be processed recursively.

該文件本身也可能包含@file選項; 任何這樣的選項將被遞歸處理。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章