ARCMWDT: Fix building under hwmv2 model

On very early stage build system needs to get access to DTC preprocessor.
MWDT has no it's own preprocessor, so here zephyr-SDK preprocessor is used.
On latest build stages zephyr-SDK objcoby also required as MWDT binutils
don't support all features. This at the same time requires that
ZEPHYR_SDK_INSTALL_DIR must be initialized with valid arch-dependent
prefix.

Zephyr-SDK requires ARCH variable to be initialized before
include "generic.cmake", but in hew HWMv2 model ARCH variable will be
initialized more later. This workaround uses any (first awailable,
independent on ARCH) toolchain from SDK for DTC preprocessing only.
For other build stages ARCMWDT will be used.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
This commit is contained in:
Nikolay Agishev 2024-04-05 14:44:11 +03:00 committed by Carles Cufí
commit e97d33d0c8
2 changed files with 22 additions and 5 deletions

View file

@ -20,9 +20,16 @@ SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_AR> -sq <TARGET>")
find_program(CMAKE_GDB ${CROSS_COMPILE}mdb PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) find_program(CMAKE_GDB ${CROSS_COMPILE}mdb PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
# MWDT binutils don't support required features like section renaming, so we function(zephyr_sdk_target_cmake)
# temporarily had to use GNU objcopy instead # Scoped loading of variables set by Zephyr SDK target.cmake.
find_program(CMAKE_OBJCOPY ${ZEPHYR_SDK_CROSS_COMPILE}objcopy PATHS ${ZEPHYR_SDK_INSTALL_DIR} NO_DEFAULT_PATH) include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/target.cmake)
message(STATUS "Found GNU objcopy helper for MWDT: ${CMAKE_OBJCOPY} (Zephyr SDK ${SDK_VERSION})")
# MWDT binutils don't support required features like section renaming, so we
# temporarily had to use GNU objcopy instead
find_program(CMAKE_OBJCOPY ${CROSS_COMPILE}objcopy PATHS ${ZEPHYR_SDK_INSTALL_DIR} NO_DEFAULT_PATH)
message(STATUS "Found GNU objcopy helper for MWDT: ${CMAKE_OBJCOPY} (Zephyr SDK ${SDK_VERSION})")
endfunction()
zephyr_sdk_target_cmake()
include(${ZEPHYR_BASE}/cmake/bintools/arcmwdt/target_bintools.cmake) include(${ZEPHYR_BASE}/cmake/bintools/arcmwdt/target_bintools.cmake)

View file

@ -23,7 +23,17 @@ find_package(Zephyr-sdk 0.15 REQUIRED)
# https://github.com/zephyrproject-rtos/sdk-ng/pull/682 got merged and we switch to proper SDK # https://github.com/zephyrproject-rtos/sdk-ng/pull/682 got merged and we switch to proper SDK
# version. # version.
set(TOOLCHAIN_HOME ${ZEPHYR_SDK_INSTALL_DIR}) set(TOOLCHAIN_HOME ${ZEPHYR_SDK_INSTALL_DIR})
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/target.cmake)
# On very early stage build system needs to get access to DTC preprocessor.
# MWDT has no it's own preprocessor, so here zephyr-SDK preprocessor is used.
# At the same time zephyr-SDK requires ARCH variable to be initialized before include "generic.cmake",
# but in hew HWMv2 model ARCH variable will be initialized more later.
# This workaround uses any (first awailable, independent on ARCH) toolchain from SDK for DTC preprocessing only.
# For other build stages ARCMWDT will be used.
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/generic.cmake)
unset(TOOLCHAIN_HAS_NEWLIB CACHE)
unset(TOOLCHAIN_HAS_PICOLIBC CACHE)
set(ZEPHYR_SDK_CROSS_COMPILE ${CROSS_COMPILE}) set(ZEPHYR_SDK_CROSS_COMPILE ${CROSS_COMPILE})
# Handling to be improved in Zephyr SDK, to avoid overriding ZEPHYR_TOOLCHAIN_VARIANT by # Handling to be improved in Zephyr SDK, to avoid overriding ZEPHYR_TOOLCHAIN_VARIANT by
# find_package(Zephyr-sdk) if it's already set # find_package(Zephyr-sdk) if it's already set