meta: enable LTO

Also set -Wa,--dsp also on C files because the fxSDK sets it globally
and LTO complains if -Wa/-Xassembler options are not uniform across all
compilation units.
This commit is contained in:
Lephenixnoir 2024-05-27 19:03:50 +02:00
parent d6f709f36e
commit 6b0ea3f33e
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

View file

@ -23,6 +23,7 @@ endif()
if(FXLIBC_TARGET STREQUAL gint)
list(APPEND TARGET_FOLDERS sh-generic)
set(FXLIBC_ARCH sh)
set(FXLIBC_LTO 1)
add_definitions(-D__SUPPORT_GINT)
# Default to fxSDK install path
@ -58,11 +59,19 @@ add_compile_options(-Wall -Wextra -std=c11 -ffreestanding -Os)
if(FXLIBC_PIC)
add_compile_options(-fpic)
endif()
if(FXLIBC_LTO)
add_compile_options(-flto)
# Generate the archive with gcc-ar instead of ar as it will load the LTO
# plugin which is required to generate a usable archive.
set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_C_COMPILER_AR} qcs <TARGET> <OBJECTS>")
# Also the ranlib rule (useless because ar is passed the s flag anyway)
set(CMAKE_C_ARCHIVE_FINISH "${CMAKE_C_COMPILER_RANLIB} <TARGET>")
endif()
if(FXLIBC_ARCH STREQUAL sh)
add_compile_options(
"$<$<COMPILE_LANGUAGE:C>:-m3;-mb>"
"$<$<COMPILE_LANGUAGE:ASM>:-m4-nofpu;-mb;-Wa,--dsp>")
"$<$<COMPILE_LANGUAGE:ASM>:-m4-nofpu;-mb>" -Wa,--dsp)
endif()
# Building