xref: /linux/arch/riscv/kernel/Makefile (revision da5b2ad1c2f18834cb1ce429e2e5a5cf5cbdf21b)
1# SPDX-License-Identifier: GPL-2.0-only
2#
3# Makefile for the RISC-V Linux kernel
4#
5
6ifdef CONFIG_FTRACE
7CFLAGS_REMOVE_ftrace.o	= $(CC_FLAGS_FTRACE)
8CFLAGS_REMOVE_patch.o	= $(CC_FLAGS_FTRACE)
9CFLAGS_REMOVE_sbi.o	= $(CC_FLAGS_FTRACE)
10CFLAGS_REMOVE_return_address.o	= $(CC_FLAGS_FTRACE)
11endif
12CFLAGS_syscall_table.o	+= $(call cc-option,-Wno-override-init,)
13CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,)
14
15ifdef CONFIG_KEXEC_CORE
16AFLAGS_kexec_relocate.o := -mcmodel=medany $(call cc-option,-mno-relax)
17endif
18
19# cmodel=medany and notrace when patching early
20ifdef CONFIG_RISCV_ALTERNATIVE_EARLY
21CFLAGS_alternative.o := -mcmodel=medany
22CFLAGS_cpufeature.o := -mcmodel=medany
23CFLAGS_sbi_ecall.o := -mcmodel=medany
24ifdef CONFIG_FTRACE
25CFLAGS_REMOVE_alternative.o = $(CC_FLAGS_FTRACE)
26CFLAGS_REMOVE_cpufeature.o = $(CC_FLAGS_FTRACE)
27CFLAGS_REMOVE_sbi_ecall.o = $(CC_FLAGS_FTRACE)
28endif
29ifdef CONFIG_RELOCATABLE
30CFLAGS_alternative.o += -fno-pie
31CFLAGS_cpufeature.o += -fno-pie
32CFLAGS_sbi_ecall.o += -fno-pie
33endif
34ifdef CONFIG_KASAN
35KASAN_SANITIZE_alternative.o := n
36KASAN_SANITIZE_cpufeature.o := n
37KASAN_SANITIZE_sbi_ecall.o := n
38endif
39endif
40
41extra-y += vmlinux.lds
42
43obj-y	+= head.o
44obj-y	+= soc.o
45obj-$(CONFIG_RISCV_ALTERNATIVE) += alternative.o
46obj-y	+= cpu.o
47obj-y	+= cpufeature.o
48obj-y	+= entry.o
49obj-y	+= irq.o
50obj-y	+= process.o
51obj-y	+= ptrace.o
52obj-y	+= reset.o
53obj-y	+= return_address.o
54obj-y	+= setup.o
55obj-y	+= signal.o
56obj-y	+= syscall_table.o
57obj-y	+= sys_riscv.o
58obj-y	+= sys_hwprobe.o
59obj-y	+= time.o
60obj-y	+= traps.o
61obj-y	+= riscv_ksyms.o
62obj-y	+= stacktrace.o
63obj-y	+= cacheinfo.o
64obj-y	+= patch.o
65obj-y	+= vendor_extensions.o
66obj-y	+= vendor_extensions/
67obj-y	+= probes/
68obj-y	+= tests/
69obj-$(CONFIG_MMU) += vdso.o vdso/
70
71obj-$(CONFIG_RISCV_MISALIGNED)	+= traps_misaligned.o
72obj-$(CONFIG_RISCV_MISALIGNED)	+= unaligned_access_speed.o
73obj-$(CONFIG_RISCV_PROBE_UNALIGNED_ACCESS)	+= copy-unaligned.o
74
75obj-$(CONFIG_FPU)		+= fpu.o
76obj-$(CONFIG_FPU)		+= kernel_mode_fpu.o
77obj-$(CONFIG_RISCV_ISA_V)	+= vector.o
78obj-$(CONFIG_RISCV_ISA_V)	+= kernel_mode_vector.o
79obj-$(CONFIG_SMP)		+= smpboot.o
80obj-$(CONFIG_SMP)		+= smp.o
81obj-$(CONFIG_SMP)		+= cpu_ops.o
82
83obj-$(CONFIG_RISCV_BOOT_SPINWAIT) += cpu_ops_spinwait.o
84obj-$(CONFIG_MODULES)		+= module.o
85obj-$(CONFIG_MODULE_SECTIONS)	+= module-sections.o
86
87obj-$(CONFIG_CPU_PM)		+= suspend_entry.o suspend.o
88obj-$(CONFIG_HIBERNATION)	+= hibernate.o hibernate-asm.o
89
90obj-$(CONFIG_FUNCTION_TRACER)	+= mcount.o ftrace.o
91obj-$(CONFIG_DYNAMIC_FTRACE)	+= mcount-dyn.o
92
93obj-$(CONFIG_PERF_EVENTS)	+= perf_callchain.o
94obj-$(CONFIG_HAVE_PERF_REGS)	+= perf_regs.o
95obj-$(CONFIG_RISCV_SBI)		+= sbi.o sbi_ecall.o
96ifeq ($(CONFIG_RISCV_SBI), y)
97obj-$(CONFIG_SMP)		+= sbi-ipi.o
98obj-$(CONFIG_SMP) += cpu_ops_sbi.o
99endif
100obj-$(CONFIG_HOTPLUG_CPU)	+= cpu-hotplug.o
101obj-$(CONFIG_PARAVIRT)		+= paravirt.o
102obj-$(CONFIG_KGDB)		+= kgdb.o
103obj-$(CONFIG_KEXEC_CORE)	+= kexec_relocate.o crash_save_regs.o machine_kexec.o
104obj-$(CONFIG_KEXEC_FILE)	+= elf_kexec.o machine_kexec_file.o
105obj-$(CONFIG_CRASH_DUMP)	+= crash_dump.o
106obj-$(CONFIG_VMCORE_INFO)	+= vmcore_info.o
107
108obj-$(CONFIG_JUMP_LABEL)	+= jump_label.o
109
110obj-$(CONFIG_CFI_CLANG)		+= cfi.o
111
112obj-$(CONFIG_EFI)		+= efi.o
113obj-$(CONFIG_COMPAT)		+= compat_syscall_table.o
114obj-$(CONFIG_COMPAT)		+= compat_signal.o
115obj-$(CONFIG_COMPAT)		+= compat_vdso/
116
117obj-$(CONFIG_64BIT)		+= pi/
118obj-$(CONFIG_ACPI)		+= acpi.o
119obj-$(CONFIG_ACPI_NUMA)	+= acpi_numa.o
120