Something went wrong. Try again.
(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366# SPDX-License-Identifier: GPL-2.0# Unified Makefile for i386 and x86_64
# select defconfig based on actual architectureifeq ($(ARCH),x86) ifeq ($(shell uname -m | sed -e 's/i.86/i386/'),i386) KBUILD_DEFCONFIG := i386_defconfig else KBUILD_DEFCONFIG := x86_64_defconfig endifelse KBUILD_DEFCONFIG := $(ARCH)_defconfigendif
ifdef CONFIG_CC_IS_GCCRETPOLINE_CFLAGS := -mindirect-branch=thunk-extern -mindirect-branch-registerRETPOLINE_VDSO_CFLAGS := -mindirect-branch=thunk-inline -mindirect-branch-registerendififdef CONFIG_CC_IS_CLANGRETPOLINE_CFLAGS := -mretpoline-external-thunkRETPOLINE_VDSO_CFLAGS := -mretpolineendifRETPOLINE_CFLAGS += $(CONFIG_CC_OPT_INDIRECT_BRANCH_CS_PREFIX)
ifdef CONFIG_MITIGATION_RETHUNKRETHUNK_CFLAGS := -mfunction-return=thunk-externRETHUNK_RUSTFLAGS := -Zfunction-return=thunk-externRETPOLINE_CFLAGS += $(RETHUNK_CFLAGS)RETPOLINE_RUSTFLAGS += $(RETHUNK_RUSTFLAGS)endif
export RETHUNK_CFLAGSexport RETHUNK_RUSTFLAGSexport RETPOLINE_CFLAGSexport RETPOLINE_RUSTFLAGSexport RETPOLINE_VDSO_CFLAGS
# For gcc stack alignment is specified with -mpreferred-stack-boundary,# clang has the option -mstack-alignment for that purpose.ifdef CONFIG_CC_IS_GCC cc_stack_align4 := -mpreferred-stack-boundary=2 cc_stack_align8 := -mpreferred-stack-boundary=3endififdef CONFIG_CC_IS_CLANG cc_stack_align4 := -mstack-alignment=4 cc_stack_align8 := -mstack-alignment=8endif
# How to compile the 16-bit code. Note we always compile for -march=i386;# that way we can complain to the user if the CPU is insufficient.REALMODE_CFLAGS := $(CC_FLAGS_DIALECT) -m16 -g -Os \ -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \ -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \ -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ -mno-mmx -mno-sse $(CONFIG_CC_OPT_CF_PROTECTION_NONE)
REALMODE_CFLAGS += -ffreestandingREALMODE_CFLAGS += -fno-stack-protectorREALMODE_CFLAGS += -Wno-address-of-packed-memberREALMODE_CFLAGS += $(cc_stack_align4)REALMODE_CFLAGS += $(CLANG_FLAGS)export REALMODE_CFLAGS
# BITS is used as extension for files which are available in a 32 bit# and a 64 bit version to simplify shared Makefiles.# e.g.: obj-y += foo_$(BITS).oexport BITS
## Prevent GCC from generating any FP code by mistake.## This must happen before we try the -mpreferred-stack-boundary, see:## https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383#KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4aKBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.jsonKBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
# The target.json file is not available when invoking rustc-option, so use the# built-in target when checking whether flags are supported instead.KBUILD_RUSTFLAGS_OPTION_CHKS += --target=x86_64-unknown-none
## CFLAGS for compiling floating point code inside the kernel.#CC_FLAGS_FPU := -msse -msse2ifdef CONFIG_CC_IS_GCCCC_FLAGS_FPU += -mhard-floatendif
ifeq ($(CONFIG_X86_KERNEL_IBT),y)## Kernel IBT has S_CET.NOTRACK_EN=0, as such the compilers must not generate# NOTRACK prefixes. Current generation compilers unconditionally employ NOTRACK# for jump-tables, as such, disable jump-tables for now.## (jump-tables are implicitly disabled by RETPOLINE)## https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104816#KBUILD_CFLAGS += $(CONFIG_CC_OPT_CF_PROTECTION_BRANCH)KBUILD_RUSTFLAGS += -Zcf-protection=branch $(if $(call rustc-min-version,109300),-Cjump-tables=n,-Zno-jump-tables)elseKBUILD_CFLAGS += $(CONFIG_CC_OPT_CF_PROTECTION_NONE)endif
ifeq ($(CONFIG_X86_32),y) BITS := 32 UTS_MACHINE := i386 CHECKFLAGS += -D__i386__
KBUILD_AFLAGS += -m32 KBUILD_CFLAGS += -m32
KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
# Never want PIC in a 32-bit kernel, prevent breakage with GCC built # with nonstandard options KBUILD_CFLAGS += -fno-pic
# Align the stack to the register width instead of using the default # alignment of 16 bytes. This reduces stack usage and the number of # alignment instructions. KBUILD_CFLAGS += $(cc_stack_align4)
# CPU-specific tuning. Anything which can be shared with UML should go here. include $(srctree)/arch/x86/Makefile_32.cpu KBUILD_CFLAGS += $(cflags-y)
percpu_seg := fselse BITS := 64 UTS_MACHINE := x86_64 CHECKFLAGS += -D__x86_64__
KBUILD_AFLAGS += -m64 KBUILD_CFLAGS += -m64
# Align jump targets to 1 byte, not the default 16 bytes: KBUILD_CFLAGS += $(CONFIG_CC_OPT_FALIGN_JUMPS)
# Pack loops tightly as well: KBUILD_CFLAGS += $(CONFIG_CC_OPT_FALIGN_LOOPS)
# Don't autogenerate traditional x87 instructions KBUILD_CFLAGS += -mno-80387 KBUILD_CFLAGS += -mno-fp-ret-in-387
# By default gcc and clang use a stack alignment of 16 bytes for x86. # However the standard kernel entry on x86-64 leaves the stack on an # 8-byte boundary. If the compiler isn't informed about the actual # alignment it will generate extra alignment instructions for the # default alignment which keep the stack *mis*aligned. # Furthermore an alignment to the register width reduces stack usage # and the number of alignment instructions. KBUILD_CFLAGS += $(cc_stack_align8)
# Use -mskip-rax-setup if supported. KBUILD_CFLAGS += -mskip-rax-setup
ifdef CONFIG_X86_NATIVE_CPU KBUILD_CFLAGS += -march=native # Prevent the compiler from generating EGPR use. The kernel is # not yet prepared for general in-kernel use. KBUILD_CFLAGS += $(call cc-option,-mno-apx-features=egpr)
# generate_rust_target.rs handles Rust APX gating. KBUILD_RUSTFLAGS += -Ctarget-cpu=nativeelse KBUILD_CFLAGS += -march=x86-64 -mtune=generic KBUILD_RUSTFLAGS += -Ctarget-cpu=x86-64 -Ztune-cpu=genericendif
KBUILD_CFLAGS += -mno-red-zone KBUILD_CFLAGS += -mcmodel=kernel KBUILD_RUSTFLAGS += -Cno-redzone=y KBUILD_RUSTFLAGS += -Ccode-model=kernel
percpu_seg := gsendif
ifeq ($(CONFIG_STACKPROTECTOR),y) ifeq ($(CONFIG_SMP),y) KBUILD_CFLAGS += -mstack-protector-guard-reg=$(percpu_seg) KBUILD_CFLAGS += -mstack-protector-guard-symbol=__ref_stack_chk_guard else KBUILD_CFLAGS += -mstack-protector-guard=global endifendif
## If the function graph tracer is used with mcount instead of fentry,# '-maccumulate-outgoing-args' is needed to prevent a GCC bug# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109)#ifdef CONFIG_FUNCTION_GRAPH_TRACER ifndef CONFIG_HAVE_FENTRY ACCUMULATE_OUTGOING_ARGS := 1 endifendif
ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1) # This compiler flag is not supported by Clang: KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)endif
# Workaround for a gcc prelease that unfortunately was shipped in a suse releaseKBUILD_CFLAGS += -Wno-sign-compare#KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
# Avoid indirect branches in kernel to deal with Spectreifdef CONFIG_MITIGATION_RETPOLINE KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) KBUILD_RUSTFLAGS += $(RETPOLINE_RUSTFLAGS) # Additionally, avoid generating expensive indirect jumps which # are subject to retpolines for small number of switch cases. # LLVM turns off jump table generation by default when under # retpoline builds, however, gcc does not for x86. This has # only been fixed starting from gcc stable version 8.4.0 and # onwards, but not for older ones. See gcc bug #86952. ifndef CONFIG_CC_IS_CLANG KBUILD_CFLAGS += -fno-jump-tables endifendif
ifdef CONFIG_MITIGATION_SLS KBUILD_CFLAGS += -mharden-sls=allendif
ifdef CONFIG_CALL_PADDINGPADDING_CFLAGS := -fpatchable-function-entry=$(CONFIG_FUNCTION_PADDING_BYTES),$(CONFIG_FUNCTION_PADDING_BYTES)KBUILD_CFLAGS += $(PADDING_CFLAGS)export PADDING_CFLAGS
PADDING_RUSTFLAGS := -Zpatchable-function-entry=$(CONFIG_FUNCTION_PADDING_BYTES),$(CONFIG_FUNCTION_PADDING_BYTES)KBUILD_RUSTFLAGS += $(PADDING_RUSTFLAGS)export PADDING_RUSTFLAGSendif
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
## The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to# the linker to force 2MB page size regardless of the default page size used# by the linker.#ifdef CONFIG_X86_64LDFLAGS_vmlinux += -z max-page-size=0x200000endif
archscripts: scripts_basic $(Q)$(MAKE) $(build)=arch/x86/tools relocs vdso2c
#### Syscall table generation
archheaders: $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
#### <asm/cpufeaturemasks.h> header generation
cpufeaturemasks.hdr := arch/x86/include/generated/asm/cpufeaturemasks.hcpufeaturemasks.awk := $(srctree)/arch/x86/tools/cpufeaturemasks.awkcpufeatures_hdr := $(srctree)/arch/x86/include/asm/cpufeatures.htargets += $(cpufeaturemasks.hdr) filechk_gen_featuremasks = $(AWK) -f $(cpufeaturemasks.awk) $(cpufeatures_hdr) $(KCONFIG_CONFIG)
$(cpufeaturemasks.hdr): $(cpufeaturemasks.awk) $(cpufeatures_hdr) $(KCONFIG_CONFIG) FORCE $(shell mkdir -p $(dir $@)) $(call filechk,gen_featuremasks)archprepare: $(cpufeaturemasks.hdr)
#### Kernel objects
libs-y += arch/x86/lib/
# drivers-y are linked after core-ydrivers-$(CONFIG_PCI) += arch/x86/pci/
# suspend and hibernation supportdrivers-$(CONFIG_PM) += arch/x86/power/
drivers-$(CONFIG_VIDEO) += arch/x86/video/
##### boot loader support. Several targets are kept for legacy purposes
boot := arch/x86/boot
BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 hdimage isoimage
PHONY += bzImage $(BOOT_TARGETS)
# Default kernel to buildall: bzImage
# KBUILD_IMAGE specify target image being builtKBUILD_IMAGE := $(boot)/bzImage
bzImage: vmlinuxifeq ($(CONFIG_X86_DECODER_SELFTEST),y) $(Q)$(MAKE) $(build)=arch/x86/tools posttestendif $(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE) $(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot $(Q)ln -fsn ../../x86/boot/bzImage $(objtree)/arch/$(UTS_MACHINE)/boot/$@
$(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(boot) $@
PHONY += installinstall: $(call cmd,install)
vdso-install-$(CONFIG_X86_64) += arch/x86/entry/vdso/vdso64/vdso64.so.dbgvdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdso64/vdsox32.so.dbgvdso-install-$(CONFIG_COMPAT_32) += arch/x86/entry/vdso/vdso32/vdso32.so.dbg
archprepare: checkbincheckbin:ifdef CONFIG_MITIGATION_RETPOLINEifeq ($(RETPOLINE_CFLAGS),) @echo "You are building kernel with non-retpoline compiler." >&2 @echo "Please update your compiler." >&2 @falseendifendif
ifdef CONFIG_UNWINDER_ORCorc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.horc_hash_sh := $(srctree)/scripts/orc_hash.shtargets += $(orc_hash_h)quiet_cmd_orc_hash = GEN $@ cmd_orc_hash = mkdir -p $(dir $@); \ $(CONFIG_SHELL) $(orc_hash_sh) < $< > $@$(orc_hash_h): $(srctree)/arch/x86/include/asm/orc_types.h $(orc_hash_sh) FORCE $(call if_changed,orc_hash)archprepare: $(orc_hash_h)endif
archclean: $(Q)rm -rf $(objtree)/arch/i386 $(Q)rm -rf $(objtree)/arch/x86_64
define archhelp echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)' echo ' install - Install kernel using (your) ~/bin/$(INSTALLKERNEL) or' echo ' (distribution) /sbin/$(INSTALLKERNEL) or install to ' echo ' $$(INSTALL_PATH) and run lilo' echo '' echo ' fdimage - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)' echo ' fdimage144 - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)' echo ' fdimage288 - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)' echo ' hdimage - Create a BIOS/EFI hard disk image (arch/x86/boot/hdimage)' echo ' isoimage - Create a boot CD-ROM image (arch/x86/boot/image.iso)' echo ' bzdisk/fdimage*/hdimage/isoimage also accept:' echo ' FDARGS="..." arguments for the booted kernel' echo ' FDINITRD=file initrd for the booted kernel'
endef