libbuitin/compiler_rt: Supports separate builtin rt.builtins or rt.profile

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
wangmingrong1 2024-11-12 11:21:46 +08:00 committed by Xiang Xiao
parent bfdfbc10ab
commit e3917e2f09
7 changed files with 37 additions and 25 deletions

View file

@ -5,36 +5,42 @@
comment "Toolchain Library Support" comment "Toolchain Library Support"
config LIB_BUILTIN
bool
config LIB_COMPILER_RT
bool
choice choice
prompt "Builtin toolchain support" prompt "Builtin toolchain support"
default BUILTIN_TOOLCHAIN default BUILTIN_TOOLCHAIN
---help--- ---help---
Choose to compile libraries related to toolchain into the OS Select the builtin library
config BUILTIN_COMPILER_RT config BUILTIN_COMPILER_RT
bool "Builtin LLVM Compiler-rt" bool "Builtin LLVM libclang_rt.builtins"
select LIB_BUILTIN
select LIB_COMPILER_RT
---help--- ---help---
Compile the LLVM Compiler-rt library into the OS. Compile the LLVM Compiler-rt library into the OS.
config BUILTIN_TOOLCHAIN config BUILTIN_TOOLCHAIN
bool "Link the toolchain library" bool "Link toolchain builtin library to the OS"
---help---
Use the toolchain library that comes with the compiler
endchoice endchoice
if BUILTIN_COMPILER_RT config COVERAGE_COMPILER_RT
bool "Builtin libclang_rt.profile"
select LIB_BUILTIN
select LIB_COMPILER_RT
default n
config COMPILER_RT_VERSION config LIB_COMPILER_RT_VERSION
string "Select LLVM Compiler-rt version" string "Select LLVM Compiler-rt version"
depends on LIB_COMPILER_RT
default "17.0.1" default "17.0.1"
config COMPILER_RT_HAS_BFLOAT16 config LIB_COMPILER_RT_HAS_BFLOAT16
bool "Enable support for bfloat16 in Compiler-rt" bool "Enable support for bfloat16 in Compiler-rt"
depends on LIB_COMPILER_RT
default n default n
config COMPILER_RT_PROFILE
bool "Enable profiling support in Compiler-rt"
default n
endif # BUILTIN_COMPILER_RT

View file

@ -26,7 +26,7 @@ BINDIR ?= bin
KBIN = libkbuiltin$(LIBEXT) KBIN = libkbuiltin$(LIBEXT)
KBINDIR = kbin KBINDIR = kbin
ifeq ($(CONFIG_BUILTIN_COMPILER_RT),y) ifeq ($(CONFIG_LIB_COMPILER_RT),y)
include compiler-rt/Make.defs include compiler-rt/Make.defs
endif endif

View file

@ -20,7 +20,7 @@
include $(TOPDIR)/Make.defs include $(TOPDIR)/Make.defs
COMPILER_RT_VERSION=$(CONFIG_COMPILER_RT_VERSION) COMPILER_RT_VERSION=$(CONFIG_LIB_COMPILER_RT_VERSION)
ifeq ($(CONFIG_ARCH_ARM),y) ifeq ($(CONFIG_ARCH_ARM),y)
ARCH = arm ARCH = arm
@ -67,26 +67,32 @@ distclean::
$(call DELDIR, compiler-rt/compiler-rt) $(call DELDIR, compiler-rt/compiler-rt)
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/include FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/include
################# Builtin Library #################
ifeq ($(CONFIG_BUILTIN_COMPILER_RT),y)
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH} FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH}
FLAGS += -Wno-shift-count-negative -Wno-constant-conversion -Wshift-count-overflow FLAGS += -Wno-shift-count-negative -Wno-constant-conversion -Wshift-count-overflow
FLAGS += -Wno-undef -Wno-incompatible-pointer-types -Wno-visibility -Wno-macro-redefined FLAGS += -Wno-undef -Wno-incompatible-pointer-types -Wno-visibility -Wno-macro-redefined
################# Builtin Library #################
CSRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/*.c) CSRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/*.c)
ASRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/$(ARCH)/*.S) ASRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/$(ARCH)/*.S)
CSRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/$(ARCH)/*.c) CSRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/$(ARCH)/*.c)
ifeq ($(CONFIG_COMPILER_RT_HAS_BFLOAT16),) ifeq ($(CONFIG_LIB_COMPILER_RT_HAS_BFLOAT16),)
BFLOAT16_SRCS := compiler-rt/compiler-rt/lib/builtins/truncdfbf2.c BFLOAT16_SRCS := compiler-rt/compiler-rt/lib/builtins/truncdfbf2.c
BFLOAT16_SRCS += compiler-rt/compiler-rt/lib/builtins/truncsfbf2.c BFLOAT16_SRCS += compiler-rt/compiler-rt/lib/builtins/truncsfbf2.c
CSRCS := $(filter-out $(BFLOAT16_SRCS), $(CSRCS)) CSRCS := $(filter-out $(BFLOAT16_SRCS), $(CSRCS))
endif endif
endif
################# Profile Library ################# ################# Profile Library #################
ifeq ($(CONFIG_COMPILER_RT_PROFILE),y) ifeq ($(CONFIG_COVERAGE_COMPILER_RT),y)
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile
FLAGS += -Wno-cleardeprecated-pragma -Wno-deprecated-pragma -Wno-incompatible-pointer-types 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-shadow -Wno-strict-prototypes -Wno-undef -Wno-unknown-warning-option

View file

@ -68,7 +68,7 @@ ifeq ($(CONFIG_BUILD_FLAT),y)
KERNDEPDIRS += libs$(DELIM)libc mm KERNDEPDIRS += libs$(DELIM)libc mm
ifeq ($(CONFIG_BUILTIN_TOOLCHAIN),) ifeq ($(CONFIG_LIB_BUILTIN),y)
KERNDEPDIRS += libs$(DELIM)libbuiltin KERNDEPDIRS += libs$(DELIM)libbuiltin
else else
CLEANDIRS += libs$(DELIM)libbuiltin CLEANDIRS += libs$(DELIM)libbuiltin
@ -90,7 +90,7 @@ else
USERDEPDIRS += libs$(DELIM)libc mm USERDEPDIRS += libs$(DELIM)libc mm
ifeq ($(CONFIG_BUILTIN_TOOLCHAIN),) ifeq ($(CONFIG_LIB_BUILTIN),y)
USERDEPDIRS += libs$(DELIM)libbuiltin USERDEPDIRS += libs$(DELIM)libbuiltin
else else
CLEANDIRS += libs$(DELIM)libbuiltin CLEANDIRS += libs$(DELIM)libbuiltin

View file

@ -52,7 +52,7 @@ NUTTXLIBS += staging$(DELIM)libarch$(LIBEXT)
# Add toolchain library support # Add toolchain library support
ifeq ($(CONFIG_BUILTIN_TOOLCHAIN),) ifeq ($(CONFIG_LIB_BUILTIN),y)
NUTTXLIBS += staging$(DELIM)libbuiltin$(LIBEXT) NUTTXLIBS += staging$(DELIM)libbuiltin$(LIBEXT)
endif endif

View file

@ -54,7 +54,7 @@ USERLIBS += staging$(DELIM)libmm$(LIBEXT) staging$(DELIM)libarch$(LIBEXT)
# Add toolchain library support # Add toolchain library support
ifeq ($(CONFIG_BUILTIN_TOOLCHAIN),) ifeq ($(CONFIG_LIB_BUILTIN),y)
NUTTXLIBS += staging$(DELIM)libkbuiltin$(LIBEXT) NUTTXLIBS += staging$(DELIM)libkbuiltin$(LIBEXT)
USERLIBS += staging$(DELIM)libbuiltin$(LIBEXT) USERLIBS += staging$(DELIM)libbuiltin$(LIBEXT)
endif endif

View file

@ -54,7 +54,7 @@ USERLIBS += staging$(DELIM)libmm$(LIBEXT) staging$(DELIM)libarch$(LIBEXT)
# Add toolchain library support # Add toolchain library support
ifeq ($(CONFIG_BUILTIN_TOOLCHAIN),) ifeq ($(CONFIG_LIB_BUILTIN),y)
NUTTXLIBS += staging$(DELIM)libkbuiltin$(LIBEXT) NUTTXLIBS += staging$(DELIM)libkbuiltin$(LIBEXT)
USERLIBS += staging$(DELIM)libbuiltin$(LIBEXT) USERLIBS += staging$(DELIM)libbuiltin$(LIBEXT)
endif endif