hedge-dev / hedge-dev/UnleashedRecomp

Compilation Bug: Fails to build via Clang-19/LLVM19 & libc++

Open
#913 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

compiler linux
Dominant language
C++
Stars
5.1k
Forks
421
PR merge metrics
No merged PRs in 30d

Description

Validation
  • I have checked the Issues page to see if my problem has already been reported
  • [N/A] I have confirmed that this bug does not occur in the original game running on original Xbox 360 hardware
Describe the Bug

Compiling the project with a pure LLVM19 (Gentoo) toolchain results in build failure.

Steps to Reproduce

Steps to reproduce the bug:

  1. Clone the repo (with recursion)
  2. cd into the repo
  3. Copy the 3 required files
  4. Set environment variables:
export CC="clang-19"
export CXX="clang++-19"
export CPP="clang-cpp-19"
export AR="/usr/lib/llvm/19/bin/llvm-ar"
export NM="/usr/lib/llvm/19/bin/llvm-nm"
export AS="/usr/lib/llvm/19/bin/llvm-as"
export RANLIB="/usr/lib/llvm/19/bin/llvm-ranlib"
export OBJDUMP="/usr/lib/llvm/19/bin/llvm-objdump"
export OBJCOPY="/usr/lib/llvm/19/bin/llvm-objcopy"
export STRINGS="/usr/lib/llvm/19/bin/llvm-strings"
export READELF="/usr/lib/llvm/19/bin/llvm-readelf"
export ADDR2LINE="/usr/lib/llvm/19/bin/llvm-addr2line"
export STRIP="/usr/lib/llvm/19/bin/llvm-strip"
## (omit -march=znver2 if you're not using a Ryzen 3000 CPU)
export CFLAGS="-march=znver2 -pipe -O2 -fno-plt -ftrivial-auto-var-init=zero -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Wstrict-aliasing=2 -Werror=format-security -fstack-clash-protection -fstack-protector-strong -fcf-protection --param=ssp-buffer-size=4 -fPIC -ggdb3"
export CXXFLAGS="${CFLAGS}"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS="-flto=thin -Wl,-O2,--sort-common,--as-needed,--enable-new-dtags,-z,relro,-z,now"
  1. cmake --preset linux-relwithdebinfo
  2. cmake --build ./out/build/linux-relwithdebinfo/ --target UnleashedRecomp
  3. 5 Errors
Log:
[184/1048] Building CXX object tools/XenosRecomp/XenosRecomp/CMakeFiles/XenosRecomp.dir/main.cpp.o
FAILED: tools/XenosRecomp/XenosRecomp/CMakeFiles/XenosRecomp.dir/main.cpp.o 
/usr/lib/llvm/19/bin/clang++ -DXENOS_RECOMP_INCLUDE_INPUT=\"/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/shader_common.h\" -DXENOS_RECOMP_INPUT=\"/home/USERNAME/UnleashedRecomp/UnleashedRecompLib/private\" -DXENOS_RECOMP_OUTPUT=\"/home/USERNAME/UnleashedRecomp/UnleashedRecompLib/shader/shader_cache.cpp\" -I/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/../thirdparty/smol-v/source -I/home/USERNAME/UnleashedRecomp/tools/XenonRecomp/thirdparty/xxHash/cmake_unofficial/.. -I/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/thirdparty/zstd/build/cmake/../../lib -I/home/USERNAME/UnleashedRecomp/tools/XenonRecomp/thirdparty/fmt/include -isystem /home/USERNAME/UnleashedRecomp/out/build/linux-relwithdebinfo/vcpkg_installed/x64-linux/include/directx-dxc -march=znver2 -pipe -O2 -fno-plt -ftrivial-auto-var-init=zero -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Wstrict-aliasing=2 -Werror=format-security -fstack-clash-protection -fstack-protector-strong -fcf-protection --param=ssp-buffer-size=4 -fPIC -ggdb3  -fPIC -O2 -g -DNDEBUG -std=gnu++17 -fPIE -march=sandybridge -Wno-switch -Wno-unused-variable -Wno-null-arithmetic -fms-extensions -Winvalid-pch -Xclang -include-pch -Xclang /home/USERNAME/UnleashedRecomp/out/build/linux-relwithdebinfo/tools/XenosRecomp/XenosRecomp/CMakeFiles/XenosRecomp.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/USERNAME/UnleashedRecomp/out/build/linux-relwithdebinfo/tools/XenosRecomp/XenosRecomp/CMakeFiles/XenosRecomp.dir/cmake_pch.hxx -MD -MT tools/XenosRecomp/XenosRecomp/CMakeFiles/XenosRecomp.dir/main.cpp.o -MF tools/XenosRecomp/XenosRecomp/CMakeFiles/XenosRecomp.dir/main.cpp.o.d -o tools/XenosRecomp/XenosRecomp/CMakeFiles/XenosRecomp.dir/main.cpp.o -c /home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:12:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
   12 |     fread(data.get(), 1, fileSize, file);
      |     ^~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:105:39: error: no member named 'par_unseq' in namespace 'std::execution'
  105 |         std::for_each(std::execution::par_unseq, shaders.begin(), shaders.end(), [&](auto& hashShaderPair)
      |                       ~~~~~~~~~~~~~~~~^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:129:17: error: reference to local variable 'spirv' declared in enclosing lambda expression
  129 |                 spirv->Release();
      |                 ^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:106:13: note: while substituting into a lambda expression here
  106 |             {
      |             ^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:123:27: note: 'spirv' declared here
  123 |                 IDxcBlob* spirv = dxcCompiler.compile(recompiler.out, recompiler.isPixelShader, false, true);
      |                           ^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:132:22: error: reference to local variable 'currentProgress' declared in enclosing lambda expression
  132 |                 if ((currentProgress % 10) == 0 || (currentProgress == shaders.size() - 1))
      |                      ^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:131:24: note: 'currentProgress' declared here
  131 |                 size_t currentProgress = ++progress;
      |                        ^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:132:53: error: reference to local variable 'currentProgress' declared in enclosing lambda expression
  132 |                 if ((currentProgress % 10) == 0 || (currentProgress == shaders.size() - 1))
      |                                                     ^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:131:24: note: 'currentProgress' declared here
  131 |                 size_t currentProgress = ++progress;
      |                        ^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:133:64: error: reference to local variable 'currentProgress' declared in enclosing lambda expression
  133 |                     fmt::println("Recompiling shaders... {}%", currentProgress / float(shaders.size()) * 100.0f);
      |                                                                ^
/home/USERNAME/UnleashedRecomp/tools/XenosRecomp/XenosRecomp/main.cpp:131:24: note: 'currentProgress' declared here
  131 |                 size_t currentProgress = ++progress;
      |                        ^
1 warning and 5 errors generated.
[201/1048] Building CXX object tools/XenonRecomp/XenonRecomp/CMakeFiles/XenonRecomp.dir/recompiler.cpp.o
/home/USERNAME/UnleashedRecomp/tools/XenonRecomp/XenonRecomp/recompiler.cpp:2593:17: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
 2593 |                 fread(temp.data(), 1, fileSize, f);
      |                 ^~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
ninja: build stopped: subcommand failed.
Expected Behavior

Compilation was expected to succeed, given that the project depends on Clang as a dependency.

Specifications

Fill out the following details:

  • CPU: AMD Ryzen 3700X
  • OS: Gentoo Linux (LLVM & libc++ Profile)
  • Project Version: git commit da5db2a05a314b1906acc03607583c3b2bd79506

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linux-relwithdebinfo CMake preset and reproduce the build using the listed Clang-19 and LLVM tools. Inspect tools/XenosRecomp/XenosRecomp/main.cpp around lines 105-133, where the reported errors occur. Done means the UnleashedRecomp target builds successfully with the Gentoo LLVM/libc++ toolchain.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.