Skip to content

Commit e97d33d

Browse files
Nikolay Agishevcarlescufi
authored andcommitted
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>
1 parent b116bc7 commit e97d33d

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

cmake/bintools/arcmwdt/target.cmake

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_AR> -sq <TARGET>")
2020

2121
find_program(CMAKE_GDB ${CROSS_COMPILE}mdb PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
2222

23-
# MWDT binutils don't support required features like section renaming, so we
24-
# temporarily had to use GNU objcopy instead
25-
find_program(CMAKE_OBJCOPY ${ZEPHYR_SDK_CROSS_COMPILE}objcopy PATHS ${ZEPHYR_SDK_INSTALL_DIR} NO_DEFAULT_PATH)
26-
message(STATUS "Found GNU objcopy helper for MWDT: ${CMAKE_OBJCOPY} (Zephyr SDK ${SDK_VERSION})")
23+
function(zephyr_sdk_target_cmake)
24+
# Scoped loading of variables set by Zephyr SDK target.cmake.
25+
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/target.cmake)
26+
27+
# MWDT binutils don't support required features like section renaming, so we
28+
# temporarily had to use GNU objcopy instead
29+
find_program(CMAKE_OBJCOPY ${CROSS_COMPILE}objcopy PATHS ${ZEPHYR_SDK_INSTALL_DIR} NO_DEFAULT_PATH)
30+
message(STATUS "Found GNU objcopy helper for MWDT: ${CMAKE_OBJCOPY} (Zephyr SDK ${SDK_VERSION})")
31+
endfunction()
32+
33+
zephyr_sdk_target_cmake()
2734

2835
include(${ZEPHYR_BASE}/cmake/bintools/arcmwdt/target_bintools.cmake)

cmake/toolchain/arcmwdt/generic.cmake

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

0 commit comments

Comments
 (0)