llvm: Add support for selecting runtime library
This patch adds Kconfig options to select either GNU libgcc or LLVM compiler-rt. The 'rtlib' flag is provided in a config file, so this patch introduces 'clang_libgcc.cfg' and 'clang_compiler_rt.cfg' which enable appropriate library. The file is selected by concatenating the 'clang_' prefix with library name. Signed-off-by: Patryk Duda <pdk@semihalf.com>
This commit is contained in:
parent
7c76464c14
commit
4b94fc3da2
|
@ -34,8 +34,14 @@ macro(toolchain_ld_base)
|
|||
endif()
|
||||
|
||||
if (CONFIG_LLVM_USE_LD)
|
||||
if(CONFIG_LIBGCC_RTLIB)
|
||||
set(runtime_lib "libgcc")
|
||||
elseif(CONFIG_COMPILER_RT_RTLIB)
|
||||
set(runtime_lib "compiler_rt")
|
||||
endif()
|
||||
|
||||
zephyr_link_libraries(
|
||||
--config ${ZEPHYR_BASE}/cmake/toolchain/llvm/clang.cfg
|
||||
--config ${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -41,7 +41,13 @@ macro(toolchain_ld_base)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LIBGCC_RTLIB)
|
||||
set(runtime_lib "libgcc")
|
||||
elseif(CONFIG_COMPILER_RT_RTLIB)
|
||||
set(runtime_lib "compiler_rt")
|
||||
endif()
|
||||
|
||||
zephyr_link_libraries(
|
||||
--config ${ZEPHYR_BASE}/cmake/toolchain/llvm/clang.cfg
|
||||
--config ${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg
|
||||
)
|
||||
endmacro()
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) 2023 The ChromiumOS Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
--rtlib=compiler-rt
|
|
@ -19,7 +19,4 @@ set(BINTOOLS llvm)
|
|||
|
||||
set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
|
||||
|
||||
list(APPEND TOOLCHAIN_C_FLAGS --config ${ZEPHYR_BASE}/cmake/toolchain/llvm/clang.cfg)
|
||||
list(APPEND TOOLCHAIN_LD_FLAGS --config ${ZEPHYR_BASE}/cmake/toolchain/llvm/clang.cfg)
|
||||
|
||||
message(STATUS "Found toolchain: host (clang/ld)")
|
||||
|
|
|
@ -42,3 +42,14 @@ if(DEFINED triple)
|
|||
|
||||
unset(triple)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LIBGCC_RTLIB)
|
||||
set(runtime_lib "libgcc")
|
||||
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)
|
||||
|
|
|
@ -18,4 +18,6 @@ source "lib/open-amp/Kconfig"
|
|||
source "lib/smf/Kconfig"
|
||||
|
||||
source "lib/acpi/Kconfig"
|
||||
|
||||
source "lib/runtime/Kconfig"
|
||||
endmenu
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) 2023 The ChromiumOS Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config COMPILER_RT_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
depends on "${ZEPHYR_TOOLCHAIN_VARIANT}" = "llvm"
|
||||
help
|
||||
Selected when the compiler supports compiler-rt runtime library.
|
||||
|
||||
choice RTLIB_IMPLEMENTATION
|
||||
prompt "Runtime library implementation"
|
||||
default LIBGCC_RTLIB
|
||||
|
||||
config LIBGCC_RTLIB
|
||||
bool "GNU Libgcc"
|
||||
help
|
||||
Use libgcc as a runtime library.
|
||||
|
||||
config COMPILER_RT_RTLIB
|
||||
bool "LLVM compiler-rt"
|
||||
depends on COMPILER_RT_SUPPORTED
|
||||
help
|
||||
Use LLVM compiler-rt as a runtime library.
|
||||
|
||||
endchoice
|
|
@ -631,6 +631,7 @@ flagged.
|
|||
"CDC_ACM_PORT_NAME_",
|
||||
"CLOCK_STM32_SYSCLK_SRC_",
|
||||
"CMU",
|
||||
"COMPILER_RT_RTLIB",
|
||||
"BT_6LOWPAN", # Defined in Linux, mentioned in docs
|
||||
"CMD_CACHE", # Defined in U-Boot, mentioned in docs
|
||||
"COUNTER_RTC_STM32_CLOCK_SRC",
|
||||
|
@ -647,6 +648,7 @@ flagged.
|
|||
"FOO_SETTING_1",
|
||||
"FOO_SETTING_2",
|
||||
"LSM6DSO_INT_PIN",
|
||||
"LIBGCC_RTLIB",
|
||||
"LLVM_USE_LD", # Both LLVM_USE_* are in cmake/toolchain/llvm/Kconfig
|
||||
"LLVM_USE_LLD", # which are only included if LLVM is selected but
|
||||
# not other toolchains. Compliance check would complain,
|
||||
|
|
Loading…
Reference in New Issue