Browse Source

build: add support for nuclei 2023 toolchain include gnu/clang

new libncrt 3.0.0 support is included, and now libncrt split into
several parts like libncrt-core, and fileops part, heapos part

fileops part contains two version: one is the uart version called fileops_uart,
the semihost version called fileops_semi
heapops part contains three version: basic, realtime, minimal

Signed-off-by: Huaqi Fang <578567190@qq.com>
Huaqi Fang 2 years ago
parent
commit
6f6e1bf089

+ 6 - 0
Build/Makefile.base

@@ -50,6 +50,12 @@ RTOS ?=
 ### nostd: Don't search the standard system directories for header files
 ### nospec: Don't pass any --specs options
 STDCLIB ?= newlib_nano
+## Available choices:
+### only available for libncrt
+### basic: A low-overhead best-fit heap where allocation and deallocation have very little internal fragmentation
+### realtime: A real-time heap where allocation and deallocation have O(1) performance
+### minimal: An allocate-only heap where deallocation and reallocation are not implemented
+NCRTHEAP ?= basic
 ## If NOGC=1, it will not gc any sections during compiling to save code size
 NOGC ?=
 ## If BANNER=0, it will not display sdk banner when program run

+ 1 - 0
Build/Makefile.conf

@@ -98,6 +98,7 @@ ASM_INCLUDE_OPT = $(foreach dir,$(sort $(INCDIRS) $(ASM_INCDIRS)),-I$(dir))
 
 include $(NUCLEI_SDK_BUILD)/Makefile.toolchain
 
+COMMON_FLAGS += -g -fno-common
 COMMON_FLAGS += $(APP_COMMON_FLAGS) $(GC_CFLAGS) \
 	-DDOWNLOAD_MODE=DOWNLOAD_MODE_$(DOWNLOAD_UPPER) \
 	-DDOWNLOAD_MODE_STRING=\"$(DOWNLOAD_UPPER)\"

+ 9 - 1
Build/toolchain/nuclei_gnu.mk

@@ -71,6 +71,7 @@ endif
 else ifneq ($(findstring libncrt,$(STDCLIB)),)
 ### Handle cases when STDCLIB variable has libncrt in it
 COMMON_FLAGS += --specs=$(STDCLIB).specs
+LDLIBS += -l$(patsubst lib%,%,$(STDCLIB)) -lheapops_$(NCRTHEAP)
 ###
 else ifeq ($(STDCLIB),nostd)
 ### Handle cases when no standard system directories for header files
@@ -95,8 +96,16 @@ endif
 endif
 
 ifneq ($(SEMIHOST),)
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+LDLIBS += -lfileops_semi
+else
 LDLIBS += -lsemihost
 endif
+else
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+LDLIBS += -lfileops_uart
+endif
+endif
 
 ## Heap and stack size settings
 ## It will define symbols only used in linker script
@@ -116,7 +125,6 @@ SIMULATION_MODE=SIMULATION_MODE_$(call uc, $(SIMU))
 COMMON_FLAGS += -DSIMULATION_MODE=$(SIMULATION_MODE)
 endif
 
-COMMON_FLAGS += -g -fno-common
 COMMON_FLAGS += -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -mcmodel=$(RISCV_CMODEL)
 ## Append mtune options when RISCV_TUNE is defined
 ## It might be defined in SoC/<SOC>/build.mk, and can be overwritten by make

+ 9 - 2
Build/toolchain/nuclei_llvm.mk

@@ -45,7 +45,7 @@ endif
 ###
 else ifneq ($(findstring libncrt,$(STDCLIB)),)
 ### Handle cases when STDCLIB variable has libncrt in it
-LDLIBS += -l$(patsubst lib%,%,$(STDCLIB))
+LDLIBS += -l$(patsubst lib%,%,$(STDCLIB)) -lheapops_$(NCRTHEAP)
 COMMON_FLAGS += -isystem=/include/libncrt
 ###
 else ifeq ($(STDCLIB),nostd)
@@ -62,8 +62,16 @@ LDLIBS +=
 endif
 
 ifneq ($(SEMIHOST),)
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+LDLIBS += -lfileops_semi
+else
 LDLIBS += -lsemihost
 endif
+else
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+LDLIBS += -lfileops_uart
+endif
+endif
 
 ## Heap and stack size settings
 ## It will define symbols only used in linker script
@@ -83,7 +91,6 @@ SIMULATION_MODE=SIMULATION_MODE_$(call uc, $(SIMU))
 COMMON_FLAGS += -DSIMULATION_MODE=$(SIMULATION_MODE)
 endif
 
-COMMON_FLAGS += -g -fno-common
 COMMON_FLAGS += -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -mcmodel=$(RISCV_CMODEL)
 ## Append mtune options when RISCV_TUNE is defined
 ## It might be defined in SoC/<SOC>/build.mk, and can be overwritten by make

+ 18 - 2
Build/toolchain/terapines.mk

@@ -24,6 +24,10 @@ ifeq ($(BANNER),0)
 COMMON_FLAGS += -DNUCLEI_BANNER=0
 endif
 
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+$(error terapine toolchain don't provide libncrt library support)
+endif
+
 # Handle standard c library selection variable STDCLIB
 ifneq ($(findstring newlib,$(STDCLIB)),)
 ### Handle cases when STDCLIB variable has newlib in it
@@ -43,7 +47,8 @@ endif
 ###
 else ifneq ($(findstring libncrt,$(STDCLIB)),)
 ### Handle cases when STDCLIB variable has libncrt in it
-COMMON_FLAGS += --config=$(STDCLIB).specs
+LDLIBS += -l$(patsubst lib%,%,$(STDCLIB)) -lheapops_$(NCRTHEAP)
+COMMON_FLAGS += -isystem=/include/libncrt
 ###
 else ifeq ($(STDCLIB),nostd)
 ### Handle cases when no standard system directories for header files
@@ -58,6 +63,18 @@ COMMON_FLAGS += --config nosys.cfg
 ###
 endif
 
+ifneq ($(SEMIHOST),)
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+LDLIBS += -lfileops_semi
+else
+LDLIBS += -lsemihost
+endif
+else
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+LDLIBS += -lfileops_uart
+endif
+endif
+
 ## Heap and stack size settings
 ## It will define symbols only used in linker script
 ## __STACK_SIZE and __HEAP_SIZE are not a c marco
@@ -76,7 +93,6 @@ SIMULATION_MODE=SIMULATION_MODE_$(call uc, $(SIMU))
 COMMON_FLAGS += -DSIMULATION_MODE=$(SIMULATION_MODE)
 endif
 
-COMMON_FLAGS += -g -fno-common
 COMMON_FLAGS += -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -mcmodel=$(RISCV_CMODEL)
 ## Append mtune options when RISCV_TUNE is defined
 ## It might be defined in SoC/<SOC>/build.mk, and can be overwritten by make

+ 6 - 4
SoC/demosoc/build.mk

@@ -148,16 +148,18 @@ C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source $(NUCLEI_SDK_SOC_COMMON)/Source/Dri
 
 # If semihosting is enabled, no stub function is needed
 ifeq ($(SEMIHOST),)
-ifneq ($(findstring libncrt,$(STDCLIB)),)
-# semihosting currently not ported to support libncrt
-C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/libncrt
-else ifneq ($(findstring newlib,$(STDCLIB)),)
+ifneq ($(findstring newlib,$(STDCLIB)),)
 C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/newlib
 else
 # no stubs will be used
 endif
 endif
 
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+# semihosting currently not ported to support libncrt
+C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/libncrt
+endif
+
 ASM_SRCS += $(NUCLEI_SDK_SOC_COMMON)/Source/GCC/startup_demosoc.S \
 		$(NUCLEI_SDK_SOC_COMMON)/Source/GCC/intexc_demosoc.S      \
 		$(NUCLEI_SDK_SOC_COMMON)/Source/GCC/intexc_demosoc_s.S

+ 6 - 4
SoC/evalsoc/build.mk

@@ -143,16 +143,18 @@ C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source $(NUCLEI_SDK_SOC_COMMON)/Source/Dri
 
 # If semihosting is enabled, no stub function is needed
 ifeq ($(SEMIHOST),)
-ifneq ($(findstring libncrt,$(STDCLIB)),)
-# semihosting currently not ported to support libncrt
-C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/libncrt
-else ifneq ($(findstring newlib,$(STDCLIB)),)
+ifneq ($(findstring newlib,$(STDCLIB)),)
 C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/newlib
 else
 # no stubs will be used
 endif
 endif
 
+ifneq ($(findstring libncrt,$(STDCLIB)),)
+# semihosting currently not ported to support libncrt
+C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/libncrt
+endif
+
 ASM_SRCS += $(NUCLEI_SDK_SOC_COMMON)/Source/GCC/startup_evalsoc.S \
 		$(NUCLEI_SDK_SOC_COMMON)/Source/GCC/intexc_evalsoc.S      \
 		$(NUCLEI_SDK_SOC_COMMON)/Source/GCC/intexc_evalsoc_s.S