loader: Check for processor of compiler, not processor of build system
authorSimon McVittie <smcv@collabora.com>
Thu, 6 Jan 2022 14:00:45 +0000 (14:00 +0000)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Thu, 6 Jan 2022 18:24:11 +0000 (11:24 -0700)
If we are cross-compiling, for example for aarch64 on x86, then the
compiler we care about here is the machine we are compiling *for*,
e.g. aarch64 (the "target" in CMake terminology, the "host system" in
Autotools/Meson) rather than the machine we are compiling *on*, e.g. x86
(the "host" in CMake terminology, the "build system" in Autotools/Meson).

Signed-off-by: Simon McVittie <smcv@collabora.com>
loader/CMakeLists.txt

index 8bb10fd1979ca871675ff4b9ee87acd14ac20471..94cb461027a7a67aef12d1bf560f68cec73e7198 100644 (file)
@@ -224,12 +224,12 @@ else(UNIX AND NOT APPLE) # i.e.: Linux
         set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}")
         set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
 
-        if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64")
+        if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
             try_compile(ASSEMBLER_WORKS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/asm_test_aarch64.S)
             if(ASSEMBLER_WORKS)
                 set(OPT_LOADER_SRCS ${OPT_LOADER_SRCS} unknown_ext_chain_gas_aarch64.S)
             endif()
-        elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86")
+        elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
             check_include_file("cet.h" HAVE_CET_H)
             if(HAVE_CET_H)
                 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS HAVE_CET_H)
@@ -250,7 +250,7 @@ else(UNIX AND NOT APPLE) # i.e.: Linux
         add_custom_target(loader_asm_gen_files DEPENDS gen_defines.asm)
     else()
         if(USE_GAS)
-            message(WARNING "Could not find working ${CMAKE_HOST_SYSTEM_PROCESSOR} GAS assembler\n${ASM_FAILURE_MSG}")
+            message(WARNING "Could not find working ${CMAKE_SYSTEM_PROCESSOR} GAS assembler\n${ASM_FAILURE_MSG}")
         else()
             message(WARNING "Assembly sources have been disabled\n${ASM_FAILURE_MSG}")
         endif()