Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zephyr: fixes for platform support #1658

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PLATFORMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ In this policy, the words "must" and "must not" specify absolute requirements th
- x86_64/amd64/x64 for Windows 2022
- armeabi-v7a, arm64-v8a, x86, x86_64 for Android
- aarch64 for Apple iOS and tvOS (CMake `-DPLATFORM=OS64` and `TVOS`)
- arm64, arm (32 bit), x86, x86_64 for Zephyr

### Tier 3

Expand Down
23 changes: 11 additions & 12 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@
# Only add liboqs Zephyr module if enabled in Kconfig
if(CONFIG_LIBOQS)
# Workarounds for Zephyr
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
# We have to set that manually as CMake can't detect it properly in Zephyr
set(CMAKE_SIZEOF_VOID_P 8)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")
# Workaround as the generic name "arm" is not a supported architecture in liboqs.
# In Zephyr, however, it is exclusively used for 32-bit ARM architectures.
set(CMAKE_SYSTEM_PROCESSOR "armv7")

# We have to set that manually as CMake can't detect it properly in Zephyr
set(CMAKE_SIZEOF_VOID_P 4)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "posix")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "posix")
# Workaround to enable the native Zephyr builds on the Linux host system.
if(BOARD MATCHES "native_posix|native_sim")
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
else()
message(FATAL_ERROR "Unsupported board ${BOARD} with posix architecture")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
if(CONFIG_64BIT)
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
endif()
endif()

# We have to set that manually as CMake can't detect it properly in Zephyr
# We have to set CMAKE_SIZEOF_VOID_P manually as CMake can't detect it properly in Zephyr
if(CONFIG_64BIT)
set(CMAKE_SIZEOF_VOID_P 8)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86")
# We have to set that manually as CMake can't detect it properly in Zephyr
else()
set(CMAKE_SIZEOF_VOID_P 4)
endif()

Expand Down Expand Up @@ -143,7 +142,7 @@ if(CONFIG_LIBOQS)
# Include the liboqs headers
zephyr_include_directories(${CMAKE_CURRENT_BINARY_DIR}/build/include)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7")
# Undo the workaround from above to not interfere with other modules
set(CMAKE_SYSTEM_PROCESSOR "arm")
elseif(CMAKE_SYSTEM_PROCESSOR EQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
Expand Down
Loading