thinlto with either GNUgold or LDD supported

This commit is contained in:
veclavtalica 2024-11-04 08:32:10 +03:00
parent 1c97053675
commit 19215d5795

View File

@ -175,10 +175,18 @@ function(give_options_without_warnings target)
$<$<BOOL:${TWN_SANITIZE}>:-fstack-protector-all -fsanitize=undefined -fsanitize=address> $<$<BOOL:${TWN_SANITIZE}>:-fstack-protector-all -fsanitize=undefined -fsanitize=address>
$<$<BOOL:${EMSCRIPTEN}>:-gsource-map>) $<$<BOOL:${EMSCRIPTEN}>:-gsource-map>)
set(BUILD_SHARED_LIBRARY_FLAGS_RELEASE if (CMAKE_C_COMPILER_LINKER_ID MATCHES GNUgold)
-Wl,--gc-sections # TODO: is it even needed with LTO? set(THINLTO_USAGE "-plugin-opt,")
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Clang>:-Wl,-plugin-opt,cache-dir=${CMAKE_CURRENT_BINARY_DIR}/linker-cache/> endif()
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Clang>:-Wl,-plugin-opt,cache-policy=prune_after=30m>) if (CMAKE_C_COMPILER_LINKER_ID MATCHES LLD)
set(THINLTO_USAGE "--thinlto-")
endif()
if (THINLTO_USAGE)
set(BUILD_SHARED_LIBRARY_FLAGS_RELEASE
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Clang>:-Wl,${THINLTO_USAGE}cache-dir=${CMAKE_CURRENT_BINARY_DIR}/linker-cache/>
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Clang>:-Wl,${THINLTO_USAGE}cache-policy=prune_after=30m>)
endif()
target_compile_options(${target} PUBLIC target_compile_options(${target} PUBLIC
${BUILD_FLAGS} ${BUILD_FLAGS}