Skip to content

Conversation

@fwyzard
Copy link
Contributor

@fwyzard fwyzard commented Mar 15, 2020

Building in-tree with LLVM 11.0 master with the LLVM_LINK_LLVM_DYLIB cmake flag fails to link with the LLVMSPIRVLib library.

Add an explicit dependency to force the correct build order and linking.

Signed-off-by: Andrea Bocci [email protected]

Building in-tree with LLVM 11.0 master with the LLVM_LINK_LLVM_DYLIB
cmake flag fails to link with the LLVMSPIRVLib library.

Add an explicit dependency to force the correct build order and linking.

Signed-off-by: Andrea Bocci <[email protected]>
@CLAassistant
Copy link

CLAassistant commented Mar 15, 2020

CLA assistant check
All committers have signed the CLA.

@fwyzard
Copy link
Contributor Author

fwyzard commented Mar 15, 2020

Configuring and building in-tree with

git clone https://github.com/llvm/llvm-project.git
git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git llvm-project/llvm/projects/SPIRV-LLVM-Translator

mkdir llvm-project/build
cd llvm-project/build
cmake ../llvm \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_TARGETS_TO_BUILD="X86" \
  -DLLVM_LINK_LLVM_DYLIB=ON

make llvm-spirv -j`nproc`

results in the link errors

...
Scanning dependencies of target llvm-spirv
[100%] Building CXX object projects/SPIRV-LLVM-Translator/tools/llvm-spirv/CMakeFiles/llvm-spirv.dir/llvm-spirv.cpp.o
[100%] Linking CXX executable ../../../../bin/llvm-spirv
CMakeFiles/llvm-spirv.dir/llvm-spirv.cpp.o: In function `convertSPIRV()::{lambda(std::ostream&)#1}::operator()(std::ostream&) const [clone .isra.169]':
llvm-spirv.cpp:(.text._ZZL12convertSPIRVvENKUlRSoE_clES_.isra.169+0x32): undefined reference to `SPIRV::convertSpirv(std::istream&, std::ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, bool, bool)'
CMakeFiles/llvm-spirv.dir/llvm-spirv.cpp.o: In function `parseSpecConstOpt(llvm::StringRef, SPIRV::TranslatorOpts&)':
llvm-spirv.cpp:(.text._Z17parseSpecConstOptN4llvm9StringRefERN5SPIRV14TranslatorOptsE+0x16a): undefined reference to `llvm::getSpecConstInfo(std::istream&, std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int> > >&)'
CMakeFiles/llvm-spirv.dir/llvm-spirv.cpp.o: In function `main':
llvm-spirv.cpp:(.text.startup.main+0xcbe): undefined reference to `llvm::regularizeLlvmForSpirv(llvm::Module*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
llvm-spirv.cpp:(.text.startup.main+0xf06): undefined reference to `llvm::readSpirv(llvm::LLVMContext&, SPIRV::TranslatorOpts const&, std::istream&, llvm::Module*&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
llvm-spirv.cpp:(.text.startup.main+0x116e): undefined reference to `llvm::getSpecConstInfo(std::istream&, std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int> > >&)'
llvm-spirv.cpp:(.text.startup.main+0x13ea): undefined reference to `llvm::writeSpirv(llvm::Module*, SPIRV::TranslatorOpts const&, std::ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
llvm-spirv.cpp:(.text.startup.main+0x161f): undefined reference to `llvm::writeSpirv(llvm::Module*, SPIRV::TranslatorOpts const&, std::ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
llvm-spirv.cpp:(.text.startup.main+0x173f): undefined reference to `SPIRV::SPIRVUseTextFormat'
collect2: error: ld returned 1 exit status
make[3]: *** [projects/SPIRV-LLVM-Translator/tools/llvm-spirv/CMakeFiles/llvm-spirv.dir/build.make:85: bin/llvm-spirv] Error 1
make[2]: *** [CMakeFiles/Makefile2:11342: projects/SPIRV-LLVM-Translator/tools/llvm-spirv/CMakeFiles/llvm-spirv.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:11354: projects/SPIRV-LLVM-Translator/tools/llvm-spirv/CMakeFiles/llvm-spirv.dir/rule] Error 2
make: *** [Makefile:3319: llvm-spirv] Error 2

This commit fixes the link step by adding an explicit dependency on the LLVMSPIRVLib library.

@romanovvlad
Copy link
Contributor

romanovvlad commented Mar 17, 2020

@AlexeySotkin @AlexeySachkov FYI

Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me,

@AlexeySotkin, we probably need to add this configuration to Travis CI

Copy link
Member

@svenvh svenvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants