• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This file is included by the global makefile so that you can add your own
2# architecture-specific flags and dependencies. Remember to do have actions
3# for "archclean" and "archdep" for cleaning up and making dependencies for
4# this architecture
5#
6# This file is subject to the terms and conditions of the GNU General Public
7# License.  See the file "COPYING" in the main directory of this archive
8# for more details.
9#
10
11OBJCOPYFLAGS    := -O binary
12LDFLAGS_vmlinux :=
13ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
14	LDFLAGS_vmlinux := --no-relax
15endif
16
17ifeq ($(CONFIG_CMODEL_MEDLOW),y)
18KBUILD_CFLAGS_MODULE += -mcmodel=medany
19endif
20
21export BITS
22ifeq ($(CONFIG_ARCH_RV64I),y)
23	BITS := 64
24	UTS_MACHINE := riscv64
25
26	KBUILD_CFLAGS += -mabi=lp64
27	KBUILD_AFLAGS += -mabi=lp64
28
29	KBUILD_LDFLAGS += -melf64lriscv
30else
31	BITS := 32
32	UTS_MACHINE := riscv32
33
34	KBUILD_CFLAGS += -mabi=ilp32
35	KBUILD_AFLAGS += -mabi=ilp32
36	KBUILD_LDFLAGS += -melf32lriscv
37endif
38
39ifeq ($(CONFIG_LD_IS_LLD),y)
40ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
41	KBUILD_CFLAGS += -mno-relax
42	KBUILD_AFLAGS += -mno-relax
43ifneq ($(LLVM_IAS),1)
44	KBUILD_CFLAGS += -Wa,-mno-relax
45	KBUILD_AFLAGS += -Wa,-mno-relax
46endif
47endif
48endif
49
50# ISA string setting
51riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
52riscv-march-$(CONFIG_ARCH_RV64I)	:= rv64ima
53riscv-march-$(CONFIG_FPU)		:= $(riscv-march-y)fd
54riscv-march-$(CONFIG_RISCV_ISA_C)	:= $(riscv-march-y)c
55
56# Newer binutils versions default to ISA spec version 20191213 which moves some
57# instructions from the I extension to the Zicsr and Zifencei extensions.
58toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei)
59riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
60
61KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
62KBUILD_AFLAGS += -march=$(riscv-march-y)
63
64KBUILD_CFLAGS += -mno-save-restore
65KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
66
67ifeq ($(CONFIG_CMODEL_MEDLOW),y)
68	KBUILD_CFLAGS += -mcmodel=medlow
69endif
70ifeq ($(CONFIG_CMODEL_MEDANY),y)
71	KBUILD_CFLAGS += -mcmodel=medany
72endif
73ifeq ($(CONFIG_PERF_EVENTS),y)
74        KBUILD_CFLAGS += -fno-omit-frame-pointer
75endif
76
77KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
78KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
79
80# GCC versions that support the "-mstrict-align" option default to allowing
81# unaligned accesses.  While unaligned accesses are explicitly allowed in the
82# RISC-V ISA, they're emulated by machine mode traps on all extant
83# architectures.  It's faster to have GCC emit only aligned accesses.
84KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
85
86# arch specific predefines for sparse
87CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
88
89# Default target when executing plain make
90boot		:= arch/riscv/boot
91KBUILD_IMAGE	:= $(boot)/Image.gz
92
93head-y := arch/riscv/kernel/head.o
94
95core-y += arch/riscv/
96
97libs-y += arch/riscv/lib/
98libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
99
100PHONY += vdso_install
101vdso_install:
102	$(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
103
104ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_SOC_KENDRYTE),yy)
105KBUILD_IMAGE := $(boot)/loader.bin
106else
107KBUILD_IMAGE := $(boot)/Image.gz
108endif
109BOOT_TARGETS := Image Image.gz loader loader.bin
110
111all:	$(notdir $(KBUILD_IMAGE))
112
113$(BOOT_TARGETS): vmlinux
114	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
115	@$(kecho) '  Kernel: $(boot)/$@ is ready'
116
117zinstall install:
118	$(Q)$(MAKE) $(build)=$(boot) $@
119