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.
This commit is contained in:
Oliver Hamlet
2025-10-22 17:49:41 +01:00
parent faa48eb2e6
commit a06078592f
+7 -1
View File
@@ -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
$<$<NOT:$<CONFIG:Debug>>:--release>
$<$<AND:$<CONFIG:Debug>,$<PLATFORM_ID:Windows>>:--config>
$<$<AND:$<CONFIG:Debug>,$<PLATFORM_ID:Windows>>:${PROJECT_SOURCE_DIR}/.cargo/msvc-debug-config.toml>