Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / arm64 / Makefile
blob358c68565bfd0633d8565187016e1003445208fc
2 # arch/arm64/Makefile
4 # This file is included by the global makefile so that you can add your own
5 # architecture-specific flags and dependencies.
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.
11 # Copyright (C) 1995-2001 by Russell King
13 LDFLAGS_vmlinux :=--no-undefined -X --pic-veneer
15 ifeq ($(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.
19 LDFLAGS_vmlinux += -shared -Bsymbolic -z notext \
20 $(call ld-option, --no-apply-dynamic-relocs)
21 endif
23 ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
24 ifeq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
25 LDFLAGS_vmlinux += --fix-cortex-a53-843419
26 endif
27 endif
29 cc_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)
35 ifeq ($(CONFIG_BROKEN_GAS_INST),y)
36 $(warning Detected assembler with broken .inst; disassembly will be unreliable)
37 endif
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)
41 CC_FLAGS_FPU := -ffreestanding
42 # Enable <arm_neon.h>
43 CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include)
44 CC_FLAGS_NO_FPU := -mgeneral-regs-only
46 KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \
47 $(compat_vdso) $(cc_has_k_constraint)
48 KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
49 KBUILD_AFLAGS += $(compat_vdso)
51 KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"
53 KBUILD_CFLAGS += $(call cc-option,-mabi=lp64)
54 KBUILD_AFLAGS += $(call cc-option,-mabi=lp64)
56 # Avoid generating .eh_frame* sections.
57 ifneq ($(CONFIG_UNWIND_TABLES),y)
58 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
59 KBUILD_AFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
60 KBUILD_RUSTFLAGS += -Cforce-unwind-tables=n
61 else
62 KBUILD_CFLAGS += -fasynchronous-unwind-tables
63 KBUILD_AFLAGS += -fasynchronous-unwind-tables
64 KBUILD_RUSTFLAGS += -Cforce-unwind-tables=y -Zuse-sync-unwind=n
65 endif
67 ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)
68 prepare: stack_protector_prepare
69 stack_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 $(objtree)/include/generated/asm-offsets.h))
75 endif
77 ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
78 KBUILD_CFLAGS += -mbranch-protection=pac-ret+bti
79 KBUILD_RUSTFLAGS += -Zbranch-protection=bti,pac-ret
80 else ifeq ($(CONFIG_ARM64_PTR_AUTH_KERNEL),y)
81 KBUILD_RUSTFLAGS += -Zbranch-protection=pac-ret
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
87 else
88 KBUILD_CFLAGS += $(call cc-option,-mbranch-protection=none)
89 endif
91 # Tell the assembler to support instructions from the latest target
92 # architecture.
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.
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.
102 ifeq ($(CONFIG_AS_HAS_ARMV8_5), y)
103 asm-arch := armv8.5-a
104 else ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
105 asm-arch := armv8.4-a
106 else ifeq ($(CONFIG_AS_HAS_ARMV8_3), y)
107 asm-arch := armv8.3-a
108 else ifeq ($(CONFIG_AS_HAS_ARMV8_2), y)
109 asm-arch := armv8.2-a
110 endif
112 ifdef asm-arch
113 KBUILD_CFLAGS += -Wa,-march=$(asm-arch) \
114 -DARM64_ASM_ARCH='"$(asm-arch)"'
115 endif
117 ifeq ($(CONFIG_SHADOW_CALL_STACK), y)
118 KBUILD_CFLAGS += -ffixed-x18
119 KBUILD_RUSTFLAGS += -Zfixed-x18
120 endif
122 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
123 KBUILD_CPPFLAGS += -mbig-endian
124 CHECKFLAGS += -D__AARCH64EB__
125 # Prefer the baremetal ELF build target, but not all toolchains include
126 # it so fall back to the standard linux version if needed.
127 KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb -z norelro)
128 UTS_MACHINE := aarch64_be
129 else
130 KBUILD_CPPFLAGS += -mlittle-endian
131 CHECKFLAGS += -D__AARCH64EL__
132 # Same as above, prefer ELF but fall back to linux target if needed.
133 KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux -z norelro)
134 UTS_MACHINE := aarch64
135 endif
137 ifeq ($(CONFIG_LD_IS_LLD), y)
138 KBUILD_LDFLAGS += -z norelro
139 endif
141 CHECKFLAGS += -D__aarch64__
143 ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS),y)
144 KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
145 CC_FLAGS_FTRACE := -fpatchable-function-entry=4,2
146 else ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_ARGS),y)
147 KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
148 CC_FLAGS_FTRACE := -fpatchable-function-entry=2
149 endif
151 ifeq ($(CONFIG_KASAN_SW_TAGS), y)
152 KASAN_SHADOW_SCALE_SHIFT := 4
153 else ifeq ($(CONFIG_KASAN_GENERIC), y)
154 KASAN_SHADOW_SCALE_SHIFT := 3
155 endif
157 KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
158 KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
159 KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
161 libs-y := arch/arm64/lib/ $(libs-y)
162 libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
164 # Default target when executing plain make
165 boot := arch/arm64/boot
167 BOOT_TARGETS := Image vmlinuz.efi image.fit
169 PHONY += $(BOOT_TARGETS)
171 ifeq ($(CONFIG_EFI_ZBOOT),)
172 KBUILD_IMAGE := $(boot)/Image.gz
173 else
174 KBUILD_IMAGE := $(boot)/vmlinuz.efi
175 endif
177 all: $(notdir $(KBUILD_IMAGE))
179 image.fit: dtbs
181 vmlinuz.efi image.fit: Image
182 $(BOOT_TARGETS): vmlinux
183 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
185 Image.%: Image
186 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
188 ifeq ($(CONFIG_COMPRESSED_INSTALL),y)
189 DEFAULT_KBUILD_IMAGE = $(KBUILD_IMAGE)
190 else
191 DEFAULT_KBUILD_IMAGE = $(boot)/Image
192 endif
194 install: KBUILD_IMAGE := $(DEFAULT_KBUILD_IMAGE)
195 install zinstall:
196 $(call cmd,install)
198 archprepare:
199 $(Q)$(MAKE) $(build)=arch/arm64/tools kapi
200 ifeq ($(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
204 endif
205 ifeq ($(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
209 endif
211 ifeq ($(KBUILD_EXTMOD),)
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.
218 prepare: vdso_prepare
219 vdso_prepare: prepare0
220 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso \
221 include/generated/vdso-offsets.h arch/arm64/kernel/vdso/vdso.so
222 ifdef CONFIG_COMPAT_VDSO
223 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \
224 arch/arm64/kernel/vdso32/vdso.so
225 endif
226 endif
228 vdso-install-y += arch/arm64/kernel/vdso/vdso.so.dbg
229 vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso32.so.dbg
231 include $(srctree)/scripts/Makefile.defconf
233 PHONY += virtconfig
234 virtconfig:
235 $(call merge_into_defconfig_override,defconfig,virt)
237 define archhelp
238 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
239 echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
240 echo ' image.fit - Flat Image Tree (arch/$(ARCH)/boot/image.fit)'
241 echo ' install - Install kernel (compressed if COMPRESSED_INSTALL set)'
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'
246 endef