Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) # Unified Makefile for i386 and x86_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) # select defconfig based on actual architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) ifeq ($(ARCH),x86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)   ifeq ($(shell uname -m),x86_64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)         KBUILD_DEFCONFIG := x86_64_defconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)   else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)         KBUILD_DEFCONFIG := i386_defconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)   endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)         KBUILD_DEFCONFIG := $(ARCH)_defconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) # For gcc stack alignment is specified with -mpreferred-stack-boundary,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) # clang has the option -mstack-alignment for that purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)       cc_stack_align4 := -mpreferred-stack-boundary=2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)       cc_stack_align8 := -mpreferred-stack-boundary=3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) else ifneq ($(call cc-option, -mstack-alignment=16),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)       cc_stack_align4 := -mstack-alignment=4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)       cc_stack_align8 := -mstack-alignment=8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) # How to compile the 16-bit code.  Note we always compile for -march=i386;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) # that way we can complain to the user if the CPU is insufficient.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) # The -m16 option is supported by GCC >= 4.9 and clang >= 3.5. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) # older versions of GCC, include an *assembly* header to make sure that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) # gcc doesn't play any games behind our back.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) CODE16GCC_CFLAGS := -m32 -Wa,$(srctree)/arch/x86/boot/code16gcc.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) M16_CFLAGS	 := $(call cc-option, -m16, $(CODE16GCC_CFLAGS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) REALMODE_CFLAGS	:= $(M16_CFLAGS) -g -Os -DDISABLE_BRANCH_PROFILING \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		   -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		   -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		   -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) REALMODE_CFLAGS += -ffreestanding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) REALMODE_CFLAGS += -fno-stack-protector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) REALMODE_CFLAGS += $(CLANG_FLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) export REALMODE_CFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) # BITS is used as extension for files which are available in a 32 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) # and a 64 bit version to simplify shared Makefiles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) # e.g.: obj-y += foo_$(BITS).o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) export BITS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) # Prevent GCC from generating any FP code by mistake.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) # This must happen before we try the -mpreferred-stack-boundary, see:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) # Intel CET isn't enabled in the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) ifeq ($(CONFIG_X86_32),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)         BITS := 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)         UTS_MACHINE := i386
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)         CHECKFLAGS += -D__i386__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)         biarch := $(call cc-option,-m32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)         KBUILD_AFLAGS += $(biarch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)         KBUILD_CFLAGS += $(biarch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)         KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)         # Never want PIC in a 32-bit kernel, prevent breakage with GCC built
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)         # with nonstandard options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)         KBUILD_CFLAGS += -fno-pic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)         # Align the stack to the register width instead of using the default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)         # alignment of 16 bytes. This reduces stack usage and the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)         # alignment instructions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)         KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)         # CPU-specific tuning. Anything which can be shared with UML should go here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)         include arch/x86/Makefile_32.cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)         KBUILD_CFLAGS += $(cflags-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)         # temporary until string.h is fixed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)         KBUILD_CFLAGS += -ffreestanding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)         BITS := 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)         UTS_MACHINE := x86_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)         CHECKFLAGS += -D__x86_64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)         biarch := -m64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)         KBUILD_AFLAGS += -m64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)         KBUILD_CFLAGS += -m64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)         # Align jump targets to 1 byte, not the default 16 bytes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)         KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)         # Pack loops tightly as well:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)         KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)         # Don't autogenerate traditional x87 instructions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)         KBUILD_CFLAGS += $(call cc-option,-mno-80387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)         KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)         # By default gcc and clang use a stack alignment of 16 bytes for x86.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)         # However the standard kernel entry on x86-64 leaves the stack on an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)         # 8-byte boundary. If the compiler isn't informed about the actual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)         # alignment it will generate extra alignment instructions for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)         # default alignment which keep the stack *mis*aligned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)         # Furthermore an alignment to the register width reduces stack usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)         # and the number of alignment instructions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)         KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	# Use -mskip-rax-setup if supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)         # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)         cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)         cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)         cflags-$(CONFIG_MCORE2) += \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)                 $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)         cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)         KBUILD_CFLAGS += $(cflags-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)         KBUILD_CFLAGS += -mno-red-zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)         KBUILD_CFLAGS += -mcmodel=kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) ifdef CONFIG_X86_X32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	x32_ld_ok := $(call try-run,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			/bin/echo -e '1: .quad 1b' | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			$(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			$(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			$(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)         ifeq ($(x32_ld_ok),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)                 CONFIG_X86_X32_ABI := y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)                 KBUILD_AFLAGS += -DCONFIG_X86_X32_ABI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)                 KBUILD_CFLAGS += -DCONFIG_X86_X32_ABI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)         else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)                 $(warning CONFIG_X86_X32 enabled but no binutils support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)         endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) export CONFIG_X86_X32_ABI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) # If the function graph tracer is used with mcount instead of fentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) # '-maccumulate-outgoing-args' is needed to prevent a GCC bug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) # (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) ifdef CONFIG_FUNCTION_GRAPH_TRACER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)   ifndef CONFIG_HAVE_FENTRY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	ACCUMULATE_OUTGOING_ARGS := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)   else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)     ifeq ($(call cc-option-yn, -mfentry), n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	ACCUMULATE_OUTGOING_ARGS := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	# GCC ignores '-maccumulate-outgoing-args' when used with '-Os'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	# If '-Os' is enabled, disable it and print a warning.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)         ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)           undefine CONFIG_CC_OPTIMIZE_FOR_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)           $(warning Disabling CONFIG_CC_OPTIMIZE_FOR_SIZE.  Your compiler does not have -mfentry so you cannot optimize for size with CONFIG_FUNCTION_GRAPH_TRACER.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)         endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)     endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)   endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	# This compiler flag is not supported by Clang:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) # Workaround for a gcc prelease that unfortunately was shipped in a suse release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) KBUILD_CFLAGS += -Wno-sign-compare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) # Avoid indirect branches in kernel to deal with Spectre
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) ifdef CONFIG_RETPOLINE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)   KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)   # Additionally, avoid generating expensive indirect jumps which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)   # are subject to retpolines for small number of switch cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)   # clang turns off jump table generation by default when under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)   # retpoline builds, however, gcc does not for x86. This has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)   # only been fixed starting from gcc stable version 8.4.0 and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)   # onwards, but not for older ones. See gcc bug #86952.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)   ifndef CONFIG_CC_IS_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)     KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)   endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) ifdef CONFIG_LTO_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) KBUILD_LDFLAGS	+= -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ifdef CONFIG_X86_NEED_RELOCS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) LDFLAGS_vmlinux := --emit-relocs --discard-none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) LDFLAGS_vmlinux :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) # The 64-bit kernel must be aligned to 2MB.  Pass -z max-page-size=0x200000 to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) # the linker to force 2MB page size regardless of the default page size used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) # by the linker.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ifdef CONFIG_X86_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) LDFLAGS_vmlinux += -z max-page-size=0x200000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) archscripts: scripts_basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	$(Q)$(MAKE) $(build)=arch/x86/tools relocs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) ###
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) # Syscall table generation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) archheaders:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	$(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ###
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) # Kernel objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) head-y := arch/x86/kernel/head_$(BITS).o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) head-y += arch/x86/kernel/head$(BITS).o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) head-y += arch/x86/kernel/ebda.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) head-y += arch/x86/kernel/platform-quirks.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) libs-y  += arch/x86/lib/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) # See arch/x86/Kbuild for content of core part of the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) core-y += arch/x86/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) # drivers-y are linked after core-y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) drivers-$(CONFIG_PCI)            += arch/x86/pci/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) # must be linked after kernel/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) drivers-$(CONFIG_OPROFILE) += arch/x86/oprofile/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) # suspend and hibernation support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) drivers-$(CONFIG_PM) += arch/x86/power/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) drivers-$(CONFIG_FB) += arch/x86/video/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ####
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) # boot loader support. Several targets are kept for legacy purposes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) boot := arch/x86/boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 isoimage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) PHONY += bzImage $(BOOT_TARGETS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) # Don't compile Image in mixed build with "all" target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ifndef KBUILD_MIXED_TREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) # Default kernel to build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) all: bzImage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) # KBUILD_IMAGE specify target image being built
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) KBUILD_IMAGE := $(boot)/bzImage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) bzImage: vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) ifeq ($(CONFIG_X86_DECODER_SELFTEST),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	$(Q)$(MAKE) $(build)=arch/x86/tools posttest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	$(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	$(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	$(Q)ln -fsn ../../x86/boot/bzImage $(objtree)/arch/$(UTS_MACHINE)/boot/$@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) $(BOOT_TARGETS): vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	$(Q)$(MAKE) $(build)=$(boot) $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) PHONY += install bzlilo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) install bzlilo:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	$(Q)$(MAKE) $(build)=$(boot) $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) PHONY += vdso_install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) vdso_install:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	$(Q)$(MAKE) $(build)=arch/x86/entry/vdso $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) archprepare: checkbin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) checkbin:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) ifndef CONFIG_CC_HAS_ASM_GOTO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	@echo Compiler lacks asm-goto support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	@exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ifdef CONFIG_RETPOLINE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) ifeq ($(RETPOLINE_CFLAGS),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	@echo "You are building kernel with non-retpoline compiler." >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	@echo "Please update your compiler." >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	@false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) archclean:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	$(Q)rm -rf $(objtree)/arch/i386
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	$(Q)rm -rf $(objtree)/arch/x86_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	$(Q)$(MAKE) $(clean)=$(boot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	$(Q)$(MAKE) $(clean)=arch/x86/tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) define archhelp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)   echo  '* bzImage      - Compressed kernel image (arch/x86/boot/bzImage)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)   echo  '  install      - Install kernel using'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)   echo  '                  (your) ~/bin/$(INSTALLKERNEL) or'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)   echo  '                  (distribution) /sbin/$(INSTALLKERNEL) or'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)   echo  '                  install to $$(INSTALL_PATH) and run lilo'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)   echo  '  fdimage      - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)   echo  '  fdimage144   - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)   echo  '  fdimage288   - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)   echo  '  isoimage     - Create a boot CD-ROM image (arch/x86/boot/image.iso)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)   echo  '                  bzdisk/fdimage*/isoimage also accept:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)   echo  '                  FDARGS="..."  arguments for the booted kernel'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)   echo  '                  FDINITRD=file initrd for the booted kernel'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) endef