diff --git a/arch/arm/src/cmake/clang.cmake b/arch/arm/src/cmake/clang.cmake index f86103649d18b..74af8b14b0db9 100644 --- a/arch/arm/src/cmake/clang.cmake +++ b/arch/arm/src/cmake/clang.cmake @@ -237,7 +237,7 @@ set(PREPROCESS ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} -E -P -x c) set(NUTTX_FIND_TOOLCHAIN_LIB_DEFINED true) -if(CONFIG_BUILTIN_TOOLCHAIN) +if(NOT CONFIG_COMPILER_RT_BUILTIN) if(ARGN) function(nuttx_find_toolchain_lib) execute_process( diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index ba571237ade43..c75524d885717 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -451,7 +451,7 @@ endif # Add the builtin library -ifeq ($(CONFIG_BUILTIN_TOOLCHAIN),y) +ifeq ($(CONFIG_COMPILER_RT_BUILTIN),) COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name) ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) ifeq ($(wildcard $(COMPILER_RT_LIB)),) diff --git a/boards/arm/mps/mps3-an547/configs/clang/defconfig b/boards/arm/mps/mps3-an547/configs/clang/defconfig index 1cc7240cadc3c..a2333e37423b9 100644 --- a/boards/arm/mps/mps3-an547/configs/clang/defconfig +++ b/boards/arm/mps/mps3-an547/configs/clang/defconfig @@ -27,6 +27,7 @@ CONFIG_CMSDK_UART0_RX_IRQ=50 CONFIG_CMSDK_UART0_SERIAL_CONSOLE=y CONFIG_CMSDK_UART0_TX_IRQ=49 CONFIG_CMSDK_UART=y +CONFIG_COMPILER_RT_BUILTIN=y CONFIG_DEBUG_ASSERTIONS=y CONFIG_DEBUG_BUSFAULT=y CONFIG_DEBUG_FEATURES=y diff --git a/libs/libbuiltin/Kconfig b/libs/libbuiltin/Kconfig index 3db48a0c516d6..f229d5a2aa0d5 100644 --- a/libs/libbuiltin/Kconfig +++ b/libs/libbuiltin/Kconfig @@ -29,12 +29,20 @@ config COMPILER_RT_VERSION string "Select LLVM Compiler-rt version" default "17.0.1" +config COMPILER_RT_BUILTIN + bool "Enable the rt.builtin builtin" + default n + +if COMPILER_RT_BUILTIN + config COMPILER_RT_HAS_BFLOAT16 bool "Enable support for bfloat16 in Compiler-rt" default n +endif # COMPILER_RT_BUILTIN + config COMPILER_RT_PROFILE - bool "Enable profiling support in Compiler-rt" + bool "Enable the rt.profile builtin" default n endif # BUILTIN_COMPILER_RT diff --git a/libs/libbuiltin/compiler-rt/Make.defs b/libs/libbuiltin/compiler-rt/Make.defs index 3e453798d7b23..72752f8056319 100644 --- a/libs/libbuiltin/compiler-rt/Make.defs +++ b/libs/libbuiltin/compiler-rt/Make.defs @@ -57,35 +57,42 @@ distclean:: $(call DELDIR, compiler-rt/compiler-rt) FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/include -FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins -FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH} -FLAGS += -Wno-shift-count-negative -Wno-constant-conversion -Wshift-count-overflow -FLAGS += -Wno-undef -Wno-incompatible-pointer-types -Wno-visibility -Wno-macro-redefined ################# Builtin Library ################# +ifeq ($(CONFIG_COMPILER_RT_BUILTIN),y) + +FLAGS += -Wno-undef -Wno-macro-redefined + +FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins +FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH} + CSRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/*.c) ASRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/$(ARCH)/*.S) CSRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/$(ARCH)/*.c) ifeq ($(CONFIG_COMPILER_RT_HAS_BFLOAT16),) - BFLOAT16_SRCS := compiler-rt/compiler-rt/lib/builtins/truncdfbf2.c - BFLOAT16_SRCS += compiler-rt/compiler-rt/lib/builtins/truncsfbf2.c - CSRCS := $(filter-out $(BFLOAT16_SRCS), $(CSRCS)) +BFLOAT16_SRCS := compiler-rt/compiler-rt/lib/builtins/truncdfbf2.c +BFLOAT16_SRCS += compiler-rt/compiler-rt/lib/builtins/truncsfbf2.c +CSRCS := $(filter-out $(BFLOAT16_SRCS), $(CSRCS)) +endif + endif ################# Profile Library ################# ifeq ($(CONFIG_COMPILER_RT_PROFILE),y) -FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile -FLAGS += -Wno-cleardeprecated-pragma -Wno-deprecated-pragma -Wno-incompatible-pointer-types -FLAGS += -Wno-shadow -Wno-strict-prototypes -Wno-undef -Wno-unknown-warning-option + +FLAGS += -Wno-incompatible-pointer-types -Wno-undef +FLAGS += -Wno-shadow -Wno-strict-prototypes FLAGS += -DCOMPILER_RT_HAS_UNAME -FLAGS += -fno-profile-generate + +FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile CSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.c) CPPSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.cpp) CSRCS += compiler-rt/InstrProfilingPlatform.c + endif AFLAGS += $(FLAGS)