Lorenz Braun via llvm-dev
2020-Feb-10 10:46 UTC
[llvm-dev] Question on symbol lookup error (VersionTuple)
Hi, i am currently working on an out-of-source pass to manipulate CUDA applications. Because since CUDA 9.2 the launch mechanism has changed, i check the CUDA SDK version from within my module pass. My pass fails when i use opt to run it on IR code: `symbol lookup error: /opt/cuda-flux/lib/libcuda_flux_pass.so: undefined symbol: _ZN4llvmlsERNS_11raw_ostreamERKNS_12VersionTupleE` This error does not happen when i register my pass with clang. When looking up the symbol tables with nm it shows me that the symbol is not found (which i expected from the error i got): ``` $ nm --dynamic /opt/cuda-flux/lib/libcuda_flux_pass.so | grep _ZN4llvmlsERNS_11raw_ostreamERKNS_12VersionTupleE U _ZN4llvmlsERNS_11raw_ostreamERKNS_12VersionTupleE ``` When making the same lookup on the clang binary the symbol is found. However, it is not found when doing the lookup on the opt binary. Is this on purpose? If yes, what would be the best way to fix this? Linking the LLVMSupport lib does not really work because this will lead to command line option registered multiple times. Here some additional info to give some context info: - using llvm 10.0 tag from github - cmake config: cmake -DLLVM_ENABLE_PROJECTS="clang;openmp" -DCMAKE_INSTALL_PREFIX=/opt/llvm-10.0 -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_DOXYGEN=OFF -DLLVM_BUILD_DOCS=OFF -GNinja -DLLVM_INSTALL_BINUTILS_SYMLINKS=ON ../llvm Best Regards Lorenz
Lorenz Braun via llvm-dev
2020-Feb-10 13:48 UTC
[llvm-dev] Question on symbol lookup error (VersionTuple)
I was able to solve the problem by rebuilding llvm with the cmake flag BUILD_SHARED_LIBS=ON. I am not entirely sure why this works because i did not link against the LLVMSupport.so. For any readers that are trying to solve a similar problem, be aware that i am building my pass out-of-source. Any additional comments on why excatly this works are very welcome ;) Best Regards Lorenz On 10.02.20 11:46, Lorenz Braun via llvm-dev wrote:> Hi, > > i am currently working on an out-of-source pass to manipulate CUDA > applications. Because since CUDA 9.2 the launch mechanism has changed, > i check the CUDA SDK version from within my module pass. My pass fails > when i use opt to run it on IR code: > `symbol lookup error: /opt/cuda-flux/lib/libcuda_flux_pass.so: > undefined symbol: _ZN4llvmlsERNS_11raw_ostreamERKNS_12VersionTupleE` > > This error does not happen when i register my pass with clang. When > looking up the symbol tables with nm it shows me that the symbol is > not found (which i expected from the error i got): > ``` > $ nm --dynamic /opt/cuda-flux/lib/libcuda_flux_pass.so | grep > _ZN4llvmlsERNS_11raw_ostreamERKNS_12VersionTupleE > U _ZN4llvmlsERNS_11raw_ostreamERKNS_12VersionTupleE > ``` > > When making the same lookup on the clang binary the symbol is found. > However, it is not found when doing the lookup on the opt binary. Is > this on purpose? If yes, what would be the best way to fix this? > Linking the LLVMSupport lib does not really work because this will > lead to command line option registered multiple times. > > Here some additional info to give some context info: > - using llvm 10.0 tag from github > - cmake config: > cmake -DLLVM_ENABLE_PROJECTS="clang;openmp" > -DCMAKE_INSTALL_PREFIX=/opt/llvm-10.0 -DCMAKE_BUILD_TYPE=Release > -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_DOXYGEN=OFF > -DLLVM_BUILD_DOCS=OFF -GNinja -DLLVM_INSTALL_BINUTILS_SYMLINKS=ON ../llvm > > Best Regards > Lorenz > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev