Skip to content

Commit

Permalink
Build: Force hightec toolchain use STDCLIB=picolibc_small
Browse files Browse the repository at this point in the history
The library integrated into hightec is picolibc, so we just keep the picolibc
present as it is

Signed-off-by: Huaqi Fang <[email protected]>
  • Loading branch information
fanghuaqi committed Jul 12, 2024
1 parent 2b33ef2 commit da02b96
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Build/Makefile.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ ifdef STDCLIB
override NEWLIB := $(STDCLIB)
endif

ifeq ($(TOOLCHAIN),hightec)
override STDCLIB := picolibc_small
endif

include $(NUCLEI_SDK_BUILD)/Makefile.files
include $(NUCLEI_SDK_NMSIS)/build.mk
include $(NUCLEI_SDK_BUILD)/Makefile.soc
Expand Down
30 changes: 13 additions & 17 deletions Build/toolchain/hightec.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,25 @@ AR := llvm-ar
SIZE := llvm-size
OPENOCD := openocd

ifneq ($(findstring libncrt,$(STDCLIB)),)
$(error Terapines toolchain dont 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
ifeq ($(STDCLIB),newlib_full)
ifneq ($(findstring picolibc,$(STDCLIB)),)
### Handle cases when STDCLIB variable has picolibc in it
ifeq ($(STDCLIB),picolibc_full)
LDLIBS += -lc
else ifeq ($(STDCLIB),newlib_fast)
else ifeq ($(STDCLIB),picolibc_fast)
LDLIBS += -lc
STDCLIB_LDFLAGS += -u _printf_float -u _scanf_float
else ifeq ($(STDCLIB),newlib_small)
STDCLIB_LDFLAGS +=
else ifeq ($(STDCLIB),picolibc_small)
LDLIBS += -lc
STDCLIB_LDFLAGS += -u _printf_float
else ifeq ($(STDCLIB),newlib_nano)
STDCLIB_LDFLAGS +=
else ifeq ($(STDCLIB),picolibc_nano)
LDLIBS += -lc
# work around for relocation R_RISCV_PCREL_HI20 out of range: -524289 is not in [-524288, 524287]; references _printf_float when compile with rv64
# so with this change below, newlib_nano = newlib_small now
STDCLIB_LDFLAGS += -u _printf_float
# so with this change below, picolibc_nano = picolibc_small now
STDCLIB_LDFLAGS +=
else
LDLIBS += -lc
STDCLIB_LDFLAGS += -u _printf_float
STDCLIB_LDFLAGS +=
endif
###
else ifeq ($(STDCLIB),nostd)
Expand All @@ -43,7 +39,7 @@ COMMON_FLAGS +=
###
else
LDLIBS += -lc
STDCLIB_LDFLAGS += -u _printf_float
STDCLIB_LDFLAGS +=
###
endif

Expand Down Expand Up @@ -86,7 +82,7 @@ ifneq ($(RISCV_TUNE),)
COMMON_FLAGS +=# -mtune=$(RISCV_TUNE)
endif

ifneq ($(findstring newlib,$(STDCLIB)),)
ifneq ($(findstring picolibc,$(STDCLIB)),)
LDFLAGS += #-u __on_exit_args
endif

Expand Down
2 changes: 2 additions & 0 deletions SoC/evalsoc/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source $(NUCLEI_SDK_SOC_COMMON)/Source/Dri
ifeq ($(SEMIHOST),)
ifneq ($(findstring newlib,$(STDCLIB)),)
C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/newlib
else ifneq ($(findstring picolibc,$(STDCLIB)),)
C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/picolibc
else
# no stubs will be used
endif
Expand Down

0 comments on commit da02b96

Please sign in to comment.