From: Andarwinux Date: Thu, 21 Mar 2024 00:00:00 +0000 (+0000) Subject: loader: add support for cross-compiling with LTO and ASM X-Git-Tag: upstream/1.3.296~92 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c39f5d1f8afb85b727044edc4462e08ed37d799;p=platform%2Fupstream%2FVulkan-Loader.git loader: add support for cross-compiling with LTO and ASM --- diff --git a/BUILD.md b/BUILD.md index 69153922..9165b1cf 100644 --- a/BUILD.md +++ b/BUILD.md @@ -637,11 +637,6 @@ can be manually disabled by setting `USE_GAS` or `USE_MASM` to `OFF`. 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 diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index fba0fabf..da4144b3 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -264,7 +264,14 @@ elseif(UNIX OR MINGW) # i.e.: Linux & Apple & MinGW 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 "$/gen_defines.asm") set(ASM_OFFSET_INTERMEDIATE_LOCATION "$/CMakeFiles/asm_offset.dir/asm_offset.c.s")