The significant gap in compilation speed between clang and gcc for ORCJIT

During my study of ORC JIT, it was inevitable to compile the official provided examples. While compiling these examples, I noticed that clang’s compilation speed was significantly slower compared to gcc, which was considerably faster. To analyze this, I scripted a shell program to measure the compilation time of the same file using both compilers. Through multiple experiments and comparisons, I found that gcc’s compilation speed was approximately twenty times faster than clang’s for the same file. Result as following:
image
options as following:
gcc:
g++ -g /home/jinrui/llvm-project-main/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native` -O0 -o /home/jinrui/llvm-project-main/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLVMJITTest
clang++:
clang++ -g /home/jinrui/llvm-project-main/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native` -O0 -o /home/jinrui/llvm-project-main/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLVMJITTest
From a normal perspective, such a significant difference in compilation time between clang and gcc shouldn’t occur. However, I’m currently unable to comprehend the reason behind this vast gap. Moreover, I’ve observed that when building the LLVM project, using gcc results in a much faster compilation speed compared to clang.

I’m not sure where this difference comes from, but -ftime-trace can provide additional insight.

Per The significant gap in compilation speed between clang and gcc for ORCJIT. · Issue #73925 · llvm/llvm-project · GitHub this is because OP is using a debug build of clang… duh.

1 Like