Skip to content

Commit ced119b

Browse files
committed
Merge tag 'x86_build_for_v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 build updates from Borislav Petkov: - Remove cc-option checks which are old and already supported by the minimal compiler version the kernel uses and thus avoid the need to invoke the compiler unnecessarily. - Cleanups * tag 'x86_build_for_v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/build: Move the install rule to arch/x86/Makefile x86/build: Remove the left-over bzlilo target x86/tools/relocs: Mark die() with the printf function attr format x86/build: Remove stale cc-option checks
2 parents 8f645b4 + 0815512 commit ced119b

File tree

4 files changed

+40
-58
lines changed

4 files changed

+40
-58
lines changed

arch/x86/Makefile

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ REALMODE_CFLAGS := -m16 -g -Os -DDISABLE_BRANCH_PROFILING \
3131

3232
REALMODE_CFLAGS += -ffreestanding
3333
REALMODE_CFLAGS += -fno-stack-protector
34-
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member)
35-
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
34+
REALMODE_CFLAGS += -Wno-address-of-packed-member
35+
REALMODE_CFLAGS += $(cc_stack_align4)
3636
REALMODE_CFLAGS += $(CLANG_FLAGS)
3737
export REALMODE_CFLAGS
3838

@@ -48,8 +48,7 @@ export BITS
4848
#
4949
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
5050
#
51-
KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
52-
KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
51+
KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
5352

5453
# Intel CET isn't enabled in the kernel
5554
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
@@ -59,9 +58,8 @@ ifeq ($(CONFIG_X86_32),y)
5958
UTS_MACHINE := i386
6059
CHECKFLAGS += -D__i386__
6160

62-
biarch := $(call cc-option,-m32)
63-
KBUILD_AFLAGS += $(biarch)
64-
KBUILD_CFLAGS += $(biarch)
61+
KBUILD_AFLAGS += -m32
62+
KBUILD_CFLAGS += -m32
6563

6664
KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
6765

@@ -72,7 +70,7 @@ ifeq ($(CONFIG_X86_32),y)
7270
# Align the stack to the register width instead of using the default
7371
# alignment of 16 bytes. This reduces stack usage and the number of
7472
# alignment instructions.
75-
KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4))
73+
KBUILD_CFLAGS += $(cc_stack_align4)
7674

7775
# CPU-specific tuning. Anything which can be shared with UML should go here.
7876
include arch/x86/Makefile_32.cpu
@@ -93,7 +91,6 @@ else
9391
UTS_MACHINE := x86_64
9492
CHECKFLAGS += -D__x86_64__
9593

96-
biarch := -m64
9794
KBUILD_AFLAGS += -m64
9895
KBUILD_CFLAGS += -m64
9996

@@ -104,7 +101,7 @@ else
104101
KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
105102

106103
# Don't autogenerate traditional x87 instructions
107-
KBUILD_CFLAGS += $(call cc-option,-mno-80387)
104+
KBUILD_CFLAGS += -mno-80387
108105
KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
109106

110107
# By default gcc and clang use a stack alignment of 16 bytes for x86.
@@ -114,20 +111,17 @@ else
114111
# default alignment which keep the stack *mis*aligned.
115112
# Furthermore an alignment to the register width reduces stack usage
116113
# and the number of alignment instructions.
117-
KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align8))
114+
KBUILD_CFLAGS += $(cc_stack_align8)
118115

119116
# Use -mskip-rax-setup if supported.
120117
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
121118

122119
# FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
123-
cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
124-
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
125-
126-
cflags-$(CONFIG_MCORE2) += \
127-
$(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
128-
cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
129-
$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
130-
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
120+
cflags-$(CONFIG_MK8) += -march=k8
121+
cflags-$(CONFIG_MPSC) += -march=nocona
122+
cflags-$(CONFIG_MCORE2) += -march=core2
123+
cflags-$(CONFIG_MATOM) += -march=atom
124+
cflags-$(CONFIG_GENERIC_CPU) += -mtune=generic
131125
KBUILD_CFLAGS += $(cflags-y)
132126

133127
KBUILD_CFLAGS += -mno-red-zone
@@ -158,18 +152,6 @@ export CONFIG_X86_X32_ABI
158152
ifdef CONFIG_FUNCTION_GRAPH_TRACER
159153
ifndef CONFIG_HAVE_FENTRY
160154
ACCUMULATE_OUTGOING_ARGS := 1
161-
else
162-
ifeq ($(call cc-option-yn, -mfentry), n)
163-
ACCUMULATE_OUTGOING_ARGS := 1
164-
165-
# GCC ignores '-maccumulate-outgoing-args' when used with '-Os'.
166-
# If '-Os' is enabled, disable it and print a warning.
167-
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
168-
undefine CONFIG_CC_OPTIMIZE_FOR_SIZE
169-
$(warning Disabling CONFIG_CC_OPTIMIZE_FOR_SIZE. Your compiler does not have -mfentry so you cannot optimize for size with CONFIG_FUNCTION_GRAPH_TRACER.)
170-
endif
171-
172-
endif
173155
endif
174156
endif
175157

@@ -193,7 +175,7 @@ ifdef CONFIG_RETPOLINE
193175
# only been fixed starting from gcc stable version 8.4.0 and
194176
# onwards, but not for older ones. See gcc bug #86952.
195177
ifndef CONFIG_CC_IS_CLANG
196-
KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables)
178+
KBUILD_CFLAGS += -fno-jump-tables
197179
endif
198180
endif
199181

@@ -275,9 +257,10 @@ endif
275257
$(BOOT_TARGETS): vmlinux
276258
$(Q)$(MAKE) $(build)=$(boot) $@
277259

278-
PHONY += install bzlilo
279-
install bzlilo:
280-
$(Q)$(MAKE) $(build)=$(boot) $@
260+
PHONY += install
261+
install:
262+
$(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \
263+
$(KBUILD_IMAGE) System.map "$(INSTALL_PATH)"
281264

282265
PHONY += vdso_install
283266
vdso_install:

arch/x86/boot/Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ quiet_cmd_genimage = GENIMAGE $3
133133
cmd_genimage = $(BASH) $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \
134134
$(obj)/mtools.conf '$(FDARGS)' $(FDINITRD)
135135

136-
PHONY += bzdisk fdimage fdimage144 fdimage288 hdimage isoimage install
136+
PHONY += bzdisk fdimage fdimage144 fdimage288 hdimage isoimage
137137

138138
# This requires write access to /dev/fd0
139139
# All images require syslinux to be installed; hdimage also requires
@@ -156,8 +156,3 @@ hdimage: $(imgdeps)
156156
isoimage: $(imgdeps)
157157
$(call cmd,genimage,isoimage,$(obj)/image.iso)
158158
@$(kecho) 'Kernel: $(obj)/image.iso is ready'
159-
160-
install:
161-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh \
162-
$(KERNELRELEASE) $(obj)/bzImage \
163-
System.map "$(INSTALL_PATH)"

arch/x86/tools/relocs.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ static struct relocs relocs32;
2626
#if ELF_BITS == 64
2727
static struct relocs relocs32neg;
2828
static struct relocs relocs64;
29+
#define FMT PRIu64
30+
#else
31+
#define FMT PRIu32
2932
#endif
3033

3134
struct section {
@@ -389,7 +392,7 @@ static void read_ehdr(FILE *fp)
389392
Elf_Shdr shdr;
390393

391394
if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0)
392-
die("Seek to %d failed: %s\n", ehdr.e_shoff, strerror(errno));
395+
die("Seek to %" FMT " failed: %s\n", ehdr.e_shoff, strerror(errno));
393396

394397
if (fread(&shdr, sizeof(shdr), 1, fp) != 1)
395398
die("Cannot read initial ELF section header: %s\n", strerror(errno));
@@ -412,17 +415,17 @@ static void read_shdrs(FILE *fp)
412415

413416
secs = calloc(shnum, sizeof(struct section));
414417
if (!secs) {
415-
die("Unable to allocate %d section headers\n",
418+
die("Unable to allocate %ld section headers\n",
416419
shnum);
417420
}
418421
if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
419-
die("Seek to %d failed: %s\n",
420-
ehdr.e_shoff, strerror(errno));
422+
die("Seek to %" FMT " failed: %s\n",
423+
ehdr.e_shoff, strerror(errno));
421424
}
422425
for (i = 0; i < shnum; i++) {
423426
struct section *sec = &secs[i];
424427
if (fread(&shdr, sizeof(shdr), 1, fp) != 1)
425-
die("Cannot read ELF section headers %d/%d: %s\n",
428+
die("Cannot read ELF section headers %d/%ld: %s\n",
426429
i, shnum, strerror(errno));
427430
sec->shdr.sh_name = elf_word_to_cpu(shdr.sh_name);
428431
sec->shdr.sh_type = elf_word_to_cpu(shdr.sh_type);
@@ -450,12 +453,12 @@ static void read_strtabs(FILE *fp)
450453
}
451454
sec->strtab = malloc(sec->shdr.sh_size);
452455
if (!sec->strtab) {
453-
die("malloc of %d bytes for strtab failed\n",
454-
sec->shdr.sh_size);
456+
die("malloc of %" FMT " bytes for strtab failed\n",
457+
sec->shdr.sh_size);
455458
}
456459
if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
457-
die("Seek to %d failed: %s\n",
458-
sec->shdr.sh_offset, strerror(errno));
460+
die("Seek to %" FMT " failed: %s\n",
461+
sec->shdr.sh_offset, strerror(errno));
459462
}
460463
if (fread(sec->strtab, 1, sec->shdr.sh_size, fp)
461464
!= sec->shdr.sh_size) {
@@ -475,12 +478,12 @@ static void read_symtabs(FILE *fp)
475478
}
476479
sec->symtab = malloc(sec->shdr.sh_size);
477480
if (!sec->symtab) {
478-
die("malloc of %d bytes for symtab failed\n",
479-
sec->shdr.sh_size);
481+
die("malloc of %" FMT " bytes for symtab failed\n",
482+
sec->shdr.sh_size);
480483
}
481484
if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
482-
die("Seek to %d failed: %s\n",
483-
sec->shdr.sh_offset, strerror(errno));
485+
die("Seek to %" FMT " failed: %s\n",
486+
sec->shdr.sh_offset, strerror(errno));
484487
}
485488
if (fread(sec->symtab, 1, sec->shdr.sh_size, fp)
486489
!= sec->shdr.sh_size) {
@@ -508,12 +511,12 @@ static void read_relocs(FILE *fp)
508511
}
509512
sec->reltab = malloc(sec->shdr.sh_size);
510513
if (!sec->reltab) {
511-
die("malloc of %d bytes for relocs failed\n",
512-
sec->shdr.sh_size);
514+
die("malloc of %" FMT " bytes for relocs failed\n",
515+
sec->shdr.sh_size);
513516
}
514517
if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
515-
die("Seek to %d failed: %s\n",
516-
sec->shdr.sh_offset, strerror(errno));
518+
die("Seek to %" FMT " failed: %s\n",
519+
sec->shdr.sh_offset, strerror(errno));
517520
}
518521
if (fread(sec->reltab, 1, sec->shdr.sh_size, fp)
519522
!= sec->shdr.sh_size) {

arch/x86/tools/relocs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <regex.h>
1818
#include <tools/le_byteshift.h>
1919

20+
__attribute__((__format__(printf, 1, 2)))
2021
void die(char *fmt, ...) __attribute__((noreturn));
2122

2223
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

0 commit comments

Comments
 (0)