Compare commits

...

19 Commits

Author SHA1 Message Date
Keith Packard
bbdb6b8db9 Use SPEED_OPTIMIZATIONS on riscv for GCC 14.3
I stuck this here for testing; if this helps, we'll put it into the SDK.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-12-16 17:18:18 +09:00
Keith Packard
1ca55ab32a cmake: Support both toolchain directory layouts
Until https://github.com/zephyrproject-rtos/sdk-ng/pull/936 is merged,
SDK 0.18 is incompatible with previous versions as the paths to
find the cmake bits is different.

Deal with that by checking for files in the wrong place as well as the
right one.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-12-16 17:18:18 +09:00
Anas Nashif
f9637a5a65 tests: skip thrd test for now
This test fails sporadically on my platforms and block SDK pre-release.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-16 17:18:18 +09:00
Anas Nashif
1a68538c64 tests: c_lib: exclude 64 qemu platform
This one keeps failing sporadically, just exclude for now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-16 17:18:18 +09:00
Keith Packard
08a1d827b6 modules/trusted-firmware-m: zephyr/gnu toolchain has a different path
The SDK has gratuitously moved all gcc toolchains to a subdirectory; adapt
to that by adding 'gnu/' when necessary

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-12-16 17:17:29 +09:00
Anas Nashif
349917eef5 twister: fix variant handling
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-16 17:17:29 +09:00
Anas Nashif
524ca95cc5 tests: skip thrd test for now
This test fails sporadically on my platforms and block SDK pre-release.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-16 17:17:29 +09:00
Anas Nashif
1d88edcac9 cmake: add support enhanced variants with multiple compilers
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-16 17:17:27 +09:00
Anas Nashif
f3aa334e57 twister: support new toolchain variant syntax
support new syntax involving compiler and toolchains with multiple
compilers, i.e. zephyr/gnu

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-16 17:13:40 +09:00
Anas Nashif
195dd3d7c1 toolchains: combine host variants
Combine toolchains provided by the host into one variant. This includes
both gcc and llvm installationt typically coming from the distribution
(on Linux).

Both gcc and llvm are now part of the 'host' variant, the default is the
gnu compiler, so setting

	ZEPHYR_TOOLCHAIN_VARIANT=host

Will select the gnu compiler. To select llvm or any other compuler
provided in this variant, use the follwoing format:

	ZEPHYR_TOOLCHAIN_VARIANT=<variant>/<compiler>

The following will select llvm:

	ZEPHYR_TOOLCHAIN_VARIANT=host/llvm

Although gnu is the default, it can also be selected using the above
syntax:

	ZEPHYR_TOOLCHAIN_VARIANT=host/gcc

This commit removes the llvm variant for now, it should be deperecated
in another commit to follow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-16 17:13:34 +09:00
Stephanos Ioannidis
236fe5df34 cmake: clang: Override -Wno-volatile with -Wno-deprecated-volatile
Override the GCC-specific `-Wno-volatile` flag specified by GCC
`compiler_flags.cmake` with the Clang-equivalent
`-Wno-deprecated-volatile`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-12-16 17:07:43 +09:00
Stephanos Ioannidis
d75d1f755e cmake: linker: lld: Do not link libc when minimal libc is used
When LLVM linker is used, the toolchain-provided C standard library is
always linked, even when the Zephyr minimal libc is selected, because `c`
is unconditionally specified in `link_order_library`, which causes `-lc` to
be specified in the linker flags.

This commit adds a check to ensure that `-lc` is not specified when the
Zephyr minimal libc is selected because it is a standalone C standard
library and it does not make sense to link two C standard libraries at
once.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-12-16 17:03:46 +09:00
Stephanos Ioannidis
7396548614 lib: cpp: Enable POSIX and GNU C extensions for libc++
LLVM C++ Standard Library aka. libc++ makes use of POSIX and GNU C
extensions in its headers.

While far from ideal, there is no other option but to globally enable these
extensions for C++ source files in order to ensure that libc++ headers can
be used.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-12-16 17:03:46 +09:00
Stephanos Ioannidis
fdb491796c tests: libcxx: Add LLVM libc++/picolibc test
This commit adds a new C++ standard library test variant that builds with
Picolibc and LLVM C++ Standard Library aka. libc++ on the supported
toolchains (e.g. LLVM Embedded Toolchain for Arm and Zephyr SDK LLVM).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-12-16 17:03:46 +09:00
Stephanos Ioannidis
b0063f9ec3 lib: cpp: Allow selecting libc++ with picolibc
LLVM C++ Standard Library aka. libc++ may be used with Picolibc -- for
example, LLVM Embedded Toolchain for Arm ships with Picolibc and libc++
compiled for Picolibc, and so does Zephyr SDK LLVM toolchain.

Ideally, we would a flag like `TOOLCHAIN_HAS_LIBCXX_PICOLIBC` indicating
that toolchain has libc++ compiled specifically for Picolibc; but, we do
not want to overcomplicate the toolchain feature flags at this time without
proper underlying infrastructure to handle it.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-12-16 17:03:45 +09:00
Stephanos Ioannidis
1a042408b8 tests: libcxx: Filter libstdc++ tests by TOOLCHAIN_HAS_GLIBCXX
Run libstdc++ tests only using the toolchains that have libstdc++ (i.e.
GCC-based toolchain).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-12-16 17:03:45 +09:00
Stephanos Ioannidis
6092c5d9bd cmake: toolchain: Introduce TOOLCHAIN_HAS_LIBCXX
This commit introduces `TOOLCHAIN_HAS_LIBCXX` CMake variable, which is set
to `y` when LLVM C++ Standard Library aka. libc++ is available.

This helps filter libc++-specific Kconfig and tests in a more refined
manner.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-12-16 17:03:45 +09:00
Stephanos Ioannidis
224fc2b58d cmake: toolchain: Introduce TOOLCHAIN_HAS_GLIBCXX
This commit introduces `TOOLCHAIN_HAS_GLIBCXX` CMake variable, which is
set to `y` when GNU C++ Standard Library aka. libstdc++ is available.

This helps filter libstdc++-specific Kconfig and tests in a more refined
manner.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-12-16 17:03:45 +09:00
Anas Nashif
0ce4215c22 tests: c_lib: exclude rx arch
Many tests failing for RX, exclude those until the arch stablizes.

See #89839

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-16 17:03:45 +09:00
33 changed files with 195 additions and 44 deletions

View File

@@ -482,7 +482,9 @@ 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"
# gcc 14.3 -Os is broken on riscv. This setting should be in the SDK, it's here for testing
default SPEED_OPTIMIZATIONS if "$(TOOLCHAIN_VARIANT_COMPILER)" = "gnu" && RISCV
default SIZE_OPTIMIZATIONS_AGGRESSIVE if "$(TOOLCHAIN_VARIANT_COMPILER)" = "llvm"
default SIZE_OPTIMIZATIONS
help
Note that these flags shall only control the compiler

View File

@@ -3,6 +3,15 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake)
# Now, let's overwrite the flags that are different in clang.
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a "-std=c++2a"
"-Wno-register" "-Wno-deprecated-volatile")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp20 "-std=c++20"
"-Wno-register" "-Wno-deprecated-volatile")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b "-std=c++2b"
"-Wno-register" "-Wno-deprecated-volatile")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp23 "-std=c++23"
"-Wno-register" "-Wno-deprecated-volatile")
########################################################
# Setting compiler properties for gcc / g++ compilers. #
########################################################

View File

@@ -16,4 +16,8 @@ if(CONFIG_CPP
set_property(TARGET linker PROPERTY link_order_library "c++")
endif()
set_property(TARGET linker APPEND PROPERTY link_order_library "c;rt")
if(NOT CONFIG_MINIMAL_LIBC)
set_property(TARGET linker APPEND PROPERTY link_order_library "c")
endif()
set_property(TARGET linker APPEND PROPERTY link_order_library "rt")

View File

@@ -75,7 +75,7 @@ endif()
# or they are clearly trying to cross-compile a native simulator based target
if((${BOARD_DIR} MATCHES "boards\/native") OR ("${ARCH}" STREQUAL "posix")
OR ("${BOARD}" STREQUAL "unit_testing"))
if((NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "llvm") AND
if((NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "host/llvm") AND
(NOT ("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "cross-compile" AND DEFINED NATIVE_TARGET_HOST)))
set(ZEPHYR_TOOLCHAIN_VARIANT "host")
endif()
@@ -98,15 +98,24 @@ 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}" MATCHES "^zephyr/?")
set(TOOLCHAIN_HOME ${HOST_TOOLS_HOME})
endif()
set(TOOLCHAIN_ROOT ${TOOLCHAIN_ROOT} CACHE STRING "Zephyr toolchain root" FORCE)
assert(TOOLCHAIN_ROOT "Zephyr toolchain root path invalid: please set the TOOLCHAIN_ROOT-variable")
# Check if ZEPHYR_TOOLCHAIN_VARIANT follows "<variant_name>/<compiler>" pattern
if("${ZEPHYR_TOOLCHAIN_VARIANT}" MATCHES "^([^/]+)/([^/]+)$")
set(_variant "${CMAKE_MATCH_1}")
set(_compiler "${CMAKE_MATCH_2}")
set(ZEPHYR_TOOLCHAIN_VARIANT "${_variant}")
set(TOOLCHAIN_VARIANT_COMPILER ${_compiler} CACHE STRING "compiler used by the toolchain variant" FORCE)
endif()
# Set cached ZEPHYR_TOOLCHAIN_VARIANT.
set(ZEPHYR_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} CACHE STRING "Zephyr toolchain variant")
set(ZEPHYR_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} CACHE STRING "Zephyr toolchain variant" FORCE)
# Configure the toolchain based on what SDK/toolchain is in use.
include(${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}/generic.cmake)

View File

@@ -54,7 +54,7 @@ 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_TOOLCHAIN_VARIANT} MATCHES "^zephyr/?") OR
(NOT DEFINED ZEPHYR_TOOLCHAIN_VARIANT) OR
(DEFINED ZEPHYR_SDK_INSTALL_DIR) OR
(Zephyr-sdk_FIND_REQUIRED)

View File

@@ -129,6 +129,18 @@ else()
set(_local_TOOLCHAIN_HAS_PICOLIBC n)
endif()
if(TOOLCHAIN_HAS_GLIBCXX)
set(_local_TOOLCHAIN_HAS_GLIBCXX y)
else()
set(_local_TOOLCHAIN_HAS_GLIBCXX n)
endif()
if(TOOLCHAIN_HAS_LIBCXX)
set(_local_TOOLCHAIN_HAS_LIBCXX y)
else()
set(_local_TOOLCHAIN_HAS_LIBCXX n)
endif()
# APP_DIR: Path to the main image (sysbuild) or synonym for APPLICATION_SOURCE_DIR (non-sysbuild)
zephyr_get(APP_DIR VAR APP_DIR APPLICATION_SOURCE_DIR)
@@ -154,9 +166,12 @@ set(COMMON_KCONFIG_ENV_SETTINGS
KCONFIG_BINARY_DIR=${KCONFIG_BINARY_DIR}
APPLICATION_SOURCE_DIR=${APPLICATION_SOURCE_DIR}
ZEPHYR_TOOLCHAIN_VARIANT=${ZEPHYR_TOOLCHAIN_VARIANT}
TOOLCHAIN_VARIANT_COMPILER=${TOOLCHAIN_VARIANT_COMPILER}
TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR}
TOOLCHAIN_HAS_NEWLIB=${_local_TOOLCHAIN_HAS_NEWLIB}
TOOLCHAIN_HAS_PICOLIBC=${_local_TOOLCHAIN_HAS_PICOLIBC}
TOOLCHAIN_HAS_GLIBCXX=${_local_TOOLCHAIN_HAS_GLIBCXX}
TOOLCHAIN_HAS_LIBCXX=${_local_TOOLCHAIN_HAS_LIBCXX}
EDT_PICKLE=${EDT_PICKLE}
# Export all Zephyr modules to Kconfig
${ZEPHYR_KCONFIG_MODULES_DIR}

View File

@@ -54,3 +54,4 @@ if(NOT CROSS_COMPILE_TARGET)
endif()
set(TOOLCHAIN_HAS_NEWLIB ON CACHE BOOL "True if toolchain supports newlib")
set(TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++")

View File

@@ -18,6 +18,8 @@ set(SYSROOT_TARGET arm-none-eabi)
set(CROSS_COMPILE ${TOOLCHAIN_HOME}/bin/${CROSS_COMPILE_TARGET}-)
set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET})
set(TOOLCHAIN_HAS_NEWLIB ON CACHE BOOL "True if toolchain supports newlib")
set(TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++")
message(STATUS "Found toolchain: gnuarmemb (${GNUARMEMB_TOOLCHAIN_PATH})")

View File

@@ -1,9 +1,20 @@
# SPDX-License-Identifier: Apache-2.0
set(COMPILER host-gcc)
set(LINKER ld)
set(BINTOOLS host-gnu)
if(TOOLCHAIN_VARIANT_COMPILER STREQUAL "gnu" OR
NOT DEFINED TOOLCHAIN_VARIANT_COMPILER)
set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
if (NOT DEFINED TOOLCHAIN_VARIANT_COMPILER)
set(TOOLCHAIN_VARIANT_COMPILER "gnu" CACHE STRING "compiler used by the toolchain variant" FORCE)
endif()
include(${ZEPHYR_BASE}/cmake/toolchain/host/gnu/generic.cmake)
set(TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_BASE}/cmake/toolchain/host/gnu)
set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
set(TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++")
elseif(TOOLCHAIN_VARIANT_COMPILER STREQUAL "llvm")
include(${ZEPHYR_BASE}/cmake/toolchain/host/llvm/generic.cmake)
set(TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_BASE}/cmake/toolchain/host/llvm)
endif()
message(STATUS "Found toolchain: host (gcc/ld)")

View File

@@ -1,6 +1,7 @@
# Copyright (c) 2024 Basalte bv
# Copyright The Zephyr Project Contributors
# SPDX-License-Identifier: Apache-2.0
config TOOLCHAIN_HOST_SUPPORTS_GNU_EXTENSIONS
def_bool y
select TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS

View File

@@ -0,0 +1,9 @@
set(TOOLCHAIN_VARIANT_COMPILER gcc CACHE STRING "Variant compiler being used")
set(COMPILER host-gcc)
set(LINKER ld)
set(BINTOOLS host-gnu)
set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
message(STATUS "Found toolchain: host (gcc/ld)")

View File

@@ -0,0 +1 @@
# SPDX-License-Identifier: Apache-2.0

View File

@@ -1,9 +1,9 @@
# Copyright (c) 2023 Intel Corporation
# Copyright The Zephyr Project Contributors
# Copyright (c) 2024 Basalte bv
# SPDX-License-Identifier: Apache-2.0
#
choice LLVM_LINKER
prompt "LLVM Linker"
depends on "${ZEPHYR_TOOLCHAIN_VARIANT}" = "llvm"
default LLVM_USE_LD
config LLVM_USE_LD

View File

@@ -1,11 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# Purpose of the generic.cmake is to define a generic C compiler which can be
# used for devicetree pre-processing and other pre-processing tasks which must
# be performed before the target can be determined.
# Todo: deprecate CLANG_ROOT_DIR
set_ifndef(LLVM_TOOLCHAIN_PATH "$ENV{CLANG_ROOT_DIR}")
set(TOOLCHAIN_VARIANT_COMPILER llvm CACHE STRING "Variant compiler being used")
zephyr_get(LLVM_TOOLCHAIN_PATH)
if(LLVM_TOOLCHAIN_PATH)
@@ -41,4 +37,6 @@ if(NOT LLVM_TOOLCHAIN_PATH STREQUAL "")
endif()
endif()
set(TOOLCHAIN_HAS_LIBCXX ON CACHE BOOL "True if toolchain supports libc++")
message(STATUS "Found toolchain: llvm (clang/ld)")

View File

@@ -55,5 +55,7 @@ elseif(CONFIG_COMPILER_RT_RTLIB)
set(runtime_lib "compiler_rt")
endif()
list(APPEND TOOLCHAIN_C_FLAGS --config=${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg)
list(APPEND TOOLCHAIN_LD_FLAGS --config=${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg)
list(APPEND TOOLCHAIN_C_FLAGS
--config=${ZEPHYR_BASE}/cmake/toolchain/host/llvm/clang_${runtime_lib}.cfg)
list(APPEND TOOLCHAIN_LD_FLAGS
--config=${ZEPHYR_BASE}/cmake/toolchain/host/llvm/clang_${runtime_lib}.cfg)

View File

@@ -1,3 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# This file intentionally left blank.
if(TOOLCHAIN_VARIANT_COMPILER STREQUAL "gnu" OR
TOOLCHAIN_VARIANT_COMPILER STREQUAL "default")
include(${ZEPHYR_BASE}/cmake/toolchain/host/gnu/target.cmake)
elseif (TOOLCHAIN_VARIANT_COMPILER STREQUAL "llvm")
include(${ZEPHYR_BASE}/cmake/toolchain/host/llvm/target.cmake)
else()
message(FATAL_ERROR "Unsupported TOOLCHAIN_VARIANT_COMPILER: ${TOOLCHAIN_VARIANT_COMPILER}")
endif()

View File

@@ -16,5 +16,6 @@ set(LINKER xt-ld)
# obtain license information from remote licensing servers. So here
# forces the assembler ID to be GNU to speed things up a bit.
set(CMAKE_ASM_COMPILER_ID "GNU")
set(TOOLCHAIN_HAS_LIBCXX ON CACHE BOOL "True if toolchain supports libc++")
message(STATUS "Found toolchain: xt-clang (${XTENSA_TOOLCHAIN_PATH})")

View File

@@ -1,7 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/generic.cmake)
if(TOOLCHAIN_VARIANT_COMPILER STREQUAL "gnu" OR
NOT DEFINED TOOLCHAIN_VARIANT_COMPILER)
if(EXISTS ${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/gnu/generic.cmake)
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/gnu/generic.cmake)
else()
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/generic.cmake)
endif()
set(TOOLCHAIN_VARIANT_COMPILER "gnu" CACHE STRING "compiler used by the toolchain variant" FORCE)
set(TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr)
set(TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr)
# Zephyr SDK < 0.17.1 does not set TOOLCHAIN_HAS_GLIBCXX
set(TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++")
message(STATUS "Found toolchain: zephyr ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR})")
elseif(TOOLCHAIN_VARIANT_COMPILER STREQUAL "llvm")
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/llvm/generic.cmake)
set(TOOLCHAIN_VARIANT_COMPILER "llvm" CACHE STRING "compiler used by the toolchain variant" FORCE)
message(STATUS "Found toolchain: zephyr ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR})")
set(TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr)
message(STATUS "Found toolchain: zephyr ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR})")
else()
message(FATAL_ERROR "Unsupported TOOLCHAIN_VARIANT_COMPILER: ${TOOLCHAIN_VARIANT_COMPILER}")
endif()

View File

@@ -1,3 +1,16 @@
# SPDX-License-Identifier: Apache-2.0
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/target.cmake)
if(TOOLCHAIN_VARIANT_COMPILER STREQUAL "gnu" OR
TOOLCHAIN_VARIANT_COMPILER STREQUAL "default")
set(TOOLCHAIN_VARIANT_COMPILER gnu CACHE STRING "Variant compiler being used")
if(EXISTS ${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/gnu/target.cmake)
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/gnu/target.cmake)
else()
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/target.cmake)
endif()
elseif (TOOLCHAIN_VARIANT_COMPILER STREQUAL "llvm")
set(TOOLCHAIN_VARIANT_COMPILER llvm CACHE STRING "Variant compiler being used")
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/llvm/target.cmake)
else()
message(FATAL_ERROR "Unsupported TOOLCHAIN_VARIANT_COMPILER: ${TOOLCHAIN_VARIANT_COMPILER}")
endif()

View File

@@ -32,10 +32,12 @@ find_package(HostTools)
if("${FORMAT}" STREQUAL "json")
set(json "{\"ZEPHYR_TOOLCHAIN_VARIANT\" : \"${ZEPHYR_TOOLCHAIN_VARIANT}\", ")
string(APPEND json "\"SDK_VERSION\": \"${SDK_VERSION}\", ")
string(APPEND json "\"TOOLCHAIN_VARIANT_COMPILER\": \"${TOOLCHAIN_VARIANT_COMPILER}\", ")
string(APPEND json "\"ZEPHYR_SDK_INSTALL_DIR\" : \"${ZEPHYR_SDK_INSTALL_DIR}\"}")
_message("${json}")
else()
message(STATUS "ZEPHYR_TOOLCHAIN_VARIANT: ${ZEPHYR_TOOLCHAIN_VARIANT}")
message(STATUS "TOOLCHAIN_VARIANT_COMPILER: ${TOOLCHAIN_VARIANT_COMPILER}")
if(DEFINED SDK_VERSION)
message(STATUS "SDK_VERSION: ${SDK_VERSION}")
endif()

View File

@@ -1,5 +1,13 @@
# SPDX-License-Identifier: Apache-2.0
if(CONFIG_LIBCXX_LIBCPP)
# LLVM C++ Standard Library makes use of POSIX and GNU C extension functions
# in its headers.
zephyr_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:_POSIX_C_SOURCE=200809L>)
zephyr_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:_XOPEN_SOURCE=700>)
zephyr_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:_GNU_SOURCE>)
endif()
add_subdirectory(abi)
add_subdirectory_ifdef(CONFIG_MINIMAL_LIBCPP minimal)

View File

@@ -101,7 +101,7 @@ config FULL_LIBCPP_SUPPORTED
choice LIBCPP_IMPLEMENTATION
prompt "C++ Standard Library Implementation"
default EXTERNAL_LIBCPP if REQUIRES_FULL_LIBCPP && NATIVE_BUILD
default LIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
default LIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(TOOLCHAIN_HAS_LIBCXX)" = "y" && "$(TOOLCHAIN_VARIANT_COMPILER)" = "llvm"
default GLIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP
default MINIMAL_LIBCPP
@@ -117,6 +117,7 @@ config MINIMAL_LIBCPP
config GLIBCXX_LIBCPP
bool "GNU C++ Standard Library"
depends on "$(TOOLCHAIN_HAS_GLIBCXX)" = "y"
depends on NEWLIB_LIBC || PICOLIBC
select FULL_LIBCPP_SUPPORTED
help
@@ -125,8 +126,9 @@ config GLIBCXX_LIBCPP
config LIBCXX_LIBCPP
bool "LLVM C++ Standard Library"
depends on NEWLIB_LIBC
depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
depends on "$(TOOLCHAIN_HAS_LIBCXX)" = "y"
depends on NEWLIB_LIBC || PICOLIBC
depends on "$(TOOLCHAIN_VARIANT_COMPILER)" = "llvm"
select FULL_LIBCPP_SUPPORTED
help
Build with LLVM C++ Standard Library (libc++) provided by LLVM

View File

@@ -4,7 +4,7 @@
config COMPILER_RT_SUPPORTED
bool
default y
depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
depends on "$(TOOLCHAIN_VARIANT_COMPILER)" = "llvm"
help
Selected when the compiler supports compiler-rt runtime library.

View File

@@ -232,7 +232,13 @@ if(CONFIG_BUILD_WITH_TFM)
if(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "zephyr")
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)
if(${TOOLCHAIN_VARIANT_COMPILER} STREQUAL "gnu")
set(TFM_TOOLCHAIN_PATH ${ZEPHYR_SDK_INSTALL_DIR}/gnu/arm-zephyr-eabi/bin)
elseif(${TOOLCHAIN_VARIANT_COMPILER} STREQUAL "llvm")
set(TFM_TOOLCHAIN_PATH ${ZEPHYR_SDK_INSTALL_DIR}/llvm/bin)
else()
set(TFM_TOOLCHAIN_PATH ${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin)
endif()
elseif(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "gnuarmemb")
set(TFM_TOOLCHAIN_FILE "toolchain_GNUARM.cmake")
set(TFM_TOOLCHAIN_PREFIX "arm-none-eabi")

View File

@@ -1196,5 +1196,7 @@ class TwisterEnv:
if result['returncode'] != 0:
print(f"E: {result['returnmsg']}")
sys.exit(2)
self.toolchain = json.loads(result['stdout'])['ZEPHYR_TOOLCHAIN_VARIANT']
logger.info(f"Using '{self.toolchain}' toolchain.")
_variant = json.loads(result['stdout'])['ZEPHYR_TOOLCHAIN_VARIANT']
self.compiler = json.loads(result['stdout'])['TOOLCHAIN_VARIANT_COMPILER']
self.toolchain = f"{_variant}/{self.compiler}"
logger.info(f"Using '{self.toolchain}' toolchain variant.")

View File

@@ -74,7 +74,7 @@ class TestInstance:
if testsuite.detailed_test_id:
self.build_dir = os.path.join(
outdir, platform.normalized_name, self.toolchain, testsuite.name
outdir, platform.normalized_name, self.toolchain.replace('/', '_'), testsuite.name
)
else:
# if suite is not in zephyr,

View File

@@ -884,11 +884,10 @@ class TestPlan:
if itoolchain:
toolchain = itoolchain
elif plat.arch in ['posix', 'unit']:
# workaround until toolchain variant in zephyr is overhauled and improved.
if self.env.toolchain in ['llvm']:
toolchain = 'llvm'
if self.env.toolchain in ['host/llvm']:
toolchain = 'host/llvm'
else:
toolchain = 'host'
toolchain = 'host/gnu'
else:
toolchain = "zephyr" if not self.env.toolchain else self.env.toolchain
@@ -1002,7 +1001,9 @@ class TestPlan:
instance.add_filter("Native platform requires Linux", Filters.ENVIRONMENT)
if not force_toolchain \
and toolchain and (toolchain not in plat.supported_toolchains):
and toolchain and (toolchain not in plat.supported_toolchains) and \
(toolchain.split('/')[0] not in plat.supported_toolchains):
instance.add_filter(
f"Not supported by the toolchain: {toolchain}",
Filters.PLATFORM

View File

@@ -35,7 +35,7 @@ config COVERAGE_NATIVE_GCOV
config COVERAGE_NATIVE_SOURCE
bool "Host compiler source based code coverage"
depends on NATIVE_BUILD
depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
depends on "$(TOOLCHAIN_VARIANT_COMPILER)" = "llvm"
help
Build natively with the compiler source based coverage options.
Today this is only supported with LLVM

View File

@@ -2,6 +2,9 @@ common:
tags:
- clib
ignore_faults: true
arch_exclude:
# see #89839
- rx
integration_platforms:
- mps2/an385
tests:

View File

@@ -9,6 +9,11 @@ common:
platform_key:
- arch
- simulation
filter: not CONFIG_NATIVE_APPLICATION
arch_exclude:
# see #89839
- rx
skip: true
tests:
libraries.libc.c11_threads.minimal:
tags: minimal_libc

View File

@@ -1,6 +1,11 @@
common:
arch_exclude:
# see #89839
- rx
tests:
# GNU C++ Standard Library (libstdc++)
cpp.libcxx.glibcxx.newlib:
filter: TOOLCHAIN_HAS_NEWLIB == 1
filter: TOOLCHAIN_HAS_GLIBCXX == 1 and TOOLCHAIN_HAS_NEWLIB == 1
toolchain_exclude: xcc
min_flash: 54
min_ram: 24
@@ -12,7 +17,7 @@ tests:
integration_platforms:
- mps2/an385
cpp.libcxx.glibcxx.newlib_nano:
filter: TOOLCHAIN_HAS_NEWLIB == 1 and CONFIG_HAS_NEWLIB_LIBC_NANO
filter: TOOLCHAIN_HAS_GLIBCXX == 1 and TOOLCHAIN_HAS_NEWLIB == 1 and CONFIG_HAS_NEWLIB_LIBC_NANO
toolchain_exclude: xcc
min_flash: 54
tags: cpp
@@ -24,7 +29,7 @@ tests:
integration_platforms:
- mps2/an385
cpp.libcxx.glibcxx.picolibc:
filter: TOOLCHAIN_HAS_PICOLIBC == 1
filter: TOOLCHAIN_HAS_GLIBCXX == 1 and TOOLCHAIN_HAS_PICOLIBC == 1
toolchain_exclude: xcc
tags: cpp
timeout: 60
@@ -34,6 +39,19 @@ tests:
- CONFIG_CPP_EXCEPTIONS=y
integration_platforms:
- mps2/an385
# LLVM C++ Standard Library (libc++)
cpp.libcxx.libcxx.picolibc:
filter: TOOLCHAIN_HAS_LIBCXX == 1 and TOOLCHAIN_HAS_PICOLIBC == 1
toolchain_exclude: xcc
tags: cpp
timeout: 60
extra_configs:
- CONFIG_PICOLIBC=y
- CONFIG_LIBCXX_LIBCPP=y
- CONFIG_CPP_EXCEPTIONS=y
integration_platforms:
- mps2/an385
# ARC MWDT C++ Standard Library
cpp.libcxx.arcmwdtlib:
toolchain_allow: arcmwdt
min_flash: 54
@@ -41,6 +59,7 @@ tests:
extra_configs:
- CONFIG_ARCMWDT_LIBC=y
- CONFIG_ARCMWDT_LIBCPP=y
# Host C++ Standard Library
cpp.libcxx.host:
arch_allow: posix
tags: cpp