18c2ecf20Sopenharmony_ci# This file is included by the global makefile so that you can add your own 28c2ecf20Sopenharmony_ci# architecture-specific flags and dependencies. Remember to do have actions 38c2ecf20Sopenharmony_ci# for "archclean" and "archdep" for cleaning up and making dependencies for 48c2ecf20Sopenharmony_ci# this architecture 58c2ecf20Sopenharmony_ci# 68c2ecf20Sopenharmony_ci# This file is subject to the terms and conditions of the GNU General Public 78c2ecf20Sopenharmony_ci# License. See the file "COPYING" in the main directory of this archive 88c2ecf20Sopenharmony_ci# for more details. 98c2ecf20Sopenharmony_ci# 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciOBJCOPYFLAGS := -O binary 128c2ecf20Sopenharmony_ciLDFLAGS_vmlinux := 138c2ecf20Sopenharmony_ciifeq ($(CONFIG_DYNAMIC_FTRACE),y) 148c2ecf20Sopenharmony_ci LDFLAGS_vmlinux := --no-relax 158c2ecf20Sopenharmony_ciendif 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciifeq ($(CONFIG_CMODEL_MEDLOW),y) 188c2ecf20Sopenharmony_ciKBUILD_CFLAGS_MODULE += -mcmodel=medany 198c2ecf20Sopenharmony_ciendif 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciexport BITS 228c2ecf20Sopenharmony_ciifeq ($(CONFIG_ARCH_RV64I),y) 238c2ecf20Sopenharmony_ci BITS := 64 248c2ecf20Sopenharmony_ci UTS_MACHINE := riscv64 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -mabi=lp64 278c2ecf20Sopenharmony_ci KBUILD_AFLAGS += -mabi=lp64 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci KBUILD_LDFLAGS += -melf64lriscv 308c2ecf20Sopenharmony_cielse 318c2ecf20Sopenharmony_ci BITS := 32 328c2ecf20Sopenharmony_ci UTS_MACHINE := riscv32 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -mabi=ilp32 358c2ecf20Sopenharmony_ci KBUILD_AFLAGS += -mabi=ilp32 368c2ecf20Sopenharmony_ci KBUILD_LDFLAGS += -melf32lriscv 378c2ecf20Sopenharmony_ciendif 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciifeq ($(CONFIG_LD_IS_LLD),y) 408c2ecf20Sopenharmony_ciifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0) 418c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -mno-relax 428c2ecf20Sopenharmony_ci KBUILD_AFLAGS += -mno-relax 438c2ecf20Sopenharmony_ciifndef CONFIG_AS_IS_LLVM 448c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -Wa,-mno-relax 458c2ecf20Sopenharmony_ci KBUILD_AFLAGS += -Wa,-mno-relax 468c2ecf20Sopenharmony_ciendif 478c2ecf20Sopenharmony_ciendif 488c2ecf20Sopenharmony_ciendif 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci# ISA string setting 518c2ecf20Sopenharmony_ciriscv-march-$(CONFIG_ARCH_RV32I) := rv32ima 528c2ecf20Sopenharmony_ciriscv-march-$(CONFIG_ARCH_RV64I) := rv64ima 538c2ecf20Sopenharmony_ciriscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd 548c2ecf20Sopenharmony_ciriscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ciifdef CONFIG_TOOLCHAIN_NEEDS_OLD_ISA_SPEC 578c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wa,-misa-spec=2.2 588c2ecf20Sopenharmony_ciKBUILD_AFLAGS += -Wa,-misa-spec=2.2 598c2ecf20Sopenharmony_cielse 608c2ecf20Sopenharmony_ciriscv-march-$(CONFIG_TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI) := $(riscv-march-y)_zicsr_zifencei 618c2ecf20Sopenharmony_ciendif 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) 648c2ecf20Sopenharmony_ciKBUILD_AFLAGS += -march=$(riscv-march-y) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -mno-save-restore 678c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciifeq ($(CONFIG_CMODEL_MEDLOW),y) 708c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -mcmodel=medlow 718c2ecf20Sopenharmony_ciendif 728c2ecf20Sopenharmony_ciifeq ($(CONFIG_CMODEL_MEDANY),y) 738c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -mcmodel=medany 748c2ecf20Sopenharmony_ciendif 758c2ecf20Sopenharmony_ciifeq ($(CONFIG_PERF_EVENTS),y) 768c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -fno-omit-frame-pointer 778c2ecf20Sopenharmony_ciendif 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci# Avoid generating .eh_frame sections. 808c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciKBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax) 838c2ecf20Sopenharmony_ciKBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci# GCC versions that support the "-mstrict-align" option default to allowing 868c2ecf20Sopenharmony_ci# unaligned accesses. While unaligned accesses are explicitly allowed in the 878c2ecf20Sopenharmony_ci# RISC-V ISA, they're emulated by machine mode traps on all extant 888c2ecf20Sopenharmony_ci# architectures. It's faster to have GCC emit only aligned accesses. 898c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-mstrict-align) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci# arch specific predefines for sparse 928c2ecf20Sopenharmony_ciCHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS) 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci# Default target when executing plain make 958c2ecf20Sopenharmony_ciboot := arch/riscv/boot 968c2ecf20Sopenharmony_ciKBUILD_IMAGE := $(boot)/Image.gz 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cihead-y := arch/riscv/kernel/head.o 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_cicore-y += arch/riscv/ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cilibs-y += arch/riscv/lib/ 1038c2ecf20Sopenharmony_cilibs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciPHONY += vdso_install 1068c2ecf20Sopenharmony_civdso_install: 1078c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@ 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ciprepare: vdso_prepare 1108c2ecf20Sopenharmony_civdso_prepare: prepare0 1118c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso include/generated/vdso-offsets.h 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ciifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_SOC_CANAAN),yy) 1148c2ecf20Sopenharmony_ciKBUILD_IMAGE := $(boot)/loader.bin 1158c2ecf20Sopenharmony_cielse 1168c2ecf20Sopenharmony_ciKBUILD_IMAGE := $(boot)/Image.gz 1178c2ecf20Sopenharmony_ciendif 1188c2ecf20Sopenharmony_ciBOOT_TARGETS := Image Image.gz loader loader.bin 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ciall: $(notdir $(KBUILD_IMAGE)) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci$(BOOT_TARGETS): vmlinux 1238c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 1248c2ecf20Sopenharmony_ci @$(kecho) ' Kernel: $(boot)/$@ is ready' 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_cizinstall install: 1278c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=$(boot) $@ 128