1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Using the GNU Compiler Collection 目录翻译

Using the GNU Compiler Collection 目录翻译

时间:2023-12-31 07:57:51

相关推荐

Using the GNU Compiler Collection 目录翻译

文章目录

Introduction1 Programming Languages Supported by GCC2 Language Standards Supported by GCC2.1 C Language 3 GCC Command Options3.1 Option Summary 4 C Implementation-Defined Behavior6 Extensions to the C Language Family9 Binary Compatibility其他工具10 gcov—a Test Coverage Program11 gcov-tool—an Offline Gcda Profile Processing Tool12 gcov-dump—an Offline Gcda and Gcno Profile Dump Tool13 lto-dump—Tool for dumping LTO object files.

Introduction

本手册介绍了如何使用GNU编译器,以及它们的特性和不兼容性,以及如何报告错误。它对应于编译器(GCC)13.0.1版。GNU编译器的内部内容,包括如何将它们移植到新的目标,以及如何为新语言编写前端的一些信息,都记录在单独的手册中。请参阅GNU编译器集合(GCC)内部的“简介”部分。

1 Programming Languages Supported by GCC

GCC代表“GNU编译器集合”。GCC 支持哪些语言 GCC是几种主要编程语言的编译器的集成发行版。这些语言目前包括C、C++、Objective-C、Objective-C++、Fortran、Ada、D和Go。GCC 含义1 : GNU编译器集合缩写GCC在常用中有多种含义。当前的官方含义是“GNU编译器集合(GNU Compiler Collection)”,一般指完整的工具套件。GCC含义2 : GNUC编译器这个名称在历史上代表“GNUC编译器”,当重点是编译C程序时,这种用法仍然很常见。GCC含义3 : 后端最后,当谈到GCC的独立于语言的组件时,也使用了这个名称:所有支持语言的编译器之间共享的代码。GCC的语言独立组件包括大多数优化器,以及为各种处理器生成机器代码的“后端”。后端 -> 前端编译器中特定于特定语言的部分称为“前端”。一些 前端 是 GCC的集成组件,还有其他几个前端是单独维护的(这些支持Mercury和COBOL等语言)要使用这些,它们必须与GCC本身一起构建。各种语言的编译器除C以外的大多数语言的编译器都有自己的名称。C++编译器是G++,Ada编译器是GNAT,依此类推。当我们谈到编译其中一种语言时,我们可能会用 "它自己的名字,或者GCC" 来称呼该编译器。两者都是正确的。各种语言编译器的实现方式历史上,包括C++和Fortran在内的许多语言的编译器都是作为“预处理器”实现的,它们会输出另一种高级语言,如C。这种预处理器(C++ -> C)不应与C预处理器(头文件,宏展开)混淆C预处理器是C、C++、Objective-C和Objective-C++语言的一个组成部分。GCC中包含的编译器都不是这样实现的;它们都直接生成机器代码。

2 Language Standards Supported by GCC

对于GCC编译的每种语言如果有标准,GCC都会尝试遵循该标准的一个或多个版本,可能会有一些例外,也可能会有某些扩展。

2.1 C Language

The original ANSI C standard (X3.159-1989) was ratified in 1989 and published in 1990. This standard was ratified as an ISO standard (ISO/IEC 9899:1990) later in 1990. There were no technical differences between these publications, although the sections of the ANSI standard were renumbered and became clauses in the ISO standard. The ANSI standard, but not the ISO standard, also came with a Rationale document. This standard, in both its forms, is commonly known as C89, or occasionally as C90, from the dates of ratification. To select this standard in GCC, use one of the options最初的 ANSI C 标准 (X3.159-1989) 于 1989 年获得批准并于 1990 年发布。该标准于 1990 年晚些时候被批准为 ISO 标准 (ISO/IEC 9899:1990)。这些出版物之间没有技术差异,尽管 ANSI 标准的章节被重新编号并成为 ISO 标准中的条款。 ANSI 标准,但不是 ISO 标准,也附带了一个基本原理文档。从批准之日起,该标准的两种形式通常称为 C89,有时也称为 C90。要在 GCC 中选择此标准,请使用其中一个选项-ansi, -std=c90 -std=c90 or -std=iso9899:1990 -std=iso9899:1990; to obtain all the diagnostics required by the standard, you should also specify;要获得标准要求的所有诊断,您还应该指定-pedantic -迂腐 (or -pedantic-errors -迂腐错误 if you want them to be errors rather than warnings). See Options Controlling C Dialect.如果您希望它们是错误而不是警告)。请参阅控制 C 方言的选项。Errors in the 1990 ISO C standard were corrected in two Technical Corrigenda published in 1994 and 1996. GCC does not support the uncorrected version.1990 年 ISO C 标准中的错误在 1994 年和 1996 年发布的两个技术勘误表中得到纠正。GCC 不支持未纠正的版本。An amendment to the 1990 standard was published in 1995. This amendment added digraphs and __STDC_VERSION__ to the language, but otherwise concerned the library. This amendment is commonly known as AMD1; the amended standard is sometimes known as C94 or C95. To select this standard in GCC, use the option1990 年标准的修正案于 1995 年发布。该修正案在语言中添加了二合字母和 __STDC_VERSION__ ,但在其他方面与图书馆有关。此修正案通常称为 AMD1;修订后的标准有时称为 C94 或 C95。要在 GCC 中选择此标准,请使用选项-std=iso9899:199409 -std=iso9899:199409 (with, as for other standard versions,(对于其他标准版本,-pedantic -迂腐 to receive all required diagnostics).接收所有必需的诊断)。A new edition of the ISO C standard was published in 1999 as ISO/IEC 9899:1999, and is commonly known as C99. (While in development, drafts of this standard version were referred to as C9X.) GCC has substantially complete support for this standard version; see /c99status.html for details. To select this standard, useISO C 标准的新版本于 1999 年作为 ISO/IEC 9899:1999 发布,通常称为 C99。 (在开发过程中,这个标准版本的草案被称为 C9X。)GCC 基本上完全支持这个标准版本;有关详细信息,请参阅 /c99status.html 。要选择此标准,请使用-std=c99 -std=c99 or -std=iso9899:1999 -std=iso9899:1999.Errors in the 1999 ISO C standard were corrected in three Technical Corrigenda published in 2001, and . GCC does not support the uncorrected version.1999 ISO C 标准中的错误已在 2001、 和 年发布的三个技术勘误中得到更正。GCC 不支持未更正的版本。A fourth version of the C standard, known as C11, was published in as ISO/IEC 9899:. (While in development, drafts of this standard version were referred to as C1X.) GCC has substantially complete support for this standard, enabled withC 标准的第四个版本,称为 C11,于 年作为 ISO/IEC 9899: 发布。 (在开发过程中,这个标准版本的草案被称为 C1X。)GCC 基本上完全支持这个标准,启用-std=c11 -std=c11 or -std=iso9899: -std=iso9899:. A version with corrections integrated was prepared in and published in as ISO/IEC 9899:; it is known as C17 and is supported with. 年准备了一个包含更正的版本,并于 年作为 ISO/IEC 9899: 发布;它被称为 C17 并支持-std=c17 -std=c17 or -std=iso9899: -std=iso9899:; the corrections are also applied with;更正也适用于-std=c11 -std=c11, and the only difference between the options is the value of __STDC_VERSION__.,选项之间的唯一区别是 __STDC_VERSION__ 的值。A further version of the C standard, known as C2X, is under development; experimental and incomplete support for this is enabled withC 标准的另一个版本,称为 C2X,正在开发中;对此启用了实验性和不完整的支持-std=c2x -std=c2x.By default, GCC provides some extensions to the C language that, on rare occasions conflict with the C standard. See Extensions to the C Language Family. Some features that are part of the C99 standard are accepted as extensions in C90 mode, and some features that are part of the C11 standard are accepted as extensions in C90 and C99 modes. Use of the默认情况下,GCC 为 C 语言提供了一些扩展,在极少数情况下会与 C 标准发生冲突。请参阅 C 语言系列的扩展。属于 C99 标准的一些功能在 C90 模式中被接受为扩展,而属于 C11 标准的一些功能在 C90 和 C99 模式中被接受为扩展。使用的-std options listed above disables these extensions where they conflict with the C standard version selected. You may also select an extended version of the C language explicitly with上面列出的选项会禁用这些与所选 C 标准版本冲突的扩展。您也可以明确选择 C ​​语言的扩展版本-std=gnu90 -std=gnu90 (for C90 with GNU extensions),(对于带有 GNU 扩展的 C90),-std=gnu99 -std=gnu99 (for C99 with GNU extensions) or(对于带有 GNU 扩展的 C99)或-std=gnu11 -std=gnu11 (for C11 with GNU extensions).(对于带有 GNU 扩展的 C11)。The default, if no C language dialect options are given, is如果没有给出 C 语言方言选项,则默认为-std=gnu17 -std=gnu17.The ISO C standard defines (in clause 4) two classes of conforming implementation. A conforming hosted implementation supports the whole standard including all the library facilities; a conforming freestanding implementation is only required to provide certain library facilities: those in <float.h>, <limits.h>, <stdarg.h>, and <stddef.h>; since AMD1, also those in <iso646.h>; since C99, also those in <stdbool.h> and <stdint.h>; and since C11, also those in <stdalign.h> and <stdnoreturn.h>. In addition, complex types, added in C99, are not required for freestanding implementations.ISO C 标准定义(在条款 4 中)两类符合性实现。符合标准的托管实现支持包括所有库设施在内的整个标准;符合要求的独立实现只需要提供某些库设施: <float.h> 、 <limits.h> 、 <stdarg.h> 和 <stddef.h> 中的设施;自 AMD1 以来,还有 <iso646.h> 中的那些;自 C99 以来,还有 <stdbool.h> 和 <stdint.h> 中的那些;从 C11 开始,还有 <stdalign.h> 和 <stdnoreturn.h> 中的那些。此外,独立实现不需要 C99 中添加的复杂类型。The standard also defines two environments for programs, a freestanding environment, required of all implementations and which may not have library facilities beyond those required of freestanding implementations, where the handling of program startup and termination are implementation-defined; and a hosted environment, which is not required, in which all the library facilities are provided and startup is through a function int main (void) or int main (int, char *[]). An OS kernel is an example of a program running in a freestanding environment; a program using the facilities of an operating system is an example of a program running in a hosted environment.该标准还为程序定义了两个环境,一个独立环境,所有实现都需要它,并且可能没有超出独立实现所需的库设施,其中程序启动和终止的处理是实现定义的;和一个托管环境,这不是必需的,其中提供了所有库设施,并且启动是通过函数 int main (void) 或 int main (int, char *[]) 进行的。操作系统内核是在独立环境中运行的程序的一个例子;使用操作系统功能的程序是在托管环境中运行的程序的一个例子。GCC aims towards being usable as a conforming freestanding implementation, or as the compiler for a conforming hosted implementation. By default, it acts as the compiler for a hosted implementation, defining __STDC_HOSTED__ as 1 and presuming that when the names of ISO C functions are used, they have the semantics defined in the standard. To make it act as a conforming freestanding implementation for a freestanding environment, use the optionGCC 的目标是可用作符合标准的独立实现,或用作符合标准的托管实现的编译器。默认情况下,它充当托管实现的编译器,将 __STDC_HOSTED__ 定义为 1 并假定在使用 ISO C 函数的名称时,它们具有标准中定义的语义。要使其充当独立环境的一致独立实现,请使用该选项-ffreestanding -独立式; it then defines __STDC_HOSTED__ to 0 and does not make assumptions about the meanings of function names from the standard library, with exceptions noted below. To build an OS kernel, you may well still need to make your own arrangements for linking and startup. See Options Controlling C Dialect.;然后它将 __STDC_HOSTED__ 定义为 0 ,并且不对标准库中的函数名称的含义做出假设,例外情况如下所述。要构建操作系统内核,您可能仍然需要自己安排链接和启动。请参阅控制 C 方言的选项。GCC does not provide the library facilities required only of hosted implementations, nor yet all the facilities required by C99 of freestanding implementations on all platforms. To use the facilities of a hosted environment, you need to find them elsewhere (for example, in the GNU C library). See Standard Libraries.GCC 不提供仅托管实现所需的库设施,也不提供 C99 在所有平台上独立实现所需的所有设施。要使用托管环境的设施,您需要在其他地方找到它们(例如,在 GNU C 库中)。请参阅标准库。Most of the compiler support routines used by GCC are present inGCC 使用的大多数编译器支持例程都存在于libgcc, but there are a few exceptions. GCC requires the freestanding environment provide memcpy, memmove, memset and memcmp. Finally, if __builtin_trap is used, and the target does not implement the trap pattern, then GCC emits a call to abort., 但也有少数例外。 GCC 要求独立环境提供 memcpy 、 memmove 、 memset 和 memcmp 。最后,如果使用 __builtin_trap ,并且目标没有实现 trap 模式,那么 GCC 发出对 abort 的调用。For references to Technical Corrigenda, Rationale documents and information concerning the history of C that is available online, see /readings.html有关在线提供的技术勘误、基本原理文档和有关 C 历史的信息的参考,请参阅 /readings.html

3 GCC Command Options

当您调用GCC时,它通常会进行预处理、编译、组装和链接。"overall options" 允许您在中间阶段停止此过程。例如,“-c”选项表示不运行链接器。然后输出由汇编器输出的对象文件组成。参见第33页第3.2节[控制输出类型的选项]。其他剩下的选项将传递给一个或多个处理阶段。一些选项控制预处理器,另一些选项控制编译器本身。还有其他选项控制汇编器和链接器;其中大部分都没有在这里记录,因为您很少需要使用它们中的任何一个。可以与GCC一起使用的大多数命令行选项对于C程序都很有用;当一个选项只对另一种语言(通常是C++)有用时,解释会明确说明。如果特定选项的描述未提及源语言,则可以将该选项与所有支持的语言一起使用。运行GCC的通常方法是运行名为GCC的可执行文件,或者在交叉编译时运行机器GCC,或者运行机器GCC版本以运行特定版本的GCC。当您编译C++程序时,应该将GCC作为g++调用。有关编译C++程序时gcc和g++之间行为差异的信息,请参见第43页第3.3节[编译C++程序]。gcc程序接受选项和文件名作为操作数。许多选项具有多字母名称;因此,可以不对多个单字母选项进行分组:“-dv”与“-d-v”非常不同。您可以混合选项和其他参数。在大多数情况下,您使用的顺序无关紧要。当您使用多个相同类型的选项时,顺序很重要;例如,如果多次指定“-L”,则将按指定的顺序搜索目录。此外,“-l”选项的位置也很重要。许多选项都有以“-f”或“-W”开头的长名称,例如,“-fmove循环不变量”、“-Wformat”等。其中大多数都有积极和消极的形式;“-ffo”的否定形式是“-fno foo”。本手册仅记录了这两种表格中的一种,以非默认的为准。某些选项采用一个或多个参数,通常用空格或等号(“=”)与选项名称分隔。除非另有说明,否则参数可以是数字或字符串。数字参数通常必须是小的无符号十进制或十六进制整数。十六进制参数必须以“0x”前缀开头。指定某种大小阈值的选项的参数可以是任意大的十进制或十六进制整数,后跟指定字节倍数的字节大小后缀,例如kB和KiB分别表示千字节和千字节,MB和MiB表示兆字节和兆字节,GB和GiB表示千兆字节和千兆字节,等等。这些参数在以下文本中由字节大小指定。有关二进制和十进制字节大小前缀的完整列表和解释,请参阅NIST、IEC和其他相关国家和国际标准。参见[选项索引],第1027页,了解GCC选项的索引。

3.1 Option Summary

4 C Implementation-Defined Behavior

"ISO C的一致性实现" 需要 记录 该种实现 在指定为每个领域的 "实现定义"的选择了哪种实现。以下列出了所有此类区域,以及ISO/IEC 9899:1990、ISO/IEC 9899:1999和ISO/IEC 9899:标准中的章节编号。某些领域仅在标准的一个版本中(而没有在每个版本中)定义了实现。一些选择取决于GCC遵循的平台外部确定的ABI(包括标准字符编码);以下列出了“由ABI确定”.参见第9章[二进制兼容性],第931页,和/readings.html。预处理器手册中记录了一些选择。请参阅C预处理器中的“实现定义的行为”一节。一些选择是由库和操作系统(或为独立环境编译时的其他环境)做出的;有关详细信息,请参阅他们的文档。

6 Extensions to the C Language Family

GNUC提供了ISO标准C中没有的几种语言特性要测试这些特性在条件编译中的可用性,请检查预定义的宏__GNUC__,该宏始终在GCC下定义。这些扩展在C和Objective-C中可用。它们中的大多数在C++中也可用。有关仅适用于C++的扩展,请参阅第7章[C++语言的扩展],第901页。Some features that are in ISO C99 but not C90 or C++ are also, as extensions, accepted by GCC in C90 mode and in C++.在ISO C99(而不是 C90 /C++) 中的一些特性 也被 C90模式/C++ 作为扩展

9 Binary Compatibility

二进制兼容性包含几个相关概念:ABIABI conformancecalling conventions...

其他工具

10 gcov—a Test Coverage Program

gcov 是一个可以与 GCC 结合使用的工具,用于测试程序中的代码覆盖率。

11 gcov-tool—an Offline Gcda Profile Processing Tool

12 gcov-dump—an Offline Gcda and Gcno Profile Dump Tool

13 lto-dump—Tool for dumping LTO object files.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。