【问题标题】:Understanding some cc1 parameters了解一些cc1参数
【发布时间】:2020-07-30 18:32:17
【问题描述】:

运行$ gcc -v 导致第一个命令是cc1 命令。首先,我在哪里可以找到所有参数的含义?我尝试输入man cc1help cc1 等,但找不到任何内容。

在 linux 上,gcc -v file.c 导致第一个命令被(重新组织了一下):

/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1 \
    file.c \
    -o ccN7P5D111.s
    -quiet \
    -v \
    -imultiarch x86_64-linux-gnu \
    -quiet \
    -dumpbase file.c \
    -mtune=generic \
    -march=x86-64 \
    -auxbase file \
    -version \
    -fstack-protector \
    -Wformat \
    -Wformat-security \
  • file.c 是要编译的文件。
  • -o ccN7P5D111.s 是输出文件(几乎是一个随机的 tmpfile)

还有其他人,嗯,不太确定。对它们的基本描述是什么?其中哪些重要?

【问题讨论】:

  • 至少其中一些也是gcc 选项,并且认为它们对cc1gcc 的含义相同似乎是合理的。但我不太明白问题的重点,因为cc1 是 GCC 的内部组件,而不是面向用户的可执行文件。
  • 你试过阅读the GCC manual吗?如前所述,其中一些也是gcc 前端选项。内部cc1 参数也可能记录在案。
  • cc1 是 gcc 的一个实现细节,因此只有少量文档。您不应该以用户身份直接调用它。

标签: c assembly gcc


【解决方案1】:

它不在$PATH 中,这就是gcc -v 通过完整路径运行它的原因。它没有手册页,因为它不打算手动调用,只需通过 gcc 前端。

它们都不重要,如果您不是(试图成为)GCC 开发人员,请不要手动运行它。如果您是,请阅读源代码。

在我的系统上,/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/cc1 --help 打印一堆帮助,就像大多数程序一样。

The following options are specific to just the language Ada:
  -fdump-scos                           [available in Ada]

The following options are specific to just the language AdaSCIL:
 None found.  Use --help=AdaSCIL to show *all* the options supported by the AdaSCIL front-end.

The following options are specific to just the language AdaWhy:
 None found.  Use --help=AdaWhy to show *all* the options supported by the AdaWhy front-end.

The following options are specific to just the language BRIG:
  -fassume-phsa                         [available in BRIG]

The following options are specific to just the language C:
  -fgimple                              [disabled]

The following options are specific to just the language C++:
  -Wplacement-new                       -Wplacement-new=1
  -Wplacement-new=<0,2>                 [available in C++]

The following options are specific to just the language D:
  -Hd <dir>                             
  -Hf <file>                            
  -Wcast-result                         [available in D]
  -Wspeculative                         [disabled]
  -X                                    [disabled]
  -Xf <file>                            
  -fall-instantiations                  [disabled]
  -fassert                              [available in D]
  -fbounds-check                        [available in D]
  -fbounds-check=[on|safeonly|off]      [available in D]
  -fdebug                               [disabled]
...

The following options control parameters:
  --param=align-loop-iterations=        4
  --param=align-threshold=<1,65536>             100
  --param=analyzer-bb-explosion-factor=         5
  --param=analyzer-max-enodes-per-program-point=        8
  --param=analyzer-max-recursion-depth=         2
  --param=analyzer-min-snodes-for-call-summary=         10
  --param=asan-globals=<0,1>            1
...

The following options control compiler warning messages:
  -W                                    -Wextra
  -Waggregate-return                    [disabled]
  -Waggressive-loop-optimizations       [enabled]
  -Wanalyzer-double-fclose              [enabled]
  -Wanalyzer-double-free                [enabled]
  -Wanalyzer-exposure-through-output-file       [enabled]

GCC 确实有一个 gcc-internals 手册,其中包括您在之前的问题中询问过的 collect2 的文档。

不过,gccint 手册只是说明如何使用这些部件。它还记录了机器描述文件和类似的东西,这些文件告诉 GCC ISA 的指令。如果你想修改 GCC 自己的源代码的 C 代码,你需要知道的东西,例如添加新的优化器通道,或了解 GIMPLE 和 RTL。

我实际上并没有在 gccint 手册中找到对 cc1 选项的描述。在常规(针对最终用户)GCC 手册中,有一个 Invoking GCC 条目,但当然这是针对前端的,而不是针对 cc1 的。

在本地的info 页面中进行全文搜索没有找到相关文档,因此--help 输出可能是您能得到的最好结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-27
    • 2019-06-18
    • 2022-11-25
    • 2016-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多