Merge tag 'soc-ep93xx-dt-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-block.git] / arch / arm64 / Makefile
CommitLineData
8c2c3df3
CM
1#
2# arch/arm64/Makefile
3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
7# This file is subject to the terms and conditions of the GNU General Public
8# License. See the file "COPYING" in the main directory of this archive
9# for more details.
10#
11# Copyright (C) 1995-2001 by Russell King
12
311bea3c 13LDFLAGS_vmlinux :=--no-undefined -X
8c2c3df3 14
fd9dde6a
ND
15ifeq ($(CONFIG_RELOCATABLE), y)
16# Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
17# for relative relocs, since this leads to better Image compression
18# with the relocation offsets always being zero.
3b92fa74 19LDFLAGS_vmlinux += -shared -Bsymbolic -z notext \
fd9dde6a 20 $(call ld-option, --no-apply-dynamic-relocs)
1e48ef7f
AB
21endif
22
6ffe9923 23ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
64ee84c7 24 ifeq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
6ffe9923
WD
25LDFLAGS_vmlinux += --fix-cortex-a53-843419
26 endif
27endif
28
03adcbd9
WD
29cc_has_k_constraint := $(call try-run,echo \
30 'int main(void) { \
31 asm volatile("and w0, w0, %w0" :: "K" (4294967295)); \
32 return 0; \
33 }' | $(CC) -S -x c -o "$$TMP" -,,-DCONFIG_CC_HAS_K_CONSTRAINT=1)
34
8bf9284d 35ifeq ($(CONFIG_BROKEN_GAS_INST),y)
bbb56c27
MZ
36$(warning Detected assembler with broken .inst; disassembly will be unreliable)
37endif
38
71883ae3
SH
39# The GCC option -ffreestanding is required in order to compile code containing
40# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel)
41CC_FLAGS_FPU := -ffreestanding
42# Enable <arm_neon.h>
43CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include)
44CC_FLAGS_NO_FPU := -mgeneral-regs-only
45
46KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \
03adcbd9 47 $(compat_vdso) $(cc_has_k_constraint)
fa63da2a 48KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
8bf9284d 49KBUILD_AFLAGS += $(compat_vdso)
c09d6a04 50
724a75ac
JC
51KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"
52
3d6a7b99
AP
53KBUILD_CFLAGS += $(call cc-option,-mabi=lp64)
54KBUILD_AFLAGS += $(call cc-option,-mabi=lp64)
55
6e0a66d1 56# Avoid generating .eh_frame* sections.
68c76ad4 57ifneq ($(CONFIG_UNWIND_TABLES),y)
6e0a66d1
KC
58KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
59KBUILD_AFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
d077242d 60KBUILD_RUSTFLAGS += -Cforce-unwind-tables=n
68c76ad4
AB
61else
62KBUILD_CFLAGS += -fasynchronous-unwind-tables
63KBUILD_AFLAGS += -fasynchronous-unwind-tables
d077242d 64KBUILD_RUSTFLAGS += -Cforce-unwind-tables=y -Zuse-sync-unwind=n
68c76ad4 65endif
6e0a66d1 66
0a1213fa
AB
67ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)
68prepare: stack_protector_prepare
69stack_protector_prepare: prepare0
70 $(eval KBUILD_CFLAGS += -mstack-protector-guard=sysreg \
71 -mstack-protector-guard-reg=sp_el0 \
72 -mstack-protector-guard-offset=$(shell \
73 awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
74 include/generated/asm-offsets.h))
75endif
76
92e2294d 77ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
c68cf528 78 KBUILD_CFLAGS += -mbranch-protection=pac-ret+bti
724a75ac 79 KBUILD_RUSTFLAGS += -Zbranch-protection=bti,pac-ret
c68cf528 80else ifeq ($(CONFIG_ARM64_PTR_AUTH_KERNEL),y)
724a75ac 81 KBUILD_RUSTFLAGS += -Zbranch-protection=pac-ret
c68cf528
MR
82 ifeq ($(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET),y)
83 KBUILD_CFLAGS += -mbranch-protection=pac-ret
84 else
85 KBUILD_CFLAGS += -msign-return-address=non-leaf
86 endif
92e2294d 87else
c68cf528 88 KBUILD_CFLAGS += $(call cc-option,-mbranch-protection=none)
1764c3ed
ST
89endif
90
1e249c41
MR
91# Tell the assembler to support instructions from the latest target
92# architecture.
93#
94# For non-integrated assemblers we'll pass this on the command line, and for
95# integrated assemblers we'll define ARM64_ASM_ARCH and ARM64_ASM_PREAMBLE for
96# inline usage.
97#
98# We cannot pass the same arch flag to the compiler as this would allow it to
99# freely generate instructions which are not supported by earlier architecture
100# versions, which would prevent a single kernel image from working on earlier
101# hardware.
f469c032 102ifeq ($(CONFIG_AS_HAS_ARMV8_5), y)
1e249c41
MR
103 asm-arch := armv8.5-a
104else ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
105 asm-arch := armv8.4-a
106else ifeq ($(CONFIG_AS_HAS_ARMV8_3), y)
107 asm-arch := armv8.3-a
108else ifeq ($(CONFIG_AS_HAS_ARMV8_2), y)
109 asm-arch := armv8.2-a
f469c032
VF
110endif
111
1764c3ed
ST
112ifdef asm-arch
113KBUILD_CFLAGS += -Wa,-march=$(asm-arch) \
114 -DARM64_ASM_ARCH='"$(asm-arch)"'
7c78f67e
ZY
115endif
116
da64e9d1
ST
117ifeq ($(CONFIG_SHADOW_CALL_STACK), y)
118KBUILD_CFLAGS += -ffixed-x18
d077242d 119KBUILD_RUSTFLAGS += -Zfixed-x18
da64e9d1
ST
120endif
121
a0974e6e
WD
122ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
123KBUILD_CPPFLAGS += -mbig-endian
bcde519e 124CHECKFLAGS += -D__AARCH64EB__
c931d34e
OJ
125# Prefer the baremetal ELF build target, but not all toolchains include
126# it so fall back to the standard linux version if needed.
311bea3c 127KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb -z norelro)
cfa88c79 128UTS_MACHINE := aarch64_be
a0974e6e 129else
8c2c3df3 130KBUILD_CPPFLAGS += -mlittle-endian
bcde519e 131CHECKFLAGS += -D__AARCH64EL__
c931d34e 132# Same as above, prefer ELF but fall back to linux target if needed.
311bea3c 133KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux -z norelro)
cfa88c79 134UTS_MACHINE := aarch64
a0974e6e 135endif
8c2c3df3 136
311bea3c
ND
137ifeq ($(CONFIG_LD_IS_LLD), y)
138KBUILD_LDFLAGS += -z norelro
139endif
140
1f2f01b1 141CHECKFLAGS += -D__aarch64__
8c2c3df3 142
baaf553d
MR
143ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS),y)
144 KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
145 CC_FLAGS_FTRACE := -fpatchable-function-entry=4,2
146else ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_ARGS),y)
3b23e499
TD
147 KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
148 CC_FLAGS_FTRACE := -fpatchable-function-entry=2
149endif
150
b2f557ea
AK
151ifeq ($(CONFIG_KASAN_SW_TAGS), y)
152KASAN_SHADOW_SCALE_SHIFT := 4
0fea6e9a 153else ifeq ($(CONFIG_KASAN_GENERIC), y)
b2f557ea
AK
154KASAN_SHADOW_SCALE_SHIFT := 3
155endif
156
157KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
158KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
159KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
160
8c2c3df3 161libs-y := arch/arm64/lib/ $(libs-y)
c1aac64d 162libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
8c2c3df3
CM
163
164# Default target when executing plain make
06995804 165boot := arch/arm64/boot
c37b830f 166
7a23b027 167BOOT_TARGETS := Image vmlinuz.efi image.fit
0dc1670b
SG
168
169PHONY += $(BOOT_TARGETS)
170
c37b830f 171ifeq ($(CONFIG_EFI_ZBOOT),)
06995804 172KBUILD_IMAGE := $(boot)/Image.gz
c37b830f
AB
173else
174KBUILD_IMAGE := $(boot)/vmlinuz.efi
175endif
8c2c3df3 176
c37b830f 177all: $(notdir $(KBUILD_IMAGE))
8c2c3df3 178
7a23b027
SG
179image.fit: dtbs
180
181vmlinuz.efi image.fit: Image
0dc1670b 182$(BOOT_TARGETS): vmlinux
0723c05f
OJ
183 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
184
9ca4e58c 185Image.%: Image
70f915a2 186 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
8c2c3df3 187
4c7be57f
LT
188ifeq ($(CONFIG_COMPRESSED_INSTALL),y)
189 DEFAULT_KBUILD_IMAGE = $(KBUILD_IMAGE)
190else
191 DEFAULT_KBUILD_IMAGE = $(boot)/Image
192endif
193
194install: KBUILD_IMAGE := $(DEFAULT_KBUILD_IMAGE)
70a4039b 195install zinstall:
f774f5bb 196 $(call cmd,install)
8c2c3df3 197
0c6c2d36
MB
198archprepare:
199 $(Q)$(MAKE) $(build)=arch/arm64/tools kapi
64ee84c7
MY
200ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
201 ifneq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
202 @echo "warning: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum" >&2
203 endif
204endif
205ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS),y)
206 ifneq ($(CONFIG_ARM64_LSE_ATOMICS),y)
207 @echo "warning: LSE atomics not supported by binutils" >&2
208 endif
209endif
210
98356eb0 211ifeq ($(KBUILD_EXTMOD),)
a66649da
KB
212# We need to generate vdso-offsets.h before compiling certain files in kernel/.
213# In order to do that, we should use the archprepare target, but we can't since
214# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
215# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
216# Therefore we need to generate the header after prepare0 has been made, hence
217# this hack.
218prepare: vdso_prepare
219vdso_prepare: prepare0
a5b8ca97
MY
220 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso \
221 include/generated/vdso-offsets.h arch/arm64/kernel/vdso/vdso.so
222ifdef CONFIG_COMPAT_VDSO
223 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \
c7767f5c 224 arch/arm64/kernel/vdso32/vdso.so
a5b8ca97 225endif
98356eb0 226endif
a66649da 227
56769ba4 228vdso-install-y += arch/arm64/kernel/vdso/vdso.so.dbg
a099bec7 229vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso32.so.dbg
56769ba4 230
c6cd63f5
MB
231include $(srctree)/scripts/Makefile.defconf
232
233PHONY += virtconfig
234virtconfig:
235 $(call merge_into_defconfig_override,defconfig,virt)
236
8c2c3df3
CM
237define archhelp
238 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
239 echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
7a23b027 240 echo ' image.fit - Flat Image Tree (arch/$(ARCH)/boot/image.fit)'
4c7be57f 241 echo ' install - Install kernel (compressed if COMPRESSED_INSTALL set)'
8c2c3df3
CM
242 echo ' zinstall - Install compressed kernel'
243 echo ' Install using (your) ~/bin/installkernel or'
244 echo ' (distribution) /sbin/installkernel or'
245 echo ' install to $$(INSTALL_PATH) and run lilo'
246endef