mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #18098 from maribu/makefiles/arch/riscv.inc.mk
buildsystem: Improve RISC-V compilation handling with newer toolchain
This commit is contained in:
commit
0fd544806a
@ -320,6 +320,7 @@ if __name__ == '__main__':
|
||||
_args.add_libstdcxx_includes = True
|
||||
_args.filter_out = ['-mno-thumb-interwork',
|
||||
# Only even included for versions of GCC that support it
|
||||
'-misa-spec=2.2',
|
||||
'-malign-data=natural',
|
||||
# Only supported starting with clang 11
|
||||
'-msmall-data-limit=8',
|
||||
|
@ -38,23 +38,23 @@ ifeq (,$(TARGET_ARCH))
|
||||
endif
|
||||
|
||||
ifeq ($(TOOLCHAIN),gnu)
|
||||
NEW_RISCV_ISA := $(shell echo "" | $(TARGET_ARCH)-as -march=rv32imac_zicsr -mabi=ilp32 - > /dev/null 2>&1 && echo 1 || echo 0)
|
||||
GCC_DEFAULTS_TO_NEW_RISCV_ISA ?= $(shell echo "typedef int dont_be_pedantic;" | $(TARGET_ARCH)-gcc -march=rv32imac -mabi=ilp32 -misa-spec=2.2 -E - > /dev/null 2>&1 && echo 1 || echo 0)
|
||||
endif
|
||||
|
||||
NEW_RISCV_ISA ?= 0
|
||||
GCC_DEFAULTS_TO_NEW_RISCV_ISA ?= 0
|
||||
|
||||
CFLAGS_CPU := -march=rv32imac -mabi=ilp32
|
||||
|
||||
# Since RISC-V ISA specifications 20191213 instructions previously included in
|
||||
# rv32imac have been moved to the ZICSR extension. See
|
||||
# https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf
|
||||
#
|
||||
# Select the march based on the ISA spec implemented by the used compiler:
|
||||
ifeq (1,$(NEW_RISCV_ISA))
|
||||
CFLAGS_CPU := -march=rv32imac_zicsr
|
||||
else
|
||||
CFLAGS_CPU := -march=rv32imac
|
||||
# Select the oldest ISA spec in which ZICSR was not yet split out into an
|
||||
# extension
|
||||
ifeq (1,$(GCC_DEFAULTS_TO_NEW_RISCV_ISA))
|
||||
CFLAGS_CPU += -misa-spec=2.2
|
||||
endif
|
||||
|
||||
CFLAGS_CPU += -mabi=ilp32
|
||||
ifeq ($(TOOLCHAIN),llvm)
|
||||
# Always use riscv32-none-elf as target triple for clang, as some
|
||||
# autodetected gcc target triples are incompatible with clang
|
||||
@ -76,7 +76,7 @@ LINKFLAGS += -T$(LINKER_SCRIPT)
|
||||
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) $(CFLAGS_LINK)
|
||||
ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
|
||||
# export linker flags
|
||||
LINKFLAGS += -march=rv32imac -mabi=ilp32 $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) -nostartfiles -Wl,--gc-sections -static -lgcc
|
||||
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) -nostartfiles -Wl,--gc-sections -static -lgcc
|
||||
|
||||
# Platform triple as used by Rust
|
||||
RUST_TARGET = riscv32imac-unknown-none-elf
|
||||
|
Loading…
Reference in New Issue
Block a user