stlib: Extract SDL_memcpy and SDL_memset to its own file respectively

This is done such that we can disable LTO for these 2 functions when
building with MSVC.

This is due to a limitation of Link Time Code Generation (LTCG).
Code generation might generate a new reference to memset after linking
has started. The LTCG must make assumptions about where memset is
defined which is normally the C runtime.
This commit is contained in:
Anonymous Maarten
2022-06-15 20:48:54 +02:00
committed by Sam Lantinga
parent a5d338bd2d
commit ae7446a959
8 changed files with 165 additions and 104 deletions

View File

@@ -649,6 +649,11 @@ if(MSVC)
target_compile_definitions(sdl-build-options INTERFACE "-D_CRT_SECURE_NO_WARNINGS")
endif()
if(MSVC)
# Due to a limitation of Microsoft's LTO implementation, LTO must be disabled for memcpy and memset.
set_property(SOURCE src/stdlib/SDL_memcpy.c src/stdlib/SDL_memset.c APPEND PROPERTY COMPILE_FLAGS /GL-)
endif()
if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG)
# TODO: Those all seem to be quite GCC specific - needs to be