From a06078592fecaeed5282db9c2afac5f86636d548 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 21 Oct 2025 20:23:38 +0100 Subject: [PATCH] Append -fno-lto to CXXFLAGS When building the first layer of the C++ wrapper, to fix undefined symbol errors when linking libloot as built by Manjaro Linux's default makepkg config. --- cpp/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9b1c6d1b..973e771d 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -36,7 +36,13 @@ else() endif() add_custom_target(libloot-cpp-build - COMMAND cargo build + # Force LTO to be disabled when building the first layer of the C++ wrapper, + # as it may be enabled by default, and if so that leads to undefined symbols + # in the C++ wrapper's shared library. It's not enough to just pass -fno-lto + # when building libloot-cpp itself, it also needs to be passed when building + # the cxx crate, as otherwise there will be missing cxxbridge symbols. + COMMAND ${CMAKE_COMMAND} -E env --modify "CXXFLAGS=string_append: -fno-lto" -- + cargo build $<$>:--release> $<$,$>:--config> $<$,$>:${PROJECT_SOURCE_DIR}/.cargo/msvc-debug-config.toml>