blob: 901770fc9bd2c8a4f72ae82447b806b3275414d6 [file] [log] [blame]
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -07001# 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
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070011OBJCOPYFLAGS := -O binary
12LDFLAGS_vmlinux :=
Alan Kaoa1d2a6b2018-02-13 13:13:16 +080013ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
14 LDFLAGS_vmlinux := --no-relax
15endif
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070016KBUILD_AFLAGS_MODULE += -fPIC
17KBUILD_CFLAGS_MODULE += -fPIC
18
19KBUILD_DEFCONFIG = defconfig
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
Alex Guoa89757d2018-07-29 01:14:47 +000028
29 KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
30
Masahiro Yamadad503ac52018-08-24 08:20:39 +090031 KBUILD_LDFLAGS += -melf64lriscv
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070032else
33 BITS := 32
34 UTS_MACHINE := riscv32
35
36 KBUILD_CFLAGS += -mabi=ilp32
37 KBUILD_AFLAGS += -mabi=ilp32
Masahiro Yamadad503ac52018-08-24 08:20:39 +090038 KBUILD_LDFLAGS += -melf32lriscv
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070039endif
40
41KBUILD_CFLAGS += -Wall
42
Alan Kaoe8be5302018-10-09 10:18:32 +080043# ISA string setting
44riscv-march-$(CONFIG_ARCH_RV32I) := rv32im
45riscv-march-$(CONFIG_ARCH_RV64I) := rv64im
46riscv-march-$(CONFIG_RISCV_ISA_A) := $(riscv-march-y)a
Alan Kao9671f702018-10-09 10:18:33 +080047riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd
Alan Kaoe8be5302018-10-09 10:18:32 +080048riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c
49KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
50KBUILD_AFLAGS += -march=$(riscv-march-y)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070051
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070052KBUILD_CFLAGS += -mno-save-restore
53KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
54
55ifeq ($(CONFIG_CMODEL_MEDLOW),y)
56 KBUILD_CFLAGS += -mcmodel=medlow
57endif
58ifeq ($(CONFIG_CMODEL_MEDANY),y)
59 KBUILD_CFLAGS += -mcmodel=medany
60endif
Zong Liab1ef682018-03-15 16:50:41 +080061ifeq ($(CONFIG_MODULE_SECTIONS),y)
62 KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/riscv/kernel/module.lds
63endif
64
65KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070066
67# GCC versions that support the "-mstrict-align" option default to allowing
68# unaligned accesses. While unaligned accesses are explicitly allowed in the
69# RISC-V ISA, they're emulated by machine mode traps on all extant
70# architectures. It's faster to have GCC emit only aligned accesses.
71KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
72
Luc Van Oostenryck889d7462018-05-31 17:42:01 +020073# arch specific predefines for sparse
74CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
75
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070076head-y := arch/riscv/kernel/head.o
77
78core-y += arch/riscv/kernel/ arch/riscv/mm/
79
80libs-y += arch/riscv/lib/
81
82all: vmlinux