编译llvm时llvm[n]的含义,其中n为整数

meaning of llvm[n] when compiling llvm, where n is an integer

我正在编译 LLVM 和 clang。我注意到编译的输出有 llvm[1]:llvm[2]:llvm[3]: 每行的前缀。括号中的那些整数是什么意思?

编译作业的编号(make -j)。有助于跟踪编译错误。

显然,它与编译作业的数量无关(可以通过 make -j 1 轻松查看)。基于 autoconf 的构建系统指示源代码树中 makefile 的 "level")。作为价格,它是 make 的 MAKELEVEL 变量的值。

当前接受的答案不正确。此外,这确实是一个 GNU Make 问题,而不是一个 LLVM 问题。

您看到的是由 make 回显到命令行的 MAKELEVEL 变量的当前值。此值是 递归执行 的结果。来自 GNU make manual:

As a special feature, the variable MAKELEVEL is changed when it is passed down from level to level. This variable’s value is a string which is the depth of the level as a decimal number. The value is ‘0’ for the top-level make; ‘1’ for a sub-make, ‘2’ for a sub-sub-make, and so on. The incrementation happens when make sets up the environment for a recipe.

如果您手头有 GNU Make 源代码的副本,您可以在 output.c 中看到使用 void message(...) 函数生成的输出消息。在 GNU make v4.2 中,这发生在第 626 行。具体来说,program 参数设置为字符串 "llvm" 并且 makelevel 参数设置如上所述。

由于是误提,所以不是编译作业的编号。 -j [jobs]--jobs[=jobs] 选项可以同时 并行执行 最多 jobs 个配方。如果选择 -j--jobs,但未设置 jobs,GNU Make 会尝试同时执行尽可能多的配方。有关详细信息,请参阅 this section of the GNU Make manual

可以有递归执行没有并行执行,并行执行没有递归执行。这是目前接受的答案不正确的主要原因。