Makefile (cbb245239282870bc6f54d5137dfe0f84b48ea72) Makefile (d92cc4d5164398cc6d191084b46e622976c0ba89)
1# SPDX-License-Identifier: GPL-2.0
2# Unified Makefile for i386 and x86_64
3
4# select defconfig based on actual architecture
5ifeq ($(ARCH),x86)
6 ifeq ($(shell uname -m),x86_64)
7 KBUILD_DEFCONFIG := x86_64_defconfig
8 else

--- 19 unchanged lines hidden (view full) ---

28 -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
29 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
30 -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)
31
32REALMODE_CFLAGS += -ffreestanding
33REALMODE_CFLAGS += -fno-stack-protector
34REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member)
35REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
1# SPDX-License-Identifier: GPL-2.0
2# Unified Makefile for i386 and x86_64
3
4# select defconfig based on actual architecture
5ifeq ($(ARCH),x86)
6 ifeq ($(shell uname -m),x86_64)
7 KBUILD_DEFCONFIG := x86_64_defconfig
8 else

--- 19 unchanged lines hidden (view full) ---

28 -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
29 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
30 -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)
31
32REALMODE_CFLAGS += -ffreestanding
33REALMODE_CFLAGS += -fno-stack-protector
34REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member)
35REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
36REALMODE_CFLAGS += $(CLANG_FLAGS)
36export REALMODE_CFLAGS
37
38# BITS is used as extension for files which are available in a 32 bit
39# and a 64 bit version to simplify shared Makefiles.
40# e.g.: obj-y += foo_$(BITS).o
41export BITS
42
43#

--- 30 unchanged lines hidden (view full) ---

74 KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4))
75
76 # CPU-specific tuning. Anything which can be shared with UML should go here.
77 include arch/x86/Makefile_32.cpu
78 KBUILD_CFLAGS += $(cflags-y)
79
80 # temporary until string.h is fixed
81 KBUILD_CFLAGS += -ffreestanding
37export REALMODE_CFLAGS
38
39# BITS is used as extension for files which are available in a 32 bit
40# and a 64 bit version to simplify shared Makefiles.
41# e.g.: obj-y += foo_$(BITS).o
42export BITS
43
44#

--- 30 unchanged lines hidden (view full) ---

75 KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4))
76
77 # CPU-specific tuning. Anything which can be shared with UML should go here.
78 include arch/x86/Makefile_32.cpu
79 KBUILD_CFLAGS += $(cflags-y)
80
81 # temporary until string.h is fixed
82 KBUILD_CFLAGS += -ffreestanding
83
84 ifeq ($(CONFIG_STACKPROTECTOR),y)
85 ifeq ($(CONFIG_SMP),y)
86 KBUILD_CFLAGS += -mstack-protector-guard-reg=fs -mstack-protector-guard-symbol=__stack_chk_guard
87 else
88 KBUILD_CFLAGS += -mstack-protector-guard=global
89 endif
90 endif
82else
83 BITS := 64
84 UTS_MACHINE := x86_64
85 CHECKFLAGS += -D__x86_64__
86
87 biarch := -m64
88 KBUILD_AFLAGS += -m64
89 KBUILD_CFLAGS += -m64

--- 34 unchanged lines hidden (view full) ---

124 KBUILD_CFLAGS += -mno-red-zone
125 KBUILD_CFLAGS += -mcmodel=kernel
126endif
127
128ifdef CONFIG_X86_X32
129 x32_ld_ok := $(call try-run,\
130 /bin/echo -e '1: .quad 1b' | \
131 $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
91else
92 BITS := 64
93 UTS_MACHINE := x86_64
94 CHECKFLAGS += -D__x86_64__
95
96 biarch := -m64
97 KBUILD_AFLAGS += -m64
98 KBUILD_CFLAGS += -m64

--- 34 unchanged lines hidden (view full) ---

133 KBUILD_CFLAGS += -mno-red-zone
134 KBUILD_CFLAGS += -mcmodel=kernel
135endif
136
137ifdef CONFIG_X86_X32
138 x32_ld_ok := $(call try-run,\
139 /bin/echo -e '1: .quad 1b' | \
140 $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
132 $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \
133 $(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n)
141 $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMP.o" && \
142 $(LD) -m elf32_x86_64 "$$TMP.o" -o "$$TMP",y,n)
134 ifeq ($(x32_ld_ok),y)
135 CONFIG_X86_X32_ABI := y
136 KBUILD_AFLAGS += -DCONFIG_X86_X32_ABI
137 KBUILD_CFLAGS += -DCONFIG_X86_X32_ABI
138 else
139 $(warning CONFIG_X86_X32 enabled but no binutils support)
140 endif
141endif

--- 22 unchanged lines hidden (view full) ---

164 endif
165endif
166
167ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
168 # This compiler flag is not supported by Clang:
169 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
170endif
171
143 ifeq ($(x32_ld_ok),y)
144 CONFIG_X86_X32_ABI := y
145 KBUILD_AFLAGS += -DCONFIG_X86_X32_ABI
146 KBUILD_CFLAGS += -DCONFIG_X86_X32_ABI
147 else
148 $(warning CONFIG_X86_X32 enabled but no binutils support)
149 endif
150endif

--- 22 unchanged lines hidden (view full) ---

173 endif
174endif
175
176ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
177 # This compiler flag is not supported by Clang:
178 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
179endif
180
172ifdef CONFIG_LTO_CLANG
173KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
174 -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
175endif
176
177# Workaround for a gcc prelease that unfortunately was shipped in a suse release
178KBUILD_CFLAGS += -Wno-sign-compare
179#
180KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
181
182# Avoid indirect branches in kernel to deal with Spectre
183ifdef CONFIG_RETPOLINE
184 KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
185 # Additionally, avoid generating expensive indirect jumps which
186 # are subject to retpolines for small number of switch cases.
187 # clang turns off jump table generation by default when under
188 # retpoline builds, however, gcc does not for x86. This has
189 # only been fixed starting from gcc stable version 8.4.0 and
190 # onwards, but not for older ones. See gcc bug #86952.
191 ifndef CONFIG_CC_IS_CLANG
192 KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables)
193 endif
194endif
195
181# Workaround for a gcc prelease that unfortunately was shipped in a suse release
182KBUILD_CFLAGS += -Wno-sign-compare
183#
184KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
185
186# Avoid indirect branches in kernel to deal with Spectre
187ifdef CONFIG_RETPOLINE
188 KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
189 # Additionally, avoid generating expensive indirect jumps which
190 # are subject to retpolines for small number of switch cases.
191 # clang turns off jump table generation by default when under
192 # retpoline builds, however, gcc does not for x86. This has
193 # only been fixed starting from gcc stable version 8.4.0 and
194 # onwards, but not for older ones. See gcc bug #86952.
195 ifndef CONFIG_CC_IS_CLANG
196 KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables)
197 endif
198endif
199
196KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
200KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
197
201
202ifdef CONFIG_LTO_CLANG
203KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
204 -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
205endif
206
198ifdef CONFIG_X86_NEED_RELOCS
199LDFLAGS_vmlinux := --emit-relocs --discard-none
200else
201LDFLAGS_vmlinux :=
202endif
203
204#
205# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to

--- 19 unchanged lines hidden (view full) ---

225
226head-y := arch/x86/kernel/head_$(BITS).o
227head-y += arch/x86/kernel/head$(BITS).o
228head-y += arch/x86/kernel/ebda.o
229head-y += arch/x86/kernel/platform-quirks.o
230
231libs-y += arch/x86/lib/
232
207ifdef CONFIG_X86_NEED_RELOCS
208LDFLAGS_vmlinux := --emit-relocs --discard-none
209else
210LDFLAGS_vmlinux :=
211endif
212
213#
214# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to

--- 19 unchanged lines hidden (view full) ---

234
235head-y := arch/x86/kernel/head_$(BITS).o
236head-y += arch/x86/kernel/head$(BITS).o
237head-y += arch/x86/kernel/ebda.o
238head-y += arch/x86/kernel/platform-quirks.o
239
240libs-y += arch/x86/lib/
241
233# See arch/x86/Kbuild for content of core part of the kernel
234core-y += arch/x86/
235
236# drivers-y are linked after core-y
237drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/
238drivers-$(CONFIG_PCI) += arch/x86/pci/
239
240# suspend and hibernation support
241drivers-$(CONFIG_PM) += arch/x86/power/
242
243drivers-$(CONFIG_FB) += arch/x86/video/

--- 73 unchanged lines hidden ---
242# drivers-y are linked after core-y
243drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/
244drivers-$(CONFIG_PCI) += arch/x86/pci/
245
246# suspend and hibernation support
247drivers-$(CONFIG_PM) += arch/x86/power/
248
249drivers-$(CONFIG_FB) += arch/x86/video/

--- 73 unchanged lines hidden ---