File tree Expand file tree Collapse file tree 17 files changed +62
-24
lines changed
Expand file tree Collapse file tree 17 files changed +62
-24
lines changed Original file line number Diff line number Diff line change @@ -491,7 +491,7 @@ choice COMPILER_OPTIMIZATIONS
491491 prompt "Optimization level"
492492 default NO_OPTIMIZATIONS if COVERAGE
493493 default DEBUG_OPTIMIZATIONS if DEBUG
494- default SIZE_OPTIMIZATIONS_AGGRESSIVE if "$(ZEPHYR_TOOLCHAIN_VARIANT )" = "llvm"
494+ default SIZE_OPTIMIZATIONS_AGGRESSIVE if "$(TOOLCHAIN_VARIANT_COMPILER )" = "llvm"
495495 default SIZE_OPTIMIZATIONS
496496 help
497497 Note that these flags shall only control the compiler
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ endif()
7373# Default to the host system's toolchain if we are targeting a host based target
7474if ((${BOARD_DIR} MATCHES "boards\/ native" ) OR ("${ARCH} " STREQUAL "posix" )
7575 OR ("${BOARD} " STREQUAL "unit_testing" ))
76- if (NOT "${ZEPHYR_TOOLCHAIN_VARIANT} " STREQUAL "llvm" )
76+ if (NOT "${ZEPHYR_TOOLCHAIN_VARIANT} " STREQUAL "host/ llvm" )
7777 set (ZEPHYR_TOOLCHAIN_VARIANT "host" )
7878 endif ()
7979endif ()
@@ -102,6 +102,16 @@ endif()
102102set (TOOLCHAIN_ROOT ${TOOLCHAIN_ROOT} CACHE STRING "Zephyr toolchain root" FORCE)
103103assert(TOOLCHAIN_ROOT "Zephyr toolchain root path invalid: please set the TOOLCHAIN_ROOT-variable" )
104104
105+
106+ # Check if ZEPHYR_TOOLCHAIN_VARIANT follows "<variant_name>/<compiler>" pattern
107+ if ("${ZEPHYR_TOOLCHAIN_VARIANT} " MATCHES "^([^/]+)/([^/]+)$" )
108+ set (_variant "${CMAKE_MATCH_1} " )
109+ set (_compiler "${CMAKE_MATCH_2} " )
110+ set (ZEPHYR_TOOLCHAIN_VARIANT "${_variant} " )
111+ set (TOOLCHAIN_VARIANT_COMPILER "${_compiler} " )
112+ set (TOOLCHAIN_VARIANT_COMPILER ${_compiler} CACHE STRING "compiler used by the toolchain variant" FORCE)
113+ endif ()
114+
105115# Set cached ZEPHYR_TOOLCHAIN_VARIANT.
106116set (ZEPHYR_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} CACHE STRING "Zephyr toolchain variant" )
107117
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ set(COMMON_KCONFIG_ENV_SETTINGS
164164 KCONFIG_BINARY_DIR =${KCONFIG_BINARY_DIR}
165165 APPLICATION_SOURCE_DIR=${APPLICATION_SOURCE_DIR}
166166 ZEPHYR_TOOLCHAIN_VARIANT=${ZEPHYR_TOOLCHAIN_VARIANT}
167+ TOOLCHAIN_VARIANT_COMPILER=${TOOLCHAIN_VARIANT_COMPILER}
167168 TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR}
168169 TOOLCHAIN_HAS_NEWLIB=${_local_TOOLCHAIN_HAS_NEWLIB}
169170 TOOLCHAIN_HAS_PICOLIBC=${_local_TOOLCHAIN_HAS_PICOLIBC}
Original file line number Diff line number Diff line change 11# SPDX-License-Identifier: Apache-2.0
22
3- set (COMPILER host-gcc)
4- set (LINKER ld)
5- set (BINTOOLS host-gnu)
3+ if (TOOLCHAIN_VARIANT_COMPILER STREQUAL "gnu" OR
4+ NOT DEFINED TOOLCHAIN_VARIANT_COMPILER)
65
7- set (TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib" )
8- set (TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++" )
6+ if (NOT DEFINED TOOLCHAIN_VARIANT_COMPILER)
7+ set (TOOLCHAIN_VARIANT_COMPILER "gnu" CACHE STRING "compiler used by the toolchain variant" FORCE)
8+ endif ()
9+
10+ include (${ZEPHYR_BASE} /cmake/toolchain/host/gnu/generic.cmake)
11+
12+ set (TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_BASE} /cmake/toolchain/host/gnu)
13+ set (TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib" )
14+ set (TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++" )
15+ elseif (TOOLCHAIN_VARIANT_COMPILER STREQUAL "llvm" )
16+
17+ include (${ZEPHYR_BASE} /cmake/toolchain/host/llvm/generic.cmake)
18+ set (TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_BASE} /cmake/toolchain/host/llvm)
19+ endif ()
920
10- message (STATUS "Found toolchain: host (gcc/ld)" )
Original file line number Diff line number Diff line change 1- # Copyright (c) 2024 Basalte bv
1+ # Copyright The Zephyr Project Contributors
22# SPDX-License-Identifier: Apache-2.0
33
44config TOOLCHAIN_HOST_SUPPORTS_GNU_EXTENSIONS
55 def_bool y
66 select TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS
7+
Original file line number Diff line number Diff line change 1+
2+ set (TOOLCHAIN_VARIANT_COMPILER gcc CACHE STRING "Variant compiler being used" )
3+ set (COMPILER host-gcc)
4+ set (LINKER ld)
5+ set (BINTOOLS host-gnu)
6+
7+ set (TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib" )
8+
9+ message (STATUS "Found toolchain: host (gcc/ld)" )
Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change 1- # Copyright (c) 2023 Intel Corporation
1+ # Copyright The Zephyr Project Contributors
2+ # Copyright (c) 2024 Basalte bv
23# SPDX-License-Identifier: Apache-2.0
3-
4+ #
45choice LLVM_LINKER
56 prompt "LLVM Linker"
6- depends on "${ZEPHYR_TOOLCHAIN_VARIANT}" = "llvm"
77 default LLVM_USE_LD
88
99config LLVM_USE_LD
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments