summaryrefslogtreecommitdiffstats
path: root/arch/riscv/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv/Makefile')
-rw-r--r--arch/riscv/Makefile71
1 files changed, 30 insertions, 41 deletions
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 643c0bc8eb..71ca82fe8d 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -1,67 +1,56 @@
-CPPFLAGS += -fno-strict-aliasing
+# SPDX-License-Identifier: GPL-2.0-only
+
+KBUILD_DEFCONFIG := rv64i_defconfig
+
+KBUILD_CPPFLAGS += -fno-strict-aliasing
ifeq ($(CONFIG_ARCH_RV32I),y)
- cflags-y += -march=rv32im
+ KBUILD_CPPFLAGS += -mabi=ilp32
+ riscv-ldflags-y += -melf32lriscv
+else
+ KBUILD_CPPFLAGS += -mabi=lp64
+ riscv-ldflags-y += -melf64lriscv
endif
-cflags-y += -fno-pic -pipe
-cflags-y += -Wall -Wstrict-prototypes \
- -Wno-uninitialized -Wno-format -Wno-main -mcmodel=medany
+# ISA string setting
+riscv-march-$(CONFIG_ARCH_RV32I) := rv32im
+riscv-march-$(CONFIG_ARCH_RV64I) := rv64im
-LDFLAGS += $(ldflags-y)
-LDFLAGS_barebox += -nostdlib
+# Newer binutils versions default to ISA spec version 20191213 which moves some
+# instructions from the I extension to the Zicsr and Zifencei extensions.
+toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei)
+riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
-machine-$(CONFIG_MACH_ERIZO) := erizo
+KBUILD_CPPFLAGS += -march=$(riscv-march-y)
+KBUILD_CFLAGS += -mno-save-restore
+KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
+KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
+KBUILD_CPPFLAGS += -Wstrict-prototypes -mcmodel=medany -fpic
+riscv-ldflags-y += -pie -static
-TEXT_BASE = $(CONFIG_TEXT_BASE)
-CPPFLAGS += -DTEXT_BASE=$(CONFIG_TEXT_BASE)
+LDFLAGS_pbl += $(riscv-ldflags-y)
+LDFLAGS_barebox += $(riscv-ldflags-y)
ifndef CONFIG_MODULES
# Add cleanup flags
-CPPFLAGS += -fdata-sections -ffunction-sections
+KBUILD_CPPFLAGS += -fdata-sections -ffunction-sections
LDFLAGS_barebox += -static --gc-sections
endif
KBUILD_BINARY := barebox.bin
-
-machdirs := $(patsubst %,arch/riscv/mach-%/,$(machine-y))
-
-ifeq ($(KBUILD_SRC),)
-CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
-else
-CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
-endif
+KBUILD_IMAGE := $(KBUILD_BINARY)
archprepare: maketools
PHONY += maketools
-ifneq ($(machine-y),)
-MACH := arch/riscv/mach-$(machine-y)/
-else
-MACH :=
-endif
-
-common-y += $(MACH)
-common-y += arch/riscv/boot/
+common-y += arch/riscv/boards/
+common-y += arch/riscv/cpu/
common-y += arch/riscv/lib/
+common-y += arch/riscv/boot/
common-$(CONFIG_OFTREE) += arch/riscv/dts/
-CPPFLAGS += $(cflags-y)
-CFLAGS += $(cflags-y)
-
lds-y := arch/riscv/lib/barebox.lds
CLEAN_FILES += arch/riscv/lib/barebox.lds
-
-ifeq ($(CONFIG_MACH_ERIZO),y)
-KBUILD_IMAGE := barebox.erizo.nmon
-endif
-
-quiet_cmd_erizo_nmon_image = MKIMAGE $@
- cmd_erizo_nmon_image = $(srctree)/scripts/erizo-nmon-image $< $@ || \
- echo "WARNING: Couldn't create erizo nmon image due to previous errors."
-
-barebox.erizo.nmon: $(KBUILD_BINARY) FORCE
- $(call if_changed,erizo_nmon_image)