ANDROID: CROSS_COMPILE_ARM32 must work if CONFIG_COMPAT_VDSO
[GitHub/exynos8895/android_kernel_samsung_universal8895.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
1cac41cb
MB
13ifeq ($(CONFIG_RELOCATABLE_KERNEL), y)
14LDFLAGS_vmlinux :=-p --no-undefined -X -pie -Bsymbolic
15else
8c2c3df3 16LDFLAGS_vmlinux :=-p --no-undefined -X
1cac41cb 17endif
8c2c3df3
CM
18CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
19OBJCOPYFLAGS :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
20GZFLAGS :=-9
21
01684359 22ifneq ($(CONFIG_RELOCATABLE),)
8f012745 23LDFLAGS_vmlinux += -pie -Bsymbolic
01684359
AB
24endif
25
8c2c3df3
CM
26KBUILD_DEFCONFIG := defconfig
27
c09d6a04
WD
28# Check for binutils support for specific extensions
29lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
30
31ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y)
32 ifeq ($(lseinstr),)
33$(warning LSE atomics not supported by binutils)
34 endif
35endif
36
ca9386d7
KB
37ifeq ($(CONFIG_COMPAT_VDSO), y)
38 CROSS_COMPILE_ARM32 ?= $(CONFIG_CROSS_COMPILE_ARM32:"%"=%)
39
40 # Check that the user has provided a valid prefix for the 32-bit toolchain.
41 # To prevent selecting the system $(cc-name) by default, the prefix is not
42 # allowed to be empty, unlike CROSS_COMPILE. In the unlikely event that the
43 # system $(cc-name) is actually the 32-bit ARM compiler to be used, the
44 # variable can be set to the dirname (e.g. CROSS_COMPILE_ARM32=/usr/bin/).
45 # Note: this Makefile is read both before and after regenerating the config
46 # (if needed). Any warning appearing before the config has been regenerated
47 # should be ignored. If the error is triggered and you set
48 # CONFIG_CROSS_COMPILE_ARM32, set CROSS_COMPILE_ARM32 to an appropriate value
49 # when invoking make and fix CONFIG_CROSS_COMPILE_ARM32.
50 ifeq ($(CROSS_COMPILE_ARM32),)
d49555fd 51 $(error CROSS_COMPILE_ARM32 not defined or empty, the compat vDSO will not be built)
ca9386d7
KB
52 else ifeq ($(cc-name),clang)
53 export CLANG_TRIPLE_ARM32 ?= $(CROSS_COMPILE_ARM32)
54 export CLANG_TARGET_ARM32 := --target=$(notdir $(CLANG_TRIPLE_ARM32:%-=%))
55 export CONFIG_VDSO32 := y
56 vdso32 := -DCONFIG_VDSO32=1
57 else ifeq ($(shell which $(CROSS_COMPILE_ARM32)$(cc-name) 2> /dev/null),)
58 $(error $(CROSS_COMPILE_ARM32)$(cc-name) not found, check CROSS_COMPILE_ARM32)
59 else
60 export CROSS_COMPILE_ARM32
61 export CONFIG_VDSO32 := y
62 vdso32 := -DCONFIG_VDSO32=1
63 endif
64endif
65
20ea9516
GH
66ifeq ($(cc-name),clang)
67# This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=30792.
68# TODO: revert when this is fixed in LLVM.
69KBUILD_CFLAGS += -mno-implicit-float
70else
71KBUILD_CFLAGS += -mgeneral-regs-only
72endif
ca9386d7 73KBUILD_CFLAGS += $(lseinstr) $(vdso32)
2e039261 74KBUILD_CFLAGS += -fno-pic
72034521 75KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
db8bb76c 76KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
1cac41cb 77KBUILD_CFLAGS += -fno-pic
ca9386d7 78KBUILD_AFLAGS += $(lseinstr) $(vdso32)
c09d6a04 79
a0974e6e
WD
80ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
81KBUILD_CPPFLAGS += -mbig-endian
82AS += -EB
83LD += -EB
84else
8c2c3df3
CM
85KBUILD_CPPFLAGS += -mlittle-endian
86AS += -EL
87LD += -EL
a0974e6e 88endif
8c2c3df3 89
8c2c3df3
CM
90CHECKFLAGS += -D__aarch64__
91
4166edc4 92ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y)
b6dd8e07 93KBUILD_CFLAGS_MODULE += -mcmodel=large
df057cc7
WD
94endif
95
4166edc4
AB
96ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
97KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds
98endif
99
8c2c3df3
CM
100# Default value
101head-y := arch/arm64/kernel/head.o
102
103# The byte offset of the kernel image in RAM from the start of RAM.
da57a369 104ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y)
4190312b 105TEXT_OFFSET := $(shell awk 'BEGIN {srand(); printf "0x%03x000\n", int(512 * rand())}')
da57a369 106else
8c2c3df3 107TEXT_OFFSET := 0x00080000
da57a369 108endif
8c2c3df3 109
e9186826
MK
110ifeq ($(cc-name),clang)
111KBUILD_CFLAGS += $(call cc-disable-warning, asm-operand-widths)
112endif
113
39d114dd
AR
114# KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
115# in 32-bit arithmetic
116KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \
117 (0xffffffff & (-1 << ($(CONFIG_ARM64_VA_BITS) - 32))) \
118 + (1 << ($(CONFIG_ARM64_VA_BITS) - 32 - 3)) \
119 - (1 << (64 - 32 - 3)) )) )
120
8c2c3df3
CM
121export TEXT_OFFSET GZFLAGS
122
123core-y += arch/arm64/kernel/ arch/arm64/mm/
e54bcde3 124core-$(CONFIG_NET) += arch/arm64/net/
6211753f 125core-$(CONFIG_KVM) += arch/arm64/kvm/
63917f0b 126core-$(CONFIG_XEN) += arch/arm64/xen/
2c98833a 127core-$(CONFIG_CRYPTO) += arch/arm64/crypto/
8c2c3df3 128libs-y := arch/arm64/lib/ $(libs-y)
ad08fd49 129core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
8c2c3df3
CM
130
131# Default target when executing plain make
69a800c9 132ifeq ($(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE),y)
a08cafa7 133KBUILD_IMAGE := $(subst $\",,$(CONFIG_BUILD_ARM64_APPENDED_KERNEL_IMAGE_NAME))
69a800c9 134else
70f915a2 135KBUILD_IMAGE := Image.gz
69a800c9
AR
136endif
137
70f915a2 138KBUILD_DTBS := dtbs
8c2c3df3 139
70f915a2 140all: $(KBUILD_IMAGE) $(KBUILD_DTBS)
8c2c3df3
CM
141
142boot := arch/arm64/boot
143
0723c05f
OJ
144Image: vmlinux
145 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
146
147Image.%: vmlinux
70f915a2 148 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
8c2c3df3
CM
149
150zinstall install: vmlinux
70f915a2 151 $(Q)$(MAKE) $(build)=$(boot) $@
8c2c3df3 152
70f915a2
RH
153%.dtb: scripts
154 $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
155
862f464a 156PHONY += dtbs dtbs_install
9fb5e537
RR
157
158dtbs: prepare scripts
d38726c4 159 $(Q)$(MAKE) $(build)=$(boot)/dts
8c2c3df3 160
9fb5e537
RR
161dtbs_install:
162 $(Q)$(MAKE) $(dtbinst)=$(boot)/dts
163
c11dd134 164Image-dtb Image.gz-dtb: vmlinux scripts dtbs
69a800c9
AR
165 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
166
3c01742a
KM
167PHONY += vdso_install
168vdso_install:
169 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
170
8c2c3df3
CM
171# We use MRPROPER_FILES and CLEAN_FILES now
172archclean:
173 $(Q)$(MAKE) $(clean)=$(boot)
c7c52e48 174 $(Q)$(MAKE) $(clean)=$(boot)/dts
8c2c3df3 175
fb47dee8
KB
176# We need to generate vdso-offsets.h before compiling certain files in kernel/.
177# In order to do that, we should use the archprepare target, but we can't since
178# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
179# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
180# Therefore we need to generate the header after prepare0 has been made, hence
181# this hack.
182prepare: vdso_prepare
183vdso_prepare: prepare0
184 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h
ca9386d7
KB
185 $(if $(CONFIG_VDSO32),$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \
186 include/generated/vdso32-offsets.h)
fb47dee8 187
8c2c3df3
CM
188define archhelp
189 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
190 echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
70f915a2 191 echo '* dtbs - Build device tree blobs for enabled boards'
862f464a 192 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
8c2c3df3
CM
193 echo ' install - Install uncompressed kernel'
194 echo ' zinstall - Install compressed kernel'
195 echo ' Install using (your) ~/bin/installkernel or'
196 echo ' (distribution) /sbin/installkernel or'
197 echo ' install to $$(INSTALL_PATH) and run lilo'
198endef