From: Christopher Degawa Date: Mon, 2 Oct 2023 02:38:28 +0000 (-0500) Subject: loader: Fix cross-compiling with jwasm X-Git-Tag: upstream/1.3.268~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffb46f8f789a7cf34a0c617b83308fa8b74c958a;p=platform%2Fupstream%2FVulkan-Loader.git loader: Fix cross-compiling with jwasm fixes a few issues when cross-compiling from linux to windows using mingw-w64. Particularly with the result of jwasm not being used in the library. Additionally, allows running the generated asm_offset binary with wine, if the user provided the wrapper in their toolchain with `-DCMAKE_CROSSCOMPILING_EMULATOR=wine`. Signed-off-by: Christopher Degawa --- diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 7ccfbed8..d7d6383d 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -115,8 +115,9 @@ set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG}Note that this may be unsafe, as the C co set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG} the stack frame for certain calls. If the compiler does not do this, then unknown device") set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG} extensions will suffer from a corrupted stack.") if(WIN32) - if(MINGW) - find_program(JWASM_FOUND jwasm) + option(USE_MASM "Use MASM" ON) + if(USE_MASM AND MINGW) + find_program(JWASM_FOUND NAMES jwasm) if (JWASM_FOUND) set(CMAKE_ASM_MASM_COMPILER ${JWASM_FOUND}) execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE COMPILER_VERSION_OUTPUT) @@ -130,14 +131,10 @@ if(WIN32) endif() endif() endif() - if (NOT MSVC) - set(USE_MASM OFF) - endif () - option(USE_MASM "Use MASM" ON) if (USE_MASM) - enable_language(ASM_MASM) - endif () - if(CMAKE_ASM_MASM_COMPILER_WORKS OR JWASM_FOUND) + enable_language(ASM_MASM) + endif() + if(CMAKE_ASM_MASM_COMPILER_WORKS) if(MINGW) set(CMAKE_ASM_MASM_FLAGS ${CMAKE_ASM_MASM_FLAGS} ${JWASM_FLAGS}) elseif(NOT CMAKE_CL_64 AND NOT JWASM_FOUND) @@ -146,8 +143,8 @@ if(WIN32) add_executable(asm_offset asm_offset.c) target_link_libraries(asm_offset PRIVATE loader_specific_options) - # If not cross compiling, run asm_offset to generage gen_defines.asm - if (NOT CMAKE_CROSSCOMPILING) + # If am emulator is provided (Like Wine), or running on native, run asm_offset to generate gen_defines.asm + if (CMAKE_CROSSCOMPILING_EMULATOR OR NOT CMAKE_CROSSCOMPILING) add_custom_command(OUTPUT gen_defines.asm DEPENDS asm_offset COMMAND asm_offset MASM) else() # Forces compiler to write the intermediate asm file, needed so that we can get sizeof/offset of info out of it. @@ -279,11 +276,7 @@ if(WIN32) set(RC_FILE_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/loader.rc) endif() - if (MSVC) - set(LOADER_UNKNOWN_CHAIN_LIBRARY $) - else() - set(LOADER_UNKNOWN_CHAIN_LIBRARY "") - endif() + set(LOADER_UNKNOWN_CHAIN_LIBRARY $<$:$>) add_library(vulkan SHARED