在使用clang编译器时,可以通过使用选项-ftime-report来启用编译时间报告。其中包含了编译的各个阶段以及每个阶段所花费的时间。在报告中,"phase opt and generate"指的是编译器在进行代码优化和生成目标文件的阶段。
要加快这个阶段的速度,可以尝试以下方法:
代码示例:
// sample.c int main() { int a = 1; int b = 2; int c = a + b; return c; }
// compile with time report enabled clang -ftime-report sample.c -o sample
// the time report will show the time spent on each phase, including "phase opt and generate".
下一篇:编译时将char*转换为字节