Platforms not listed will use a fallback C Code path that relies on tail-call optimization to work.
No guarantees are made about the use of the fallback code paths.
-### Link Time Optimization
-
-When cross compiling, the use of Link Time Optimization (LTO) and unknown function handling
-is not supported. Either LTO needs to be turned off, or the assembly should be disabled.
-
## Tests
To build tests, make sure that the `BUILD_TESTS` option is set to true. Using
add_custom_command(OUTPUT gen_defines.asm DEPENDS asm_offset COMMAND asm_offset GAS)
else()
# Forces compiler to write the intermediate asm file, needed so that we can get sizeof/offset of info out of it.
- target_compile_options(asm_offset PRIVATE -save-temps=obj)
+ # If with lto, compiler will output IR instead of asm, so we need to explicitly disable lto here.
+ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_compile_options(asm_offset PRIVATE -save-temps=obj -fno-lto)
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ target_compile_options(asm_offset PRIVATE -save-temps=obj -fno-lto -fno-whole-program-vtables -fno-virtual-function-elimination)
+ else()
+ target_compile_options(asm_offset PRIVATE -save-temps=obj)
+ endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(ASM_OFFSET_EXECUTABLE_LOCATION "$<TARGET_FILE_DIR:asm_offset>/gen_defines.asm")
set(ASM_OFFSET_INTERMEDIATE_LOCATION "$<TARGET_FILE_DIR:asm_offset>/CMakeFiles/asm_offset.dir/asm_offset.c.s")