cemu-project / Cemu

Cemu - Wii U emulator
https://cemu.info
Mozilla Public License 2.0
7.09k stars 551 forks source link

Linux (Arch Linux x86_64): Linking Fails Against Glslang 13.1.1 #1034

Closed V0rt3x667 closed 6 months ago

V0rt3x667 commented 9 months ago

I am trying to build Cemu on Arch Linux for x86_64 and linking fails against the Glslang library. Arch Linux is currently using Glslang version 13.1.1.

Initially I got the following error message which I fixed by changing glslang::SPIRV to glslang in /src/Cafe/CMakeLists.txt.

image

The build then proceeds until the linking stage where it then fails with the following error message.

image

I have tried compiling with Clang 16.0.6 and the LLD linker, Clang and the GCC (Gold) Linker and GCC 13.2.1 and the GCC (Gold) Linker. My build flags are:

cmake . \ -B"build" \ -G"Ninja" \ -DCMAKE_BUILD_RPATH_USE_ORIGIN="ON" \ -DCMAKE_BUILD_TYPE="Release" \ -DCMAKE_INSTALL_PREFIX="${md_inst}" \ -DCMAKE_C_COMPILER="clang" \ -DCMAKE_CXX_COMPILER="clang++" \ -DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" \ -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" \ -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \ -DCMAKE_CXX_FLAGS="${CXXFLAGS} -I/usr/include/glslang" \ -DENABLE_VCPKG="OFF" \ -DPORTABLE="OFF" \ -Wno-dev ninja -C build

Thanks for your help.

Squall-Leonhart commented 9 months ago

Upstream problem, refer to https://github.com/KhronosGroup/glslang/issues/3065

hummeltech commented 9 months ago

@V0rt3x667, I was able to get it to build successfully with this patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9dc1a6f2..025286b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -129,7 +129,7 @@ find_package(pugixml REQUIRED)
 find_package(RapidJSON REQUIRED)
 find_package(Boost COMPONENTS program_options filesystem nowide REQUIRED)
 find_package(libzip REQUIRED)
-find_package(glslang REQUIRED)
+find_package(Vulkan COMPONENTS glslang REQUIRED)
 find_package(ZLIB REQUIRED)
 find_package(zstd MODULE REQUIRED) # MODULE so that zstd::zstd is available
 find_package(OpenSSL COMPONENTS Crypto SSL REQUIRED)
@@ -137,11 +137,6 @@ find_package(glm REQUIRED)
 find_package(fmt 9 REQUIRED)
 find_package(PNG REQUIRED)

-# glslang versions older than 11.11.0 define targets without a namespace
-if (NOT TARGET glslang::SPIRV AND TARGET SPIRV)
-       add_library(glslang::SPIRV ALIAS SPIRV)
-endif()
-
 if (UNIX AND NOT APPLE)
        find_package(X11 REQUIRED)
        if (ENABLE_WAYLAND)
diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt
index 29c5a0b3..4d0e8def 100644
--- a/src/Cafe/CMakeLists.txt
+++ b/src/Cafe/CMakeLists.txt
@@ -516,7 +516,7 @@ target_link_libraries(CemuCafe PRIVATE
        Boost::nowide
        CURL::libcurl
        fmt::fmt
-       glslang::SPIRV
+       Vulkan::glslang
        ih264d
        OpenSSL::Crypto
        OpenSSL::SSL
V0rt3x667 commented 9 months ago

Thank you very much, the patch worked a treat.

hirak99 commented 9 months ago

Should we incorporate the patch into this repo?

hummeltech commented 9 months ago

@hirak99, I thought about it, however the minimum version of CMake would need to be increased to v3.24 (it's already at v3.21.1) (see docs here) and it might also break compatibility with older versions of glslang (but probably not). Therefore, some discussions need to take place. There is likely a very simple fix that can be applied to re-add support for older versions of glslang (if it does indeed break it.)

hirak99 commented 9 months ago

Thanks @hummeltech, makes sense. May be instead the arch PKGBUILD can include this patch for the time being.

kescherCode commented 8 months ago

Patch included in the AUR package for the time being. Thanks for writing the patch, @hummeltech!

hummeltech commented 8 months ago

Thanks for that @kescherCode!

kescherCode commented 6 months ago

Linking works against glslang 14. The AUR package will have the patch removed, and the requirement set to require at least glslang 14, as that's the latest version on Arch.