Commit f8e14e44 authored by Stephanos Ioannidis's avatar Stephanos Ioannidis
Browse files

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: default avatarStephanos Ioannidis <root@stephanos.io>
parent f6678fdd
Loading
Loading
Loading
Loading
+7 −0
Changes for cmake/modules/kconfig.cmake: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -135,6 +135,12 @@ 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)

@@ -161,6 +167,7 @@ set(COMMON_KCONFIG_ENV_SETTINGS
  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}
+2 −0
Changes for cmake/toolchain/llvm/generic.cmake: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -41,4 +41,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)")
+1 −0
Changes for cmake/toolchain/xt-clang/generic.cmake: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -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})")
+2 −2
Changes for lib/cpp/Kconfig: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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"
	default GLIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(TOOLCHAIN_HAS_GLIBCXX)" = "y"
	default MINIMAL_LIBCPP

@@ -126,8 +126,8 @@ config GLIBCXX_LIBCPP

config LIBCXX_LIBCPP
	bool "LLVM C++ Standard Library"
	depends on "$(TOOLCHAIN_HAS_LIBCXX)" = "y"
	depends on NEWLIB_LIBC
	depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
	select FULL_LIBCPP_SUPPORTED
	help
	  Build with LLVM C++ Standard Library (libc++) provided by LLVM