New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the link order of libglslang and libHLSL #463
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
libglslang depends on libHLSL, so the latter needs to be specified last. This fixes an issue when trying to build shaderc against system-wide versions of libglslang/libHLSL, rather than the in-tree versions from third_party. Additionally, libshaderc_util also depends on SPIRV-Tools
Additionally, I found another error in the linker scripts: |
@@ -18,7 +18,7 @@ add_library(glslc STATIC | |||
shaderc_default_compile_options(glslc) | |||
target_include_directories(glslc PUBLIC ${glslang_SOURCE_DIR}) | |||
target_link_libraries(glslc PRIVATE glslang OSDependent OGLCompiler | |||
HLSL glslang SPIRV ${CMAKE_THREAD_LIBS_INIT}) | |||
glslang SPIRV HLSL ${CMAKE_THREAD_LIBS_INIT}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glslang was already listed before and after HLSL.
I don't know the details but that's usually necessary when there's a circular dependency between the two. Are you sure that HLSL itself doesn't depend on glslang?
We may require a second mention of HLSL, something like:
glslang ... HLSL .. glslang .. HLSL
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to work as-is for me already, but I suppose I can add the extra link to be on the safe side.
glslang OSDependent OGLCompiler HLSL glslang SPIRV | ||
SPIRV-Tools-opt ${CMAKE_THREAD_LIBS_INIT}) | ||
glslang OSDependent OGLCompiler glslang HLSL SPIRV | ||
SPIRV-Tools-opt SPIRV-Tools ${CMAKE_THREAD_LIBS_INIT}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMake already has a "PUBLIC" dependency from SPIRV-Tools-opt to SPIRV-Tools. So it seems this is not necessary?
What error are you trying to fix here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but those dependencies only do anything if you actually build SPIRV-Tools-opt / SPIRV-Tools using your own cmake scripts, from third_party. But in practice, I am not building libshaderc against the third_party versions - I am building them against the system-wide SPIRV-Tools installation. (As the commit message points out)
The concrete issue being solved here is sjnewbury/gentoo-gpu#22, which prevents libshaderc
from working on Gentoo. The gentoo packaging policy forbids the use of vendored third_party
-style libraries in favor of system-wide versions of those libraries wherever avoidable, and this is such a case.
I can either ship the work-around from this commit as part of the gentoo package, or I can try submitting it upstream - which is what I tried here.
Please rebase your changes against latest master to rerun the bots. Also, please sign the contributor's license agreement (CLA). That's necessary before we can accept your CL. |
If I give you free license to take over authorship of the commit, does that mean I don't have to sign the CLA? I looked at the relevant links but was confused as to what exactly you want me to do. I can copy/paste some statement, but I'm not about to download and fill in some form for a trivial commit. |
I'd like @AWoloszyn 's opinion on how to better support building against already-installed support libraries. |
Sorry about not getting around to this earlier, it fell off the end of my inbox. In order for us to handle the correct dependencies from SPIRV-Tools-opt -> SPIRV-Tools we will have to export a CMake config file that describes the transitive dep. See: Then users would not be required to know this transitive dependency. Ideally something like this should be done in Glslang as well, so that users do not have to replicate the strange circular dependency behavior. |
The better way to handle external dependencies in general would be with pkg-config |
Correct me if I am wrong, but pkg-config is not supported (properly) on Windows, so we would have to maintain a second setup for deps for Windows as well. With the cmake-based solution at least it should work everywhere. |
Doing something like LunarG for FindVulkan seems the right way forward. See https://github.com/Kitware/CMake/blob/master/Modules/FindVulkan.cmake |
this has gone stale. closing. |
libglslang depends on libHLSL, so the latter needs to be specified last.
This fixes an issue when trying to build shaderc against system-wide
versions of libglslang/libHLSL, rather than the in-tree versions from
third_party.