Allow diligent to link a static DirectXShaderCompiler#723
Allow diligent to link a static DirectXShaderCompiler#723Lokomojo wants to merge 1 commit intoDiligentGraphics:masterfrom
Conversation
TheMostDiligent
left a comment
There was a problem hiding this comment.
This change makes sense, there are few minor questions + formatting.
| LLVMSupport | ||
| dxcompiler |
There was a problem hiding this comment.
Why are these public dependencies?
There was a problem hiding this comment.
See below for reasons - if you'd prefer to make the consumer link the libraries manually that's your call of course ;)
| ) | ||
| endif() | ||
| if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
| target_link_libraries(Diligent-ShaderTools PRIVATE dl) |
There was a problem hiding this comment.
I think that dl should not be needed when linking statically - can be in the else() branch
Graphics/ShaderTools/CMakeLists.txt
Outdated
| cmake_policy(SET CMP0079 NEW) | ||
| target_link_libraries(SPIRV-Tools-opt | ||
| PUBLIC | ||
| LLVMSupport |
There was a problem hiding this comment.
Why is it public dependency?
Also, why is this dependency needed?
There was a problem hiding this comment.
Well, I made it public so that anything consuming this library will inherit the dependency. When static linking on some systems the builid will fail if the host executable is not itself linked against the dependencies.
Needed due to
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: lib/DirectXShaderCompiler/lib/libSPIRV-Tools-opt.a(replace_desc_array_access_using_var_index.cpp.o): in function `spvtools::opt::ReplaceDescArrayAccessUsingVarIndex::ReplaceAccessChain(spvtools::opt::Instruction*, spvtools::opt::Instruction*) const':
./DirectXShaderCompiler/external/SPIRV-Tools/source/opt/replace_desc_array_access_using_var_index.cpp:83:(.text+0x385): undefined reference to `llvm_assert'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: lib/DirectXShaderCompiler/lib/libSPIRV-Tools-opt.a(replace_desc_array_access_using_var_index.cpp.o): in function `spvtools::opt::ReplaceDescArrayAccessUsingVarIndex::HasImageOrImagePtrType(spvtools::opt::Instruction const*) const':
./DirectXShaderCompiler/external/SPIRV-Tools/source/opt/replace_desc_array_access_using_var_index.cpp:157:(.text+0xf0c): undefined reference to `llvm_assert'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: lib/DirectXShaderCompiler/lib/libSPIRV-Tools-opt.a(replace_desc_array_access_using_var_index.cpp.o): in function `spvtools::opt::(anonymous namespace)::GetValueWithKeyExistenceCheck(unsigned int, std::unordered_map<unsigned int, unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int> > > const&)':
./DirectXShaderCompiler/external/SPIRV-Tools/source/opt/replace_desc_array_access_using_var_index.cpp:34:(.text+0x1c26): undefined reference to `llvm_assert'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: lib/DirectXShaderCompiler/lib/libSPIRV-Tools-opt.a(replace_desc_array_access_using_var_index.cpp.o): in function `spvtools::opt::ReplaceDescArrayAccessUsingVarIndex::CreatePhiInstruction(spvtools::opt::BasicBlock*, std::vector<unsigned int, std::allocator<unsigned int> > const&, std::vector<unsigned int, std::allocator<unsigned int> > const&, unsigned int) const':
./DirectXShaderCompiler/external/SPIRV-Tools/source/opt/replace_desc_array_access_using_var_index.cpp:424:(.text+0x1f6b): undefined reference to `llvm_assert'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: lib/DirectXShaderCompiler/lib/libSPIRV-Tools-opt.a(replace_desc_array_access_using_var_index.cpp.o): in function `spvtools::opt::ReplaceDescArrayAccessUsingVarIndex::GetConstNull(unsigned int) const':
./DirectXShaderCompiler/external/SPIRV-Tools/source/opt/replace_desc_array_access_using_var_index.cpp:400:(.text+0x2209): undefined reference to `llvm_assert'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: lib/DirectXShaderCompiler/lib/libSPIRV-Tools-opt.a(replace_desc_array_access_using_var_index.cpp.o):./DirectXShaderCompiler/external/SPIRV-Tools/source/opt/ir_builder.h:294: more undefined references to `llvm_assert' follow
Add a flag (off by default) to allow diligent to use a statically-linked DirectXShaderCompiler