Commit ced119b6 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 8f645b42 08155126
...@@ -31,8 +31,8 @@ REALMODE_CFLAGS := -m16 -g -Os -DDISABLE_BRANCH_PROFILING \ ...@@ -31,8 +31,8 @@ REALMODE_CFLAGS := -m16 -g -Os -DDISABLE_BRANCH_PROFILING \
REALMODE_CFLAGS += -ffreestanding REALMODE_CFLAGS += -ffreestanding
REALMODE_CFLAGS += -fno-stack-protector REALMODE_CFLAGS += -fno-stack-protector
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member) REALMODE_CFLAGS += -Wno-address-of-packed-member
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4)) REALMODE_CFLAGS += $(cc_stack_align4)
REALMODE_CFLAGS += $(CLANG_FLAGS) REALMODE_CFLAGS += $(CLANG_FLAGS)
export REALMODE_CFLAGS export REALMODE_CFLAGS
...@@ -48,8 +48,7 @@ export BITS ...@@ -48,8 +48,7 @@ export BITS
# #
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
# #
KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
# Intel CET isn't enabled in the kernel # Intel CET isn't enabled in the kernel
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
...@@ -59,9 +58,8 @@ ifeq ($(CONFIG_X86_32),y) ...@@ -59,9 +58,8 @@ ifeq ($(CONFIG_X86_32),y)
UTS_MACHINE := i386 UTS_MACHINE := i386
CHECKFLAGS += -D__i386__ CHECKFLAGS += -D__i386__
biarch := $(call cc-option,-m32) KBUILD_AFLAGS += -m32
KBUILD_AFLAGS += $(biarch) KBUILD_CFLAGS += -m32
KBUILD_CFLAGS += $(biarch)
KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
...@@ -72,7 +70,7 @@ ifeq ($(CONFIG_X86_32),y) ...@@ -72,7 +70,7 @@ ifeq ($(CONFIG_X86_32),y)
# Align the stack to the register width instead of using the default # 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 of 16 bytes. This reduces stack usage and the number of
# alignment instructions. # alignment instructions.
KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4)) KBUILD_CFLAGS += $(cc_stack_align4)
# CPU-specific tuning. Anything which can be shared with UML should go here. # CPU-specific tuning. Anything which can be shared with UML should go here.
include arch/x86/Makefile_32.cpu include arch/x86/Makefile_32.cpu
...@@ -93,7 +91,6 @@ else ...@@ -93,7 +91,6 @@ else
UTS_MACHINE := x86_64 UTS_MACHINE := x86_64
CHECKFLAGS += -D__x86_64__ CHECKFLAGS += -D__x86_64__
biarch := -m64
KBUILD_AFLAGS += -m64 KBUILD_AFLAGS += -m64
KBUILD_CFLAGS += -m64 KBUILD_CFLAGS += -m64
...@@ -104,7 +101,7 @@ else ...@@ -104,7 +101,7 @@ else
KBUILD_CFLAGS += $(call cc-option,-falign-loops=1) KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
# Don't autogenerate traditional x87 instructions # Don't autogenerate traditional x87 instructions
KBUILD_CFLAGS += $(call cc-option,-mno-80387) KBUILD_CFLAGS += -mno-80387
KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387) KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
# By default gcc and clang use a stack alignment of 16 bytes for x86. # By default gcc and clang use a stack alignment of 16 bytes for x86.
...@@ -114,20 +111,17 @@ else ...@@ -114,20 +111,17 @@ else
# default alignment which keep the stack *mis*aligned. # default alignment which keep the stack *mis*aligned.
# Furthermore an alignment to the register width reduces stack usage # Furthermore an alignment to the register width reduces stack usage
# and the number of alignment instructions. # and the number of alignment instructions.
KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align8)) KBUILD_CFLAGS += $(cc_stack_align8)
# Use -mskip-rax-setup if supported. # Use -mskip-rax-setup if supported.
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup) KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
# FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu) # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8) cflags-$(CONFIG_MK8) += -march=k8
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona) cflags-$(CONFIG_MPSC) += -march=nocona
cflags-$(CONFIG_MCORE2) += -march=core2
cflags-$(CONFIG_MCORE2) += \ cflags-$(CONFIG_MATOM) += -march=atom
$(call cc-option,-march=core2,$(call cc-option,-mtune=generic)) cflags-$(CONFIG_GENERIC_CPU) += -mtune=generic
cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
KBUILD_CFLAGS += $(cflags-y) KBUILD_CFLAGS += $(cflags-y)
KBUILD_CFLAGS += -mno-red-zone KBUILD_CFLAGS += -mno-red-zone
...@@ -158,18 +152,6 @@ export CONFIG_X86_X32_ABI ...@@ -158,18 +152,6 @@ export CONFIG_X86_X32_ABI
ifdef CONFIG_FUNCTION_GRAPH_TRACER ifdef CONFIG_FUNCTION_GRAPH_TRACER
ifndef CONFIG_HAVE_FENTRY ifndef CONFIG_HAVE_FENTRY
ACCUMULATE_OUTGOING_ARGS := 1 ACCUMULATE_OUTGOING_ARGS := 1
else
ifeq ($(call cc-option-yn, -mfentry), n)
ACCUMULATE_OUTGOING_ARGS := 1
# GCC ignores '-maccumulate-outgoing-args' when used with '-Os'.
# If '-Os' is enabled, disable it and print a warning.
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
undefine CONFIG_CC_OPTIMIZE_FOR_SIZE
$(warning Disabling CONFIG_CC_OPTIMIZE_FOR_SIZE. Your compiler does not have -mfentry so you cannot optimize for size with CONFIG_FUNCTION_GRAPH_TRACER.)
endif
endif
endif endif
endif endif
...@@ -193,7 +175,7 @@ ifdef CONFIG_RETPOLINE ...@@ -193,7 +175,7 @@ ifdef CONFIG_RETPOLINE
# only been fixed starting from gcc stable version 8.4.0 and # only been fixed starting from gcc stable version 8.4.0 and
# onwards, but not for older ones. See gcc bug #86952. # onwards, but not for older ones. See gcc bug #86952.
ifndef CONFIG_CC_IS_CLANG ifndef CONFIG_CC_IS_CLANG
KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables) KBUILD_CFLAGS += -fno-jump-tables
endif endif
endif endif
...@@ -275,9 +257,10 @@ endif ...@@ -275,9 +257,10 @@ endif
$(BOOT_TARGETS): vmlinux $(BOOT_TARGETS): vmlinux
$(Q)$(MAKE) $(build)=$(boot) $@ $(Q)$(MAKE) $(build)=$(boot) $@
PHONY += install bzlilo PHONY += install
install bzlilo: install:
$(Q)$(MAKE) $(build)=$(boot) $@ $(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \
$(KBUILD_IMAGE) System.map "$(INSTALL_PATH)"
PHONY += vdso_install PHONY += vdso_install
vdso_install: vdso_install:
......
...@@ -133,7 +133,7 @@ quiet_cmd_genimage = GENIMAGE $3 ...@@ -133,7 +133,7 @@ quiet_cmd_genimage = GENIMAGE $3
cmd_genimage = $(BASH) $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \ cmd_genimage = $(BASH) $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \
$(obj)/mtools.conf '$(FDARGS)' $(FDINITRD) $(obj)/mtools.conf '$(FDARGS)' $(FDINITRD)
PHONY += bzdisk fdimage fdimage144 fdimage288 hdimage isoimage install PHONY += bzdisk fdimage fdimage144 fdimage288 hdimage isoimage
# This requires write access to /dev/fd0 # This requires write access to /dev/fd0
# All images require syslinux to be installed; hdimage also requires # All images require syslinux to be installed; hdimage also requires
...@@ -156,8 +156,3 @@ hdimage: $(imgdeps) ...@@ -156,8 +156,3 @@ hdimage: $(imgdeps)
isoimage: $(imgdeps) isoimage: $(imgdeps)
$(call cmd,genimage,isoimage,$(obj)/image.iso) $(call cmd,genimage,isoimage,$(obj)/image.iso)
@$(kecho) 'Kernel: $(obj)/image.iso is ready' @$(kecho) 'Kernel: $(obj)/image.iso is ready'
install:
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh \
$(KERNELRELEASE) $(obj)/bzImage \
System.map "$(INSTALL_PATH)"
...@@ -26,6 +26,9 @@ static struct relocs relocs32; ...@@ -26,6 +26,9 @@ static struct relocs relocs32;
#if ELF_BITS == 64 #if ELF_BITS == 64
static struct relocs relocs32neg; static struct relocs relocs32neg;
static struct relocs relocs64; static struct relocs relocs64;
#define FMT PRIu64
#else
#define FMT PRIu32
#endif #endif
struct section { struct section {
...@@ -389,7 +392,7 @@ static void read_ehdr(FILE *fp) ...@@ -389,7 +392,7 @@ static void read_ehdr(FILE *fp)
Elf_Shdr shdr; Elf_Shdr shdr;
if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0)
die("Seek to %d failed: %s\n", ehdr.e_shoff, strerror(errno)); die("Seek to %" FMT " failed: %s\n", ehdr.e_shoff, strerror(errno));
if (fread(&shdr, sizeof(shdr), 1, fp) != 1) if (fread(&shdr, sizeof(shdr), 1, fp) != 1)
die("Cannot read initial ELF section header: %s\n", strerror(errno)); die("Cannot read initial ELF section header: %s\n", strerror(errno));
...@@ -412,17 +415,17 @@ static void read_shdrs(FILE *fp) ...@@ -412,17 +415,17 @@ static void read_shdrs(FILE *fp)
secs = calloc(shnum, sizeof(struct section)); secs = calloc(shnum, sizeof(struct section));
if (!secs) { if (!secs) {
die("Unable to allocate %d section headers\n", die("Unable to allocate %ld section headers\n",
shnum); shnum);
} }
if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) { if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
die("Seek to %d failed: %s\n", die("Seek to %" FMT " failed: %s\n",
ehdr.e_shoff, strerror(errno)); ehdr.e_shoff, strerror(errno));
} }
for (i = 0; i < shnum; i++) { for (i = 0; i < shnum; i++) {
struct section *sec = &secs[i]; struct section *sec = &secs[i];
if (fread(&shdr, sizeof(shdr), 1, fp) != 1) if (fread(&shdr, sizeof(shdr), 1, fp) != 1)
die("Cannot read ELF section headers %d/%d: %s\n", die("Cannot read ELF section headers %d/%ld: %s\n",
i, shnum, strerror(errno)); i, shnum, strerror(errno));
sec->shdr.sh_name = elf_word_to_cpu(shdr.sh_name); sec->shdr.sh_name = elf_word_to_cpu(shdr.sh_name);
sec->shdr.sh_type = elf_word_to_cpu(shdr.sh_type); sec->shdr.sh_type = elf_word_to_cpu(shdr.sh_type);
...@@ -450,12 +453,12 @@ static void read_strtabs(FILE *fp) ...@@ -450,12 +453,12 @@ static void read_strtabs(FILE *fp)
} }
sec->strtab = malloc(sec->shdr.sh_size); sec->strtab = malloc(sec->shdr.sh_size);
if (!sec->strtab) { if (!sec->strtab) {
die("malloc of %d bytes for strtab failed\n", die("malloc of %" FMT " bytes for strtab failed\n",
sec->shdr.sh_size); sec->shdr.sh_size);
} }
if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) { if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
die("Seek to %d failed: %s\n", die("Seek to %" FMT " failed: %s\n",
sec->shdr.sh_offset, strerror(errno)); sec->shdr.sh_offset, strerror(errno));
} }
if (fread(sec->strtab, 1, sec->shdr.sh_size, fp) if (fread(sec->strtab, 1, sec->shdr.sh_size, fp)
!= sec->shdr.sh_size) { != sec->shdr.sh_size) {
...@@ -475,12 +478,12 @@ static void read_symtabs(FILE *fp) ...@@ -475,12 +478,12 @@ static void read_symtabs(FILE *fp)
} }
sec->symtab = malloc(sec->shdr.sh_size); sec->symtab = malloc(sec->shdr.sh_size);
if (!sec->symtab) { if (!sec->symtab) {
die("malloc of %d bytes for symtab failed\n", die("malloc of %" FMT " bytes for symtab failed\n",
sec->shdr.sh_size); sec->shdr.sh_size);
} }
if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) { if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
die("Seek to %d failed: %s\n", die("Seek to %" FMT " failed: %s\n",
sec->shdr.sh_offset, strerror(errno)); sec->shdr.sh_offset, strerror(errno));
} }
if (fread(sec->symtab, 1, sec->shdr.sh_size, fp) if (fread(sec->symtab, 1, sec->shdr.sh_size, fp)
!= sec->shdr.sh_size) { != sec->shdr.sh_size) {
...@@ -508,12 +511,12 @@ static void read_relocs(FILE *fp) ...@@ -508,12 +511,12 @@ static void read_relocs(FILE *fp)
} }
sec->reltab = malloc(sec->shdr.sh_size); sec->reltab = malloc(sec->shdr.sh_size);
if (!sec->reltab) { if (!sec->reltab) {
die("malloc of %d bytes for relocs failed\n", die("malloc of %" FMT " bytes for relocs failed\n",
sec->shdr.sh_size); sec->shdr.sh_size);
} }
if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) { if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
die("Seek to %d failed: %s\n", die("Seek to %" FMT " failed: %s\n",
sec->shdr.sh_offset, strerror(errno)); sec->shdr.sh_offset, strerror(errno));
} }
if (fread(sec->reltab, 1, sec->shdr.sh_size, fp) if (fread(sec->reltab, 1, sec->shdr.sh_size, fp)
!= sec->shdr.sh_size) { != sec->shdr.sh_size) {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <regex.h> #include <regex.h>
#include <tools/le_byteshift.h> #include <tools/le_byteshift.h>
__attribute__((__format__(printf, 1, 2)))
void die(char *fmt, ...) __attribute__((noreturn)); void die(char *fmt, ...) __attribute__((noreturn));
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment