Skip to content

Commit

Permalink
compiler-rt: Support builtin and profile compilation separately
Browse files Browse the repository at this point in the history
1. Supports combining rt.builtin in the compiler toolchain with rt.profile builtin
2. Organize the makefile under compiler-rt:
	1. Delete unnecessary content

Signed-off-by: wangmingrong1 <[email protected]>
  • Loading branch information
W-M-R committed Nov 7, 2024
1 parent 07c2ba3 commit 20f32e0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion arch/arm/src/cmake/clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),)
Expand Down
1 change: 1 addition & 0 deletions boards/arm/mps/mps3-an547/configs/clang/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion libs/libbuiltin/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 18 additions & 11 deletions libs/libbuiltin/compiler-rt/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 20f32e0

Please sign in to comment.