mahkoh / jay

A Wayland Compositor
GNU General Public License v3.0
215 stars 11 forks source link

Building jay with shaderc installed fails with a "undefined reference to `spvBinaryDestroy'" link error #225

Closed onelittlehope closed 1 month ago

onelittlehope commented 1 month ago

Hi

I wanted to try out jay and so I tried to build it in a docker container.

Docker image: debian:testing

Build steps inside the container:

DEBIAN_FRONTEND=noninteractive apt-get -qq clean
DEBIAN_FRONTEND=noninteractive apt-get -qq update
DEBIAN_FRONTEND=noninteractive apt-get -qq --assume-yes dist-upgrade

DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install -qq \
  build-essential \
  cmake \
  git \
  glslc \
  libegl1-mesa-dev \
  libgbm-dev \
  libgles2-mesa-dev \
  libinput-dev \
  libpango1.0-dev \
  libshaderc-dev \
  libudev-dev \
  libvulkan-dev \
  libxkbcommon-dev \
  mesa-common-dev \
  pipewire \
  rustup \
  xwayland

rustup toolchain install stable

mkdir ~/repos
cd ~/repos
git clone https://github.com/mahkoh/jay.git

cd ~/repos/jay

cargo install --locked jay-compositor

The build fails with a link error shown below:

root@10a685938975:~/repos/jay# cargo install --locked jay-compositor
    Updating crates.io index
  Installing jay-compositor v1.4.0
    Updating crates.io index
    Updating crates.io index
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.153
   Compiling cfg-if v1.0.0
   Compiling cc v1.0.86
   Compiling autocfg v1.1.0
   Compiling quote v1.0.35
   Compiling bitflags v2.4.2
   Compiling simd-adler32 v0.3.7
   Compiling syn v2.0.48
   Compiling xmlparser v0.13.6
   Compiling cmake v0.1.50
   Compiling syn v1.0.109
   Compiling roxmltree v0.14.1
   Compiling memchr v2.7.1
   Compiling adler v1.0.2
   Compiling serde v1.0.197
   Compiling rustix v0.38.31
   Compiling regex-syntax v0.8.2
   Compiling shaderc-sys v0.8.3
   Compiling miniz_oxide v0.7.2
   Compiling getrandom v0.2.12
   Compiling regex-automata v0.4.5
   Compiling slab v0.4.9
   Compiling repc-impl v0.1.1
   Compiling utf8parse v0.2.1
   Compiling rand_core v0.6.4
   Compiling linux-raw-sys v0.4.13
   Compiling siphasher v0.3.11
   Compiling phf_shared v0.11.2
   Compiling rand v0.8.5
   Compiling anstyle-parse v0.2.3
   Compiling serde_derive v1.0.197
   Compiling regex v1.10.3
   Compiling backtrace v0.3.69
   Compiling uapi v0.2.13
   Compiling anyhow v1.0.81
   Compiling anstyle-query v1.0.2
   Compiling thiserror v1.0.57
   Compiling gimli v0.28.1
   Compiling lazy_static v1.4.0
   Compiling anstyle v1.0.6
   Compiling version_check v0.9.4
   Compiling crc32fast v1.4.0
   Compiling serde_json v1.0.114
   Compiling colorchoice v1.0.0
   Compiling anstream v0.6.11
   Compiling uapi-proc v0.0.5
   Compiling ahash v0.8.11
   Compiling addr2line v0.21.0
   Compiling terminal_size v0.3.0
   Compiling thiserror-impl v1.0.57
   Compiling futures-macro v0.3.30
   Compiling phf_generator v0.11.2
   Compiling object v0.32.2
   Compiling num-traits v0.2.17
   Compiling lock_api v0.4.11
   Compiling heck v0.4.1
   Compiling futures-io v0.3.30
   Compiling clap_lex v0.6.0
   Compiling ash v0.37.3+1.3.251
   Compiling smallvec v1.13.1
   Compiling parking_lot_core v0.9.9
   Compiling pin-utils v0.1.0
   Compiling strsim v0.10.0
   Compiling rustc-demangle v0.1.23
   Compiling ryu v1.0.17
   Compiling futures-core v0.3.30
   Compiling pin-project-lite v0.2.13
   Compiling itoa v1.0.10
   Compiling futures-task v0.3.30
   Compiling futures-util v0.3.30
   Compiling clap_builder v4.4.18
   Compiling bincode v1.3.3
   Compiling bstr v1.9.1
   Compiling clap_derive v4.4.7
   Compiling phf_macros v0.11.2
   Compiling repc v0.1.1
   Compiling shaderc v0.8.3
   Compiling gpu-alloc-types v0.3.0
   Compiling libloading v0.7.4
   Compiling tinyvec_macros v0.1.1
   Compiling option-ext v0.2.0
   Compiling hashbrown v0.14.3
   Compiling error_reporter v1.0.0
   Compiling ppv-lite86 v0.2.17
   Compiling zerocopy v0.7.32
   Compiling equivalent v1.0.1
   Compiling log v0.4.21
   Compiling once_cell v1.19.0
   Compiling scopeguard v1.2.0
   Compiling indexmap v2.2.5
   Compiling jay-config v1.3.0
   Compiling rand_chacha v0.3.1
   Compiling dirs-sys v0.4.1
   Compiling tinyvec v1.6.0
   Compiling flate2 v1.0.28
   Compiling jay-compositor v1.4.0
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustc2I10RS/symbols.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.00.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.01.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.02.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.03.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.04.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.05.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.06.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.07.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.08.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.09.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.10.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.11.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.12.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.13.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.14.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.build_script_build.cc93a20c4999dd07-cgu.15.rcgu.o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21.4ha4i9tq3jwdiurn.rcgu.o" "-Wl,--as-needed" "-L" "/tmp/cargo-installygNsP5/release/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installygNsP5/release/deps/libcc-1bb4b29c04c95049.rlib" "/tmp/cargo-installygNsP5/release/deps/libshaderc-469f7f18aaa82b32.rlib" "/tmp/cargo-installygNsP5/release/deps/libshaderc_sys-f6b92d5de966678a.rlib" "/tmp/cargo-installygNsP5/release/deps/liblibc-d3a186197df376d7.rlib" "/tmp/cargo-installygNsP5/release/deps/libbstr-bb355a7ce366aff2.rlib" "/tmp/cargo-installygNsP5/release/deps/libmemchr-3469a6c83c4c938c.rlib" "/tmp/cargo-installygNsP5/release/deps/libanyhow-5efe9e324fb0e0f9.rlib" "/tmp/cargo-installygNsP5/release/deps/librepc-c64fb6a36621d3b8.rlib" "/tmp/cargo-installygNsP5/release/deps/librepc_impl-f08eb361a12818c6.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-d5189b81a4fa4d36.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-6a4779412a873200.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-c88c426dd6780435.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-e74540b31113a555.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-8751b61bd13c15cf.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-a8b99dba9f449259.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-f0068d76172a0372.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-c16dfaf47799564e.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-bfa26dd63e299db5.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-75a2330a693e738f.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-76779dce1f7ab63d.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-01c5cc588623cb35.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-07bb9745ec737292.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-6eacdcc91004cefb.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-ae2488b58226c836.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-52acaddcaaba04c6.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-326b78eac9ecd050.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-307ebf19f0f13d30.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d9076ee5964191bf.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/cargo-installygNsP5/release/build/jay-compositor-098dd3161d1f5c21/build_script_build-098dd3161d1f5c21" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs"
  = note: /usr/bin/ld: /tmp/cargo-installygNsP5/release/deps/libshaderc_sys-f6b92d5de966678a.rlib(shaderc.cc.o): in function `shaderc_compilation_result_spv_binary::~shaderc_compilation_result_spv_binary()':
          (.text._ZN37shaderc_compilation_result_spv_binaryD2Ev[_ZN37shaderc_compilation_result_spv_binaryD5Ev]+0x17): undefined reference to `spvBinaryDestroy'
          /usr/bin/ld: /tmp/cargo-installygNsP5/release/deps/libshaderc_sys-f6b92d5de966678a.rlib(shaderc.cc.o): in function `shaderc_compilation_result_spv_binary::~shaderc_compilation_result_spv_binary()':
          (.text._ZN37shaderc_compilation_result_spv_binaryD0Ev[_ZN37shaderc_compilation_result_spv_binaryD5Ev]+0x17): undefined reference to `spvBinaryDestroy'
          /usr/bin/ld: /tmp/cargo-installygNsP5/release/deps/libshaderc_sys-f6b92d5de966678a.rlib(compiler.cc.o): in function `shaderc_util::GlslangInitializer::GlslangInitializer()':
          (.text+0x20d): undefined reference to `glslang::InitializeProcess()'
          /usr/bin/ld: /tmp/cargo-installygNsP5/release/deps/libshaderc_sys-f6b92d5de966678a.rlib(compiler.cc.o): in function `shaderc_util::GlslangInitializer::~GlslangInitializer()':
          (.text+0x2b1): undefined reference to `glslang::FinalizeProcess()'
          /usr/bin/ld: /tmp/cargo-installygNsP5/release/deps/libshaderc_sys-f6b92d5de966678a.rlib(compiler.cc.o): in function `shaderc_util::Compiler::PreprocessShader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, shaderc_util::string_piece const&, shaderc_util::string_piece const&, shaderc_util::CountingIncluder&) const':
          (.text+0x5ace): undefined reference to `glslang::TShader::TShader(EShLanguage)'
          /usr/bin/ld: (.text+0x5b19): undefined reference to `glslang::TShader::setStringsWithLengthsAndNames(char const* const*, int const*, char const* const*, int)'
          /usr/bin/ld: (.text+0x5b7b): undefined reference to `glslang::TShader::setInvertY(bool)'
          /usr/bin/ld: (.text+0x5b8a): undefined reference to `glslang::TShader::setNanMinMaxClamp(bool)'
          /usr/bin/ld: (.text+0x5c2c): undefined reference to `glslang::TShader::preprocess(TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, glslang::TShader::Includer&)'
          /usr/bin/ld: (.text+0x5c40): undefined reference to `glslang::TShader::getInfoLog()'
          /usr/bin/ld: (.text+0x5d58): undefined reference to `glslang::TShader::~TShader()'
          /usr/bin/ld: (.text+0x5da1): undefined reference to `glslang::TShader::getInfoLog()'
          /usr/bin/ld: /tmp/cargo-installygNsP5/release/deps/libshaderc_sys-f6b92d5de966678a.rlib(compiler.cc.o): in function `shaderc_util::Compiler::Compile(shaderc_util::string_piece const&, EShLanguage, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, std::function<EShLanguage (std::ostream*, shaderc_util::string_piece const&)> const&, shaderc_util::CountingIncluder&, shaderc_util::Compiler::OutputType, std::ostream*, unsigned long*, unsigned long*) const':
          (.text+0x6845): undefined reference to `glslang::TShader::TShader(EShLanguage)'
          /usr/bin/ld: (.text+0x6897): undefined reference to `glslang::TShader::setStringsWithLengthsAndNames(char const* const*, int const*, char const* const*, int)'
          /usr/bin/ld: (.text+0x68b4): undefined reference to `glslang::TShader::setEntryPoint(char const*)'
          /usr/bin/ld: (.text+0x68c4): undefined reference to `glslang::TShader::setAutoMapBindings(bool)'
          /usr/bin/ld: (.text+0x68e2): undefined reference to `glslang::TShader::setAutoMapLocations(bool)'
          /usr/bin/ld: (.text+0x68fd): undefined reference to `glslang::TShader::setShiftImageBinding(unsigned int)'
          /usr/bin/ld: (.text+0x6911): undefined reference to `glslang::TShader::setShiftSamplerBinding(unsigned int)'
          /usr/bin/ld: (.text+0x6925): undefined reference to `glslang::TShader::setShiftTextureBinding(unsigned int)'
          /usr/bin/ld: (.text+0x6939): undefined reference to `glslang::TShader::setShiftUboBinding(unsigned int)'
          /usr/bin/ld: (.text+0x694d): undefined reference to `glslang::TShader::setShiftSsboBinding(unsigned int)'
          /usr/bin/ld: (.text+0x6961): undefined reference to `glslang::TShader::setShiftUavBinding(unsigned int)'
          /usr/bin/ld: (.text+0x6971): undefined reference to `glslang::TShader::setHlslIoMapping(bool)'
          /usr/bin/ld: (.text+0x6985): undefined reference to `glslang::TShader::setResourceSetBinding(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)'
          /usr/bin/ld: (.text+0x69c3): undefined reference to `glslang::TShader::setInvertY(bool)'
          /usr/bin/ld: (.text+0x69d3): undefined reference to `glslang::TShader::setNanMinMaxClamp(bool)'
          /usr/bin/ld: (.text+0x6a59): undefined reference to `glslang::TShader::parse(TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TShader::Includer&)'
          /usr/bin/ld: (.text+0x6a68): undefined reference to `glslang::TShader::getInfoLog()'
          /usr/bin/ld: (.text+0x6ae6): undefined reference to `glslang::TProgram::TProgram()'
          /usr/bin/ld: (.text+0x6b30): undefined reference to `glslang::TProgram::link(EShMessages)'
          /usr/bin/ld: (.text+0x6b47): undefined reference to `glslang::TProgram::getInfoLog()'
          /usr/bin/ld: (.text+0x6bf8): undefined reference to `glslang::GlslangToSpv(glslang::TIntermediate const&, std::vector<unsigned int, std::allocator<unsigned int> >&, glslang::SpvOptions*)'
          /usr/bin/ld: (.text+0x6c97): undefined reference to `glslang::TProgram::~TProgram()'
          /usr/bin/ld: (.text+0x6c9f): undefined reference to `glslang::TShader::~TShader()'
          /usr/bin/ld: (.text+0x7359): undefined reference to `glslang::TShader::setTextureSamplerTransformMode(EShTextureSamplerTransformMode)'

I didn't know how to resolve this. I found someone else having a similar issue compiling their app (not jay) against shaderc.

I was able to workaround the issue by uninstalling the libshaderc-dev package and deleting the dependencies it installed. Doing this allowed jay to build properly but it took longer as mentioned in the setup.md file:

It is recommended that you install shaderc. Otherwise it will be built from source which can take several minutes.

This is likely nothing to do with jay and may be a shaderc specific issue but am just giving a heads up for anyone else who tries to build jay. Please feel free to close the issue if its out of scope.

mahkoh commented 1 month ago

undefined reference to `spvBinaryDestroy'

That symbol is very old and most likely not missing at all. I found a similar report for arch that indicated that maybe this was a packaging error by the distribution. Maybe report this upstream to the debian maintainers.