Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions module-template/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,22 @@ if(NOT RECOMPCORE_MODULE_OPT_LEVEL MATCHES "^[0-3]$")
endif()
if(RECOMPCORE_MODULE_ENABLE_IPO AND CMAKE_C_COMPILER_ID MATCHES "Clang")
include(CheckIPOSupported)
# moderngekko-port configures with CMAKE_NINJA_FORCE_RESPONSE_FILE=1, which the
# module needs: it links thousands of chunk objects and the command line does
# not fit in ARG_MAX. But check_ipo_supported's try-compile inherits the
# environment, and its static-library step then runs `ar qc libfoo.a @foo.rsp`
# -- Apple's /usr/bin/ar has no @file support, so the check fails with
# "ar: @CMakeFiles/foo.rsp: No such file or directory" and IPO is silently
# disabled. The manifest still records -flto=thin. Every module built this way
# had NO cross-translation-unit inlining. Scope the variable off for the check
# only, then restore it before the generator reads it.
set(_module_forced_rsp "$ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE}")
unset(ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE})
check_ipo_supported(RESULT RECOMPCORE_MODULE_IPO_SUPPORTED
OUTPUT RECOMPCORE_MODULE_IPO_ERROR LANGUAGES C)
if(_module_forced_rsp)
set(ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE} "${_module_forced_rsp}")
endif()
if(RECOMPCORE_MODULE_IPO_SUPPORTED)
set_property(TARGET ${MODULE_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
Expand Down