CHIP-SPV / chipStar

chipStar is a tool for compiling and running HIP/CUDA on SPIR-V via OpenCL or Level Zero APIs.
Other
157 stars 27 forks source link

Undefined references when trying to build LTO #854

Closed pvelesko closed 1 month ago

pvelesko commented 1 month ago
**Consolidate compiler generated dependencies of target onemkl_gemm_wrapper
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(ABIBreak.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(ABIBreak.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(CommandLine.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(CommandLine.cpp.o): plugin needed to handle lto object
Consolidate compiler generated dependencies of target onemkl_gemm_wrapper_no_buffers
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(Debug.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(Debug.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(Error.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(Error.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(ManagedStatic.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(ManagedStatic.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(MemoryBuffer.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(MemoryBuffer.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(SmallVector.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(SmallVector.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(ToolOutputFile.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(ToolOutputFile.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(raw_ostream.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMSupport.a(raw_ostream.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMCore.a(Globals.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMCore.a(Globals.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMCore.a(LLVMContext.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMCore.a(LLVMContext.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMCore.a(Module.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMCore.a(Module.cpp.o): plugin needed to handle lto object
[  5%] Built target MKLShim
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMBitReader.a(BitcodeReader.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMBitReader.a(BitcodeReader.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMBitWriter.a(BitcodeWriter.cpp.o): plugin needed to handle lto object
/usr/bin/ld: /home/pvelesko/install/llvm/18.0/lib/libLLVMBitWriter.a(BitcodeWriter.cpp.o): plugin needed to handle lto object**

@linehill Could you update configure_llvm.sh to build a working LTO compiler?

linehill commented 1 month ago

LTO builds shouldn't be enabled if the it is not supported or working. Perhaps, CMake's check is not good enough?

pvelesko commented 1 month ago

I guess the check is not sufficient. Can you please share how you configured LLVM to enable LTO?

linehill commented 1 month ago

Can you please share how you configured LLVM to enable LTO?

I installed binutils-dev (on Ubuntu) and added -DLLVM_BINUTILS_INCDIR=/usr/include to LLVM's configuration. I think, that was enough to enable LTO builds on chipStar.

pvelesko commented 1 month ago

And you didn't enable LLVM_ENABLE_LTO?

linehill commented 1 month ago

And you didn't enable LLVM_ENABLE_LTO?

I didn't enable that one. I think that only optimizes LLVM build by applying LTO on it. I don't recall needing configuration options other than the -DLLVM_BINUTILS_INCDIR= in the above. You can check if the LLVM builds the plugin (LLVMgold.so) needed for the LTO - it should be in <install-or-build-dir>/lib/ directory.