Skip to content

Commit 3079675

Browse files
stephanosiokeith-packard
authored andcommitted
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 <[email protected]>
1 parent 0c9c830 commit 3079675

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

cmake/modules/kconfig.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ else()
144144
set(_local_TOOLCHAIN_HAS_GLIBCXX n)
145145
endif()
146146

147+
if(TOOLCHAIN_HAS_LIBCXX)
148+
set(_local_TOOLCHAIN_HAS_LIBCXX y)
149+
else()
150+
set(_local_TOOLCHAIN_HAS_LIBCXX n)
151+
endif()
152+
147153
set(COMMON_KCONFIG_ENV_SETTINGS
148154
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
149155
srctree=${ZEPHYR_BASE}
@@ -166,6 +172,7 @@ set(COMMON_KCONFIG_ENV_SETTINGS
166172
TOOLCHAIN_HAS_NEWLIB=${_local_TOOLCHAIN_HAS_NEWLIB}
167173
TOOLCHAIN_HAS_PICOLIBC=${_local_TOOLCHAIN_HAS_PICOLIBC}
168174
TOOLCHAIN_HAS_GLIBCXX=${_local_TOOLCHAIN_HAS_GLIBCXX}
175+
TOOLCHAIN_HAS_LIBCXX=${_local_TOOLCHAIN_HAS_LIBCXX}
169176
EDT_PICKLE=${EDT_PICKLE}
170177
# Export all Zephyr modules to Kconfig
171178
${ZEPHYR_KCONFIG_MODULES_DIR}

cmake/toolchain/llvm/generic.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ if(NOT LLVM_TOOLCHAIN_PATH STREQUAL "")
4141
endif()
4242
endif()
4343

44+
set(TOOLCHAIN_HAS_LIBCXX ON CACHE BOOL "True if toolchain supports libc++")
45+
4446
message(STATUS "Found toolchain: llvm (clang/ld)")

cmake/toolchain/xt-clang/generic.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ set(LINKER xt-ld)
1616
# obtain license information from remote licensing servers. So here
1717
# forces the assembler ID to be GNU to speed things up a bit.
1818
set(CMAKE_ASM_COMPILER_ID "GNU")
19+
set(TOOLCHAIN_HAS_LIBCXX ON CACHE BOOL "True if toolchain supports libc++")
1920

2021
message(STATUS "Found toolchain: xt-clang (${XTENSA_TOOLCHAIN_PATH})")

lib/cpp/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ config FULL_LIBCPP_SUPPORTED
9595
choice LIBCPP_IMPLEMENTATION
9696
prompt "C++ Standard Library Implementation"
9797
default EXTERNAL_LIBCPP if REQUIRES_FULL_LIBCPP && NATIVE_BUILD
98-
default LIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
98+
default LIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(TOOLCHAIN_HAS_LIBCXX)" = "y"
9999
default GLIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(TOOLCHAIN_HAS_GLIBCXX)" = "y"
100100
default MINIMAL_LIBCPP
101101

@@ -121,9 +121,9 @@ config GLIBCXX_LIBCPP
121121

122122
config LIBCXX_LIBCPP
123123
bool "LLVM C++ Standard Library"
124+
depends on "$(TOOLCHAIN_HAS_LIBCXX)" = "y"
124125
depends on !NATIVE_APPLICATION
125126
depends on NEWLIB_LIBC
126-
depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
127127
select FULL_LIBCPP_SUPPORTED
128128
help
129129
Build with LLVM C++ Standard Library (libc++) provided by LLVM

0 commit comments

Comments
 (0)