1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/makefiles/arch/riscv.inc.mk
Marian Buschsieweke d9e495fe83
build system: use riscv-none-elf as triplet
Use riscv-none-elf instead of legacy riscv-none-embed as target triplet for
RISC-V development. However, if ricsv-none-elf is not present, try
riscv64-unknown-elf and riscv-none-embed instead. If the legacy riscv-none-embed
is used, a warning is printed.
2020-09-15 11:18:33 +02:00

33 lines
1.1 KiB
Makefile

# Target architecture for the build.
TARGET_ARCH_RISCV ?= riscv-none-elf
# If TARGET_ARCH wasn't set by user, also check if riscv64-unknown-elf
# or riscv-none-embed is present.
ifeq (riscv-none-elf,$(TARGET_ARCH_RISCV))
ifeq (,$(shell which $(TARGET_ARCH_RISCV)-gcc))
ifneq (,$(shell which riscv64-unknown-elf-gcc))
TARGET_ARCH_RISCV := riscv64-unknown-elf
else ifneq (,$(shell which riscv-none-embed-gcc))
$(info Falling back to legacy riscv-none-embed toolchain)
TARGET_ARCH_RISCV := riscv-none-embed
endif
endif
endif
TARGET_ARCH ?= $(TARGET_ARCH_RISCV)
# define build specific options
CFLAGS_CPU = -march=rv32imac -mabi=ilp32 -mcmodel=medlow -msmall-data-limit=8
CFLAGS_LINK = -nostartfiles -ffunction-sections -fdata-sections
CFLAGS_DBG ?= -g3
CFLAGS_OPT ?= -Os
LINKFLAGS += -L$(RIOTCPU)/$(CPU)/ldscripts
LINKER_SCRIPT ?= $(CPU_MODEL).ld
LINKFLAGS += -T$(LINKER_SCRIPT)
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) $(CFLAGS_LINK)
ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
# export linker flags
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) -Wl,--gc-sections -static -lgcc