CMake platform detection uses the build machine to decide on architecture #1072

Closed
opened 2025-09-30 20:29:04 -05:00 by FatihBAKIR · 0 comments
FatihBAKIR commented 2025-09-30 20:29:04 -05:00 (Migrated from github.com)

When cross compiling, the cmake build looks at the machine running cmake to decide whether or not build the dispatch code depending on that here:

# detect architecture for DISPATCH mode
CMAKE_HOST_SYSTEM_INFORMATION(RESULT PLATFORM QUERY OS_PLATFORM)
message(STATUS "Architecture: ${PLATFORM}")

# libxxhash
if((DEFINED DISPATCH) AND (DEFINED PLATFORM))
  # Only support DISPATCH option on x86_64.
  if(("${PLATFORM}" STREQUAL "x86_64") OR ("${PLATFORM}" STREQUAL "AMD64"))

Which obviously does not build the dispatch codepath when cross compiled on an arm64 machine for an x86_64 machine, and tries to build the x86_64 code when cross compiling for arm64 on an x86_64 machine.

I think the cmake code should look at CMAKE_SYSTEM_PROCESSOR to make this decision, and should be a quick and easy PR but I want to make sure I'm not missing anything.

When cross compiling, the cmake build looks at the machine running cmake to decide whether or not build the dispatch code depending on that here: ``` # detect architecture for DISPATCH mode CMAKE_HOST_SYSTEM_INFORMATION(RESULT PLATFORM QUERY OS_PLATFORM) message(STATUS "Architecture: ${PLATFORM}") # libxxhash if((DEFINED DISPATCH) AND (DEFINED PLATFORM)) # Only support DISPATCH option on x86_64. if(("${PLATFORM}" STREQUAL "x86_64") OR ("${PLATFORM}" STREQUAL "AMD64")) ``` Which obviously does not build the dispatch codepath when cross compiled on an arm64 machine for an x86_64 machine, and tries to build the x86_64 code when cross compiling for arm64 on an x86_64 machine. I think the cmake code should look at `CMAKE_SYSTEM_PROCESSOR` to make this decision, and should be a quick and easy PR but I want to make sure I'm not missing anything.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Cyan4973/xxHash#1072
No description provided.