Skip to content

Commit

Permalink
Adding support for 0.18 zephyr sdk
Browse files Browse the repository at this point in the history
* Changes have been partly taken from here:
  zephyrproject-rtos/zephyr@main...collab-sdk-0.18-dev
* This is needed because of change to the folder structure:

Old: opt/zephyr-sdk/arm-zephyr-eabi
New: opt/zephyr-sdk/gnu/arm-zephyr-eabi
     opt/zephyr-sdk/llvm

This structure has been adapet from the zephyr toolchain install script.

Signed-off-by: Sebastian Wezel <[email protected]>
  • Loading branch information
DatGizmo committed Feb 18, 2025
1 parent a195e73 commit 96f7e32
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Kconfig.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ choice COMPILER_OPTIMIZATIONS
prompt "Optimization level"
default NO_OPTIMIZATIONS if COVERAGE
default DEBUG_OPTIMIZATIONS if DEBUG
default SIZE_OPTIMIZATIONS_AGGRESSIVE if "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
default SIZE_OPTIMIZATIONS_AGGRESSIVE if "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm" \
|| "${ZEPHYR_TOOLCHAIN_VARIANT}" = "zephyr-llvm"
default SIZE_OPTIMIZATIONS
help
Note that these flags shall only control the compiler
Expand Down
4 changes: 3 additions & 1 deletion cmake/modules/FindHostTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ zephyr_file(APPLICATION_ROOT TOOLCHAIN_ROOT)

# Host-tools don't unconditionally set TOOLCHAIN_HOME anymore,
# but in case Zephyr's SDK toolchain is used, set TOOLCHAIN_HOME
if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr")
if(("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr-gnu") OR
("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr-llvm") OR
("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr"))
set(TOOLCHAIN_HOME ${HOST_TOOLS_HOME})
endif()

Expand Down
4 changes: 3 additions & 1 deletion cmake/modules/FindZephyr-sdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ endif()
# 1) Zephyr specified as toolchain (ZEPHYR_SDK_INSTALL_DIR still used if defined)
# 2) No toolchain specified == Default to Zephyr toolchain
# Until we completely deprecate it
if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
if(("zephyr-gnu" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
("zephyr-llvm" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
(NOT DEFINED ZEPHYR_TOOLCHAIN_VARIANT) OR
(DEFINED ZEPHYR_SDK_INSTALL_DIR) OR
(Zephyr-sdk_FIND_REQUIRED))
Expand Down
7 changes: 7 additions & 0 deletions cmake/toolchain/zephyr-gnu/generic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/gnu/generic.cmake)

set(TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr)

message(STATUS "Found toolchain: zephyr-sdk-gnu ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR})")
3 changes: 3 additions & 0 deletions cmake/toolchain/zephyr-gnu/target.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/gnu/target.cmake)
7 changes: 7 additions & 0 deletions cmake/toolchain/zephyr-llvm/generic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/llvm/generic.cmake)

set(TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr)

message(STATUS "Found toolchain: zephyr-sdk-llvm ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR})")
3 changes: 3 additions & 0 deletions cmake/toolchain/zephyr-llvm/target.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/llvm/target.cmake)
7 changes: 0 additions & 7 deletions cmake/toolchain/zephyr/generic.cmake

This file was deleted.

3 changes: 0 additions & 3 deletions cmake/toolchain/zephyr/target.cmake

This file was deleted.

3 changes: 2 additions & 1 deletion lib/runtime/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
config COMPILER_RT_SUPPORTED
bool
default y
depends on "${ZEPHYR_TOOLCHAIN_VARIANT}" = "llvm"
depends on "${ZEPHYR_TOOLCHAIN_VARIANT}" = "llvm" \
|| "${ZEPHYR_TOOLCHAIN_VARIANT}" = "zephyr-llvm"
help
Selected when the compiler supports compiler-rt runtime library.

Expand Down
8 changes: 6 additions & 2 deletions modules/trusted-firmware-m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,14 @@ if (CONFIG_BUILD_WITH_TFM)
# Get the toolchain variant
# TODO: Add support for cross-compile toolchain variant
# TODO: Enforce GCC version check against TF-M compiler requirements
if(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "zephyr")
if(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "zephyr-gnu")
set(TFM_TOOLCHAIN_FILE "toolchain_GNUARM.cmake")
set(TFM_TOOLCHAIN_PREFIX "arm-zephyr-eabi")
set(TFM_TOOLCHAIN_PATH ${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin)
set(TFM_TOOLCHAIN_PATH ${ZEPHYR_SDK_INSTALL_DIR}/gnu/arm-zephyr-eabi/bin)
elseif(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "zephyr-llvm")
set(TFM_TOOLCHAIN_FILE "toolchain_GNUARM.cmake")
set(TFM_TOOLCHAIN_PREFIX "arm-zephyr-eabi")
set(TFM_TOOLCHAIN_PATH ${ZEPHYR_SDK_INSTALL_DIR}/llvm/bin)
elseif(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "gnuarmemb")
set(TFM_TOOLCHAIN_FILE "toolchain_GNUARM.cmake")
set(TFM_TOOLCHAIN_PREFIX "arm-none-eabi")
Expand Down

0 comments on commit 96f7e32

Please sign in to comment.