undefined references linker error after applying patch "[llvm] Use = default (NFC)"
After applying this commit: https://github.com/llvm/llvm-project/commit/152d61a821da76a4fa4532ea648b2ce11bc9a06e, my local llvm Debug build crashed at linking stage and got the follwoing error (maybe different constructors but all are undefined reference error):
llvm/include/llvm/Support/GenericDomTreeConstruction.h:1541: undefined reference to `llvm::DominatorTreeBase<llvm::MachineBasicBlock, true>::DominatorTreeBase()'
If it is a Release version, the building is fine.
This patch changed the default constructor. Not sure whether it expose a problem in linker. The build command I useds is:
cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" -DCMAKE_BUILD_TYPE=Debug
cmake --build .
My ld version is 2.30, and cmake version is cmake version 3.18.2. Any clue about this issue or how to fix it? Thanks.
What compiler are you using? Is this a clean checkout of llvm-project or do you have local modifications? Can you reproduce the issue with a recent, clean clone of llvm-project?
(I am removing the llvm:crash label, as it appears that the linker fails with an error (undefined references), rather than LLVM itself crashing)
What compiler are you using? Is this a clean checkout of llvm-project or do you have local modifications? Can you reproduce the issue with a recent, clean clone of llvm-project?
(I am removing the llvm:crash label, as it appears that the linker fails with an error (
undefined references), rather than LLVM itself crashing)
@fhahn I use g++ 5.5 in Ubuntu, and the issue happend in a clean checkout llvm-project. Thank you for changing the label.
Interesting. I don't have access to a system with that compiler. Maybe posting the full error output may help someone else to figure out what is going on.
Interesting. I don't have access to a system with that compiler. Maybe posting the full error output may help someone else to figure out what is going on.
Thanks for the suggestion. Here is the sample of the error output (all errors are similar to those):
lib/libLLVMNVPTXCodeGen.a(NVPTXTargetMachine.cpp.o): In function `llvm::NVPTXTargetMachine::registerPassBuilderCallbacks(llvm::PassBuilder&)::{lambda(llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module>&, llvm::OptimizationLevel)#2}::operator()(llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module>&, llvm::OptimizationLevel) const': /home/xxx/local_build/mlir/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp:230: undefined reference to `llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function>::PassManager()' ... lib/libLLVMAMDGPUCodeGen.a(SIWholeQuadMode.cpp.o): In function `llvm::MachinePostDominatorTree::getBase()': /home/xxx/local_build/mlir/llvm/include/llvm/CodeGen/MachinePostDominators.h:38: undefined reference to `llvm::DominatorTreeBase<llvm::MachineBasicBlock, true>::DominatorTreeBase()' ... /home/xxx/local_build/mlir/llvm/lib/Transforms/IPO/Inliner.cpp:1088: undefined reference to `llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module>::PassManager()' /home/xxx/local_build/mlir/llvm/lib/Transforms/IPO/Inliner.cpp:1088: undefined reference to `llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module>::PassManager()' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
It seems like constructor is not recognized by the linker, and the commit I mentioned above changed the constructor's declaration. So it might be missing an option for it when using Debug to build.