Merge pull request #15176 from nmeum/pr/hifive1-llvm

fe310: Support compilation with clang
This commit is contained in:
Alexandre Abadie 2021-02-13 18:53:54 +01:00 committed by GitHub
commit 54dbc555c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View File

@ -1,6 +1,8 @@
CFLAGS += -Wno-pedantic CFLAGS += -Wno-pedantic
INCLUDES += -I$(RIOTCPU)/riscv_common/include INCLUDES += -I$(RIOTCPU)/riscv_common/include
TOOLCHAINS_SUPPORTED = gnu llvm
# All variables must be defined in the CPU configuration when using the common # All variables must be defined in the CPU configuration when using the common
# `ldscripts/riscv.ld` # `ldscripts/riscv.ld`
ifneq (,$(ROM_START_ADDR)$(RAM_START_ADDR)$(ROM_LEN)$(RAM_LEN)) ifneq (,$(ROM_START_ADDR)$(RAM_START_ADDR)$(ROM_LEN)$(RAM_LEN))

View File

@ -116,8 +116,8 @@ void handle_trap(uint32_t mcause)
#ifdef DEVELHELP #ifdef DEVELHELP
printf("Unhandled trap:\n"); printf("Unhandled trap:\n");
printf(" mcause: 0x%" PRIx32 "\n", mcause); printf(" mcause: 0x%" PRIx32 "\n", mcause);
printf(" mepc: 0x%" PRIx32 "\n", read_csr(mepc)); printf(" mepc: 0x%lx\n", read_csr(mepc));
printf(" mtval: 0x%" PRIx32 "\n", read_csr(mtval)); printf(" mtval: 0x%lx\n", read_csr(mtval));
#endif #endif
/* Unknown trap */ /* Unknown trap */
core_panic(PANIC_GENERAL_ERROR, "Unhandled trap"); core_panic(PANIC_GENERAL_ERROR, "Unhandled trap");

View File

@ -30,8 +30,15 @@ TARGET_ARCH_RISCV ?= \
TARGET_ARCH ?= $(TARGET_ARCH_RISCV) TARGET_ARCH ?= $(TARGET_ARCH_RISCV)
# define build specific options # define build specific options
CFLAGS_CPU = -march=rv32imac -mabi=ilp32 -mcmodel=medlow -msmall-data-limit=8 CFLAGS_CPU = -march=rv32imac -mabi=ilp32
CFLAGS_LINK = -nostartfiles -ffunction-sections -fdata-sections ifeq ($(TOOLCHAIN),llvm)
# Always use riscv32-none-elf as target triple for clang, as some
# autodetected gcc target triples are incompatible with clang
TARGET_ARCH_LLVM := riscv32-none-elf
else
CFLAGS_CPU += -mcmodel=medlow -msmall-data-limit=8
endif
CFLAGS_LINK = -ffunction-sections -fdata-sections
CFLAGS_DBG ?= -g3 CFLAGS_DBG ?= -g3
CFLAGS_OPT ?= -Os CFLAGS_OPT ?= -Os
@ -42,4 +49,4 @@ LINKFLAGS += -T$(LINKER_SCRIPT)
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) $(CFLAGS_LINK) CFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) $(CFLAGS_LINK)
ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
# export linker flags # export linker flags
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) -Wl,--gc-sections -static -lgcc LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) -nostartfiles -Wl,--gc-sections -static -lgcc