Commit ee0ef953 authored by Anas Nashif's avatar Anas Nashif Committed by Stephanos Ioannidis
Browse files

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: default avatarAnas Nashif <anas.nashif@intel.com>
parent dc936092
Loading
Loading
Loading
Loading
+1 −1
Changes for Kconfig.zephyr: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -481,7 +481,7 @@ 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"
	default SIZE_OPTIMIZATIONS_AGGRESSIVE if "$(TOOLCHAIN_VARIANT_COMPILER)" = "llvm"
	default SIZE_OPTIMIZATIONS
	help
	  Note that these flags shall only control the compiler
+11 −1
Changes for cmake/modules/FindHostTools.cmake: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ endif()
# Default to the host system's toolchain if we are targeting a host based target
if((${BOARD_DIR} MATCHES "boards\/native") OR ("${ARCH}" STREQUAL "posix")
   OR ("${BOARD}" STREQUAL "unit_testing"))
  if(NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "llvm")
  if(NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "host/llvm")
    set(ZEPHYR_TOOLCHAIN_VARIANT "host")
  endif()
endif()
@@ -102,6 +102,16 @@ 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}")
  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")

+1 −0
Changes for cmake/modules/kconfig.cmake: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ 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}
+14 −4
Changes for cmake/toolchain/host/generic.cmake: 14 added lines, 4 removed lines.
Original line number Diff line number Diff line
# 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)

  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)")
+2 −1
Changes for cmake/toolchain/host/gnu/Kconfig: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
# 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
Loading