1# SPDX-License-Identifier: Apache-2.0
2
3# For Aarch64, multilib is not an actively pursued solution for most Linux
4# distributions. Userspace is (generally) either 32-bit or 64-bit but not
5# both.
6
7# @Intent: Call a script to get userspace wordsize for comparison with CONFIG_64BIT
8execute_process(
9  COMMAND
10  ${PYTHON_EXECUTABLE}
11  ${ZEPHYR_BASE}/scripts/user_wordsize.py
12  OUTPUT_VARIABLE
13  WORDSIZE
14  OUTPUT_STRIP_TRAILING_WHITESPACE
15)
16
17if (CONFIG_64BIT)
18  if (${WORDSIZE} STREQUAL "32")
19    message(FATAL_ERROR
20      "CONFIG_64BIT=y but this Aarch64 machine has a 32-bit userspace.\n"
21      "If you were targeting native_posix_64, target native_posix instead.\n"
22      "Otherwise, be sure to define CONFIG_64BIT appropriately.\n"
23    )
24  endif()
25  zephyr_compile_options(-fPIC)
26else ()
27  if (${WORDSIZE} STREQUAL "64")
28    message(FATAL_ERROR
29      "CONFIG_64BIT=n but this Aarch64 machine has a 64-bit userspace.\n"
30      "If you were targeting native_posix, target native_posix_64 instead.\n"
31      "Otherwise, be sure to define CONFIG_64BIT appropriately.\n"
32    )
33  endif()
34endif ()
35