Closed haasn closed 6 years ago
For starters, it appears that some changes are needed to deal with the difference in the naming of your SPIRV-Tools and gentoo's official spirv-tools ebuilds. Specifically, this .diff seems to fix the generation of build-version.inc
:
diff --git a/dev-util/shaderc/Manifest b/dev-util/shaderc/Manifest
index 3ea4abb..a6ee97f 100644
--- a/dev-util/shaderc/Manifest
+++ b/dev-util/shaderc/Manifest
@@ -1 +1 @@
-EBUILD shaderc-9999.ebuild 1593 SHA256 b5a40bce7c2f6256d10e7150f9b94d100e6bf04573b10623d04d7c577b767932 SHA512 54f17db57f178582d909588812bcafed2b8228d1eb1a5a791ce96556b53f62d1cc054d0a56fe8ddf1ad6faea8a91ff4a056c0edf39476335acb9d54aa5228944 WHIRLPOOL 098dc8057c6a35b5819c3529b248906659f3b9d788a286d505a7063bce63aca8eba14c41f052a2bb176594658606068aa0f29192aa5dbe2baf74334448b25ca1
+EBUILD shaderc-9999.ebuild 1596 BLAKE2B 6864824111ff9730f12dc9f41dd2c9c2aced77b97b868cdf90724f5d6293eff5d3a7716aaf2481c49715f26fdc9612ed998526af3d9ec4507834b92fd841d3bc SHA512 71706bf3d48d589d0b22cef84f1ca93f2819b96911868845a842b4fdd7ddcce9a1e468cbcbc784a243af8929a2a463a9cbf63935fc846d63f92476ee81f003a7
diff --git a/dev-util/shaderc/shaderc-9999.ebuild b/dev-util/shaderc/shaderc-9999.ebuild
index 939a862..6c2a33d 100644
--- a/dev-util/shaderc/shaderc-9999.ebuild
+++ b/dev-util/shaderc/shaderc-9999.ebuild
@@ -25,7 +25,7 @@ IUSE=""
RDEPEND=""
DEPEND="${PYTHON_DEPS}
dev-util/glslang:=
- dev-util/SPIRV-Tools:=[${MULTILIB_USEDEP}]"
+ dev-util/spirv-tools:=[${MULTILIB_USEDEP}]"
src_prepare() {
cmake-utils_src_prepare
@@ -35,10 +35,10 @@ src_prepare() {
CMakeLists.txt || die sed failed
# Create build-version.inc since we want to use our packaged
- # SPIRV-Tools and glslang
+ # spirv-tools and glslang
echo \"shaderc $(grep -m1 -o '^v[[:digit:]]\{4\}\.[[:digit:]]\(-dev\)\?' CHANGES) $(git describe)\" \
> glslc/src/build-version.inc
- echo \"spirv-tools $(grep -m1 -o '^v[[:digit:]]\{4\}\.[[:digit:]]\(-dev\)\?' /usr/share/doc/SPIRV-Tools-*/CHANGES) $(grep -o '[[:xdigit:]]\{40\}' /usr/include/spirv-tools/spirv_tools_commit_id.h)\" \
+ echo \"spirv-tools $(bzgrep -m1 -o '^v[[:digit:]]\{4\}\.[[:digit:]]\(-dev\)\?' /usr/share/doc/spirv-tools-*/CHANGES.bz2) $(grep -o '[[:xdigit:]]\{40\}' /usr/include/spirv-tools/spirv-tools-commit.h)\" \
>> glslc/src/build-version.inc
echo \"glslang \'\'\" >> glslc/src/build-version.inc
This alone does not appear to be sufficient to solve the build error, however.
Digging into this issue a bit further: While poking around the various .a's installed by dev-util/glslang
, I noticed that libglslang.a
doesn't provide the relevant symbols (they're undefined) - instead, they're provided by libHLSL.a
. This is true for both the libglslang.a built from third_party
as well as the one available system-wide. But comparing the linker command run for the third_party
version and your version reveals the following difference:
/usr/bin/c++ -O2 -g -DNDEBUG -rdynamic examples/online-compile/CMakeFiles/shaderc-online-compile.dir/main.cc.o -o examples/online-compile/shaderc-online-compile libshaderc/libshaderc.a libshaderc_util/libshaderc_util.a -lHLSL -lglslang -lOSDependent -lOGLCompiler -lglslang -lOSDependent -lOGLCompiler -lSPIRV-Tools-opt -lpthread -lSPIRV -lSPIRV-Tools
versus
/usr/bin/c++ -O2 -g -DNDEBUG -rdynamic examples/online-compile/CMakeFiles/shaderc-online-compile.dir/main.cc.o -o examples/online-compile/shaderc-online-compile libshaderc/libshaderc.a libshaderc_util/libshaderc_util.a -lpthread third_party/glslang/SPIRV/libSPIRV.a third_party/glslang/glslang/libglslang.a third_party/glslang/glslang/OSDependent/Unix/libOSDependent.a third_party/glslang/OGLCompilersDLL/libOGLCompiler.a third_party/glslang/hlsl/libHLSL.a third_party/spirv-tools/source/opt/libSPIRV-Tools-opt.a third_party/spirv-tools/source/libSPIRV-Tools.a
The order is different. In particular, libHLSL
is specified much later in the one based on third_party
. This is why it works.
I've found a work-around, which is to apply the following diff onto the source tree:
commit 40cea483d9a1c20f01e677222e572ae46881c6c9
Author: Niklas Haas <git@haasn.xyz>
Date: Tue May 29 07:34:00 2018 +0200
Fix the link order of libglslang and libHLSL
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.
diff --git a/glslc/CMakeLists.txt b/glslc/CMakeLists.txt
index acf6fb0..0f5d888 100644
--- a/glslc/CMakeLists.txt
+++ b/glslc/CMakeLists.txt
@@ -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})
target_link_libraries(glslc PRIVATE shaderc_util shaderc)
add_executable(glslc_exe src/main.cc)
diff --git a/libshaderc_util/CMakeLists.txt b/libshaderc_util/CMakeLists.txt
index 873540a..f4aaddc 100644
--- a/libshaderc_util/CMakeLists.txt
+++ b/libshaderc_util/CMakeLists.txt
@@ -34,7 +34,7 @@ endif(SHADERC_ENABLE_INSTALL)
find_package(Threads)
target_link_libraries(shaderc_util PRIVATE
- glslang OSDependent OGLCompiler HLSL glslang SPIRV
+ glslang OSDependent OGLCompiler glslang HLSL SPIRV
SPIRV-Tools-opt ${CMAKE_THREAD_LIBS_INIT})
shaderc_add_tests(
I guess I'll attempt to get this upstreamed in the meantime.
Hmm, seems we are not done here. That diff makes it build, but trying to link against the resulting .so still fails with unresolved symbols from libSPIRV-Tools.a
, which is particularly odd because my /usr/lib/libSPIRV-Tools.a
definitely provides the symbols it's complaining about.
It gets worse: I went back to SPIRV-Tools and glslang from your gentoo-gpu overlay (rather than the upstream ones from portage), and I ran into the exact same issue; both needing the patch to build at all as well as running into link errors when trying to use the resulting .so.
I also tried going back to an older commit (from the same date when shaderc was last built successfully for me) but I ran into the same issue. So now I'm at my wit's end, and I have no idea how I ever managed to build shaderc at all; unless it's related to some unrelated third party dependncy (e.g. gcc version)?
The only good news here is that building shaderc against the included third_party
libraries does still work successfully. So whatever the issue is, it's surely still somehow connected to that.
Okay, I found a work-around by examining the link order some more. This is the final diff that fixes all of the linking issues for me:
commit 21c8be385b3fab5edcb934a6d99f69fd389c4e67
Author: Niklas Haas <git@haasn.xyz>
Date: Tue May 29 07:34:00 2018 +0200
Fix the link order of libglslang and libHLSL
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
diff --git a/glslc/CMakeLists.txt b/glslc/CMakeLists.txt
index acf6fb0..0f5d888 100644
--- a/glslc/CMakeLists.txt
+++ b/glslc/CMakeLists.txt
@@ -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})
target_link_libraries(glslc PRIVATE shaderc_util shaderc)
add_executable(glslc_exe src/main.cc)
diff --git a/libshaderc_util/CMakeLists.txt b/libshaderc_util/CMakeLists.txt
index 873540a..6d0c465 100644
--- a/libshaderc_util/CMakeLists.txt
+++ b/libshaderc_util/CMakeLists.txt
@@ -34,8 +34,8 @@ endif(SHADERC_ENABLE_INSTALL)
find_package(Threads)
target_link_libraries(shaderc_util PRIVATE
- 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})
shaderc_add_tests(
TEST_PREFIX shaderc_util
@haasn Awesome work tracking that down. I feel the need to apologise for my absence, I took too many things on and got a little burnt out with package maintenance. I've been fixing things up, and dropping old obsolete packages and going through my message backlog.
@sjnewbury No apologies needed. It the meantime it seems gentoo has included shaderc
in their main repositories, so I personally don't need to use gentoo-gpu for these anymore. And it looks as though they incorporated my fix already.
I guess I have a few more obsolete packages to drop. It's not really a bad thing! :-) I saw they're even looking to get glvnd supported in the main tree. I think there's still a few useful features in my overlay to make it worth updating and maintaining a while longer, but hopefully it won't be needed eventually.
For the past few months, shaderc has failed to build for me via your ebuild. Checking out the google shaderc repository and building it in there works fine.
I'm using spirv-tools-9999, spirv-headers-9999 and glslang-9999 all built from the regular gentoo repository. That said, it's possible the issue is in one of those three places rather than your shaderc ebuild, since the upstream shaderc build guide involves checking out those three tools locally (into
third_party
), rather than using the system-wide versions.Build log: