Commit 3b24b837 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'kbuild-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:

 - add a shell script to get Clang version

 - improve portability of build scripts

 - drop always-enabled CONFIG_THIN_ARCHIVE and remove unused code

 - rename built-in.o which is now thin archive to built-in.a

 - process clean/build targets one by one to get along with -j option

 - simplify ld-option

 - improve building with CONFIG_TRIM_UNUSED_KSYMS

 - define KBUILD_MODNAME even for objects shared among multiple modules

 - avoid linking multiple instances of same objects from composite
   objects

 - move <linux/compiler_types.h> to c_flags to include it only for C
   files

 - clean-up various Makefiles

* tag 'kbuild-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (29 commits)
  kbuild: get <linux/compiler_types.h> out of <linux/kconfig.h>
  kbuild: clean up link rule of composite modules
  kbuild: clean up archive rule of built-in.a
  kbuild: remove partial section mismatch detection for built-in.a
  net: liquidio: clean up Makefile for simpler composite object handling
  lib: zstd: clean up Makefile for simpler composite object handling
  kbuild: link $(real-obj-y) instead of $(obj-y) into built-in.a
  kbuild: rename real-objs-y/m to real-obj-y/m
  kbuild: move modname and modname-multi close to modname_flags
  kbuild: simplify modname calculation
  kbuild: fix modname for composite modules
  kbuild: define KBUILD_MODNAME even if multiple modules share objects
  kbuild: remove unnecessary $(subst $(obj)/, , ...) in modname-multi
  kbuild: Use ls(1) instead of stat(1) to obtain file size
  kbuild: link vmlinux only once for CONFIG_TRIM_UNUSED_KSYMS
  kbuild: move include/config/ksym/* to include/ksym/*
  kbuild: move CONFIG_TRIM_UNUSED_KSYMS code unneeded for external module
  kbuild: restore autoksyms.h touch to the top Makefile
  kbuild: move 'scripts' target below
  kbuild: remove wrong 'touch' in adjust_autoksyms.sh
  ...
parents 0734e00e a95b37e2
...@@ -87,6 +87,7 @@ modules.builtin ...@@ -87,6 +87,7 @@ modules.builtin
# #
include/config include/config
include/generated include/generated
include/ksym
arch/*/include/generated arch/*/include/generated
# stgit generated dirs # stgit generated dirs
......
...@@ -50,10 +50,6 @@ LDFLAGS_MODULE ...@@ -50,10 +50,6 @@ LDFLAGS_MODULE
-------------------------------------------------- --------------------------------------------------
Additional options used for $(LD) when linking modules. Additional options used for $(LD) when linking modules.
LDFLAGS_vmlinux
--------------------------------------------------
Additional options passed to final link of vmlinux.
KBUILD_VERBOSE KBUILD_VERBOSE
-------------------------------------------------- --------------------------------------------------
Set the kbuild verbosity. Can be assigned same values as "V=...". Set the kbuild verbosity. Can be assigned same values as "V=...".
......
...@@ -153,12 +153,18 @@ more details, with real examples. ...@@ -153,12 +153,18 @@ more details, with real examples.
configuration. configuration.
Kbuild compiles all the $(obj-y) files. It then calls Kbuild compiles all the $(obj-y) files. It then calls
"$(LD) -r" to merge these files into one built-in.o file. "$(AR) rcSTP" to merge these files into one built-in.a file.
built-in.o is later linked into vmlinux by the parent Makefile. This is a thin archive without a symbol table, which makes it
unsuitable as a linker input.
The scripts/link-vmlinux.sh script later makes an aggregate
built-in.a with "${AR} rcsTP", which creates the thin archive
with a symbol table and an index, making it a valid input for
the final vmlinux link passes.
The order of files in $(obj-y) is significant. Duplicates in The order of files in $(obj-y) is significant. Duplicates in
the lists are allowed: the first instance will be linked into the lists are allowed: the first instance will be linked into
built-in.o and succeeding instances will be ignored. built-in.a and succeeding instances will be ignored.
Link order is significant, because certain functions Link order is significant, because certain functions
(module_init() / __initcall) will be called during boot in the (module_init() / __initcall) will be called during boot in the
...@@ -222,7 +228,7 @@ more details, with real examples. ...@@ -222,7 +228,7 @@ more details, with real examples.
Note: Of course, when you are building objects into the kernel, Note: Of course, when you are building objects into the kernel,
the syntax above will also work. So, if you have CONFIG_EXT2_FS=y, the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,
kbuild will build an ext2.o file for you out of the individual kbuild will build an ext2.o file for you out of the individual
parts and then link this into built-in.o, as you would expect. parts and then link this into built-in.a, as you would expect.
--- 3.4 Objects which export symbols --- 3.4 Objects which export symbols
...@@ -232,7 +238,7 @@ more details, with real examples. ...@@ -232,7 +238,7 @@ more details, with real examples.
--- 3.5 Library file goals - lib-y --- 3.5 Library file goals - lib-y
Objects listed with obj-* are used for modules, or Objects listed with obj-* are used for modules, or
combined in a built-in.o for that specific directory. combined in a built-in.a for that specific directory.
There is also the possibility to list objects that will There is also the possibility to list objects that will
be included in a library, lib.a. be included in a library, lib.a.
All objects listed with lib-y are combined in a single All objects listed with lib-y are combined in a single
...@@ -244,7 +250,7 @@ more details, with real examples. ...@@ -244,7 +250,7 @@ more details, with real examples.
Note that the same kbuild makefile may list files to be built-in Note that the same kbuild makefile may list files to be built-in
and to be part of a library. Therefore the same directory and to be part of a library. Therefore the same directory
may contain both a built-in.o and a lib.a file. may contain both a built-in.a and a lib.a file.
Example: Example:
#arch/x86/lib/Makefile #arch/x86/lib/Makefile
...@@ -831,12 +837,6 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -831,12 +837,6 @@ When kbuild executes, the following steps are followed (roughly):
Note: ldflags-y can be used to further customise Note: ldflags-y can be used to further customise
the flags used. See chapter 3.7. the flags used. See chapter 3.7.
LDFLAGS_MODULE Options for $(LD) when linking modules
LDFLAGS_MODULE is used to set specific flags for $(LD) when
linking the .ko files used for modules.
Default is "-r", for relocatable output.
LDFLAGS_vmlinux Options for $(LD) when linking vmlinux LDFLAGS_vmlinux Options for $(LD) when linking vmlinux
LDFLAGS_vmlinux is used to specify additional flags to pass to LDFLAGS_vmlinux is used to specify additional flags to pass to
...@@ -986,7 +986,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -986,7 +986,7 @@ When kbuild executes, the following steps are followed (roughly):
$(head-y) lists objects to be linked first in vmlinux. $(head-y) lists objects to be linked first in vmlinux.
$(libs-y) lists directories where a lib.a archive can be located. $(libs-y) lists directories where a lib.a archive can be located.
The rest list directories where a built-in.o object file can be The rest list directories where a built-in.a object file can be
located. located.
$(init-y) objects will be located after $(head-y). $(init-y) objects will be located after $(head-y).
...@@ -1071,7 +1071,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1071,7 +1071,7 @@ When kbuild executes, the following steps are followed (roughly):
extra-y := head.o init_task.o extra-y := head.o init_task.o
In this example, extra-y is used to list object files that In this example, extra-y is used to list object files that
shall be built, but shall not be linked as part of built-in.o. shall be built, but shall not be linked as part of built-in.a.
--- 6.7 Commands useful for building a boot image --- 6.7 Commands useful for building a boot image
......
...@@ -78,7 +78,7 @@ Binutils ...@@ -78,7 +78,7 @@ Binutils
-------- --------
The build system has, as of 4.13, switched to using thin archives (`ar T`) The build system has, as of 4.13, switched to using thin archives (`ar T`)
rather than incremental linking (`ld -r`) for built-in.o intermediate steps. rather than incremental linking (`ld -r`) for built-in.a intermediate steps.
This requires binutils 2.20 or newer. This requires binutils 2.20 or newer.
Flex Flex
......
...@@ -35,7 +35,7 @@ unexport GREP_OPTIONS ...@@ -35,7 +35,7 @@ unexport GREP_OPTIONS
# Most importantly: sub-Makefiles should only ever modify files in # Most importantly: sub-Makefiles should only ever modify files in
# their own directory. If in some directory we have a dependency on # their own directory. If in some directory we have a dependency on
# a file in another dir (which doesn't happen often, but it's often # a file in another dir (which doesn't happen often, but it's often
# unavoidable when linking the built-in.o targets which finally # unavoidable when linking the built-in.a targets which finally
# turn into vmlinux), we will call a sub make in that other dir, and # turn into vmlinux), we will call a sub make in that other dir, and
# after that we are sure that everything which is in that other dir # after that we are sure that everything which is in that other dir
# is now up to date. # is now up to date.
...@@ -220,7 +220,8 @@ export srctree objtree VPATH ...@@ -220,7 +220,8 @@ export srctree objtree VPATH
version_h := include/generated/uapi/linux/version.h version_h := include/generated/uapi/linux/version.h
old_version_h := include/linux/version.h old_version_h := include/linux/version.h
no-dot-config-targets := clean mrproper distclean \ clean-targets := %clean mrproper cleandocs
no-dot-config-targets := $(clean-targets) \
cscope gtags TAGS tags help% %docs check% coccicheck \ cscope gtags TAGS tags help% %docs check% coccicheck \
$(version_h) headers_% archheaders archscripts \ $(version_h) headers_% archheaders archscripts \
kernelversion %src-pkg kernelversion %src-pkg
...@@ -243,6 +244,14 @@ ifeq ($(KBUILD_EXTMOD),) ...@@ -243,6 +244,14 @@ ifeq ($(KBUILD_EXTMOD),)
endif endif
endif endif
endif endif
# For "make -j clean all", "make -j mrproper defconfig all", etc.
ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
mixed-targets := 1
endif
endif
# install and modules_install need also be processed one by one # install and modules_install need also be processed one by one
ifneq ($(filter install,$(MAKECMDGOALS)),) ifneq ($(filter install,$(MAKECMDGOALS)),)
ifneq ($(filter modules_install,$(MAKECMDGOALS)),) ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
...@@ -418,6 +427,7 @@ KBUILD_CFLAGS_KERNEL := ...@@ -418,6 +427,7 @@ KBUILD_CFLAGS_KERNEL :=
KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_AFLAGS_MODULE := -DMODULE
KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
LDFLAGS :=
GCC_PLUGINS_CFLAGS := GCC_PLUGINS_CFLAGS :=
export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
...@@ -556,14 +566,6 @@ endif ...@@ -556,14 +566,6 @@ endif
export KBUILD_MODULES KBUILD_BUILTIN export KBUILD_MODULES KBUILD_BUILTIN
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
# Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice
# in parallel
PHONY += scripts
scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \
asm-generic gcc-plugins
$(Q)$(MAKE) $(build)=$(@)
# Objects we will link into vmlinux / subdirs we need to visit # Objects we will link into vmlinux / subdirs we need to visit
init-y := init/ init-y := init/
drivers-y := drivers/ sound/ firmware/ drivers-y := drivers/ sound/ firmware/
...@@ -611,13 +613,6 @@ else ...@@ -611,13 +613,6 @@ else
include/config/auto.conf: ; include/config/auto.conf: ;
endif # $(dot-config) endif # $(dot-config)
# For the kernel to actually contain only the needed exported symbols,
# we have to build modules as well to determine what those symbols are.
# (this can be evaluated only once include/config/auto.conf has been included)
ifdef CONFIG_TRIM_UNUSED_KSYMS
KBUILD_MODULES := 1
endif
# The all: target is the default when no target is given on the # The all: target is the default when no target is given on the
# command line. # command line.
# This allow a user to issue only 'make' to build a kernel including modules # This allow a user to issue only 'make' to build a kernel including modules
...@@ -984,13 +979,13 @@ vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ ...@@ -984,13 +979,13 @@ vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \ vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
$(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-)))) $(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-))))
init-y := $(patsubst %/, %/built-in.o, $(init-y)) init-y := $(patsubst %/, %/built-in.a, $(init-y))
core-y := $(patsubst %/, %/built-in.o, $(core-y)) core-y := $(patsubst %/, %/built-in.a, $(core-y))
drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y))
net-y := $(patsubst %/, %/built-in.o, $(net-y)) net-y := $(patsubst %/, %/built-in.a, $(net-y))
libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
libs-y2 := $(filter-out %.a, $(patsubst %/, %/built-in.o, $(libs-y))) libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))
virt-y := $(patsubst %/, %/built-in.o, $(virt-y)) virt-y := $(patsubst %/, %/built-in.a, $(virt-y))
# Externally visible symbols (used by link-vmlinux.sh) # Externally visible symbols (used by link-vmlinux.sh)
export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
...@@ -1003,25 +998,26 @@ export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Doc ...@@ -1003,25 +998,26 @@ export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Doc
vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS)
# Include targets which we want to execute sequentially if the rest of the # Recurse until adjust_autoksyms.sh is satisfied
# kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be PHONY += autoksyms_recursive
# evaluated more than once. autoksyms_recursive: $(vmlinux-deps)
PHONY += vmlinux_prereq
vmlinux_prereq: $(vmlinux-deps) FORCE
ifdef CONFIG_HEADERS_CHECK
$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
endif
ifdef CONFIG_GDB_SCRIPTS
$(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
endif
ifdef CONFIG_TRIM_UNUSED_KSYMS ifdef CONFIG_TRIM_UNUSED_KSYMS
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
"$(MAKE) -f $(srctree)/Makefile vmlinux" "$(MAKE) -f $(srctree)/Makefile vmlinux"
endif endif
# standalone target for easier testing # For the kernel to actually contain only the needed exported symbols,
include/generated/autoksyms.h: FORCE # we have to build modules as well to determine what those symbols are.
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh true # (this can be evaluated only once include/config/auto.conf has been included)
ifdef CONFIG_TRIM_UNUSED_KSYMS
KBUILD_MODULES := 1
endif
autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
$(autoksyms_h):
$(Q)mkdir -p $(dir $@)
$(Q)touch $@
ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
...@@ -1030,7 +1026,13 @@ cmd_link-vmlinux = \ ...@@ -1030,7 +1026,13 @@ cmd_link-vmlinux = \
$(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
ifdef CONFIG_HEADERS_CHECK
$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
endif
ifdef CONFIG_GDB_SCRIPTS
$(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
endif
+$(call if_changed,link-vmlinux) +$(call if_changed,link-vmlinux)
# Build samples along the rest of the kernel # Build samples along the rest of the kernel
...@@ -1060,6 +1062,13 @@ endef ...@@ -1060,6 +1062,13 @@ endef
include/config/kernel.release: include/config/auto.conf FORCE include/config/kernel.release: include/config/auto.conf FORCE
$(call filechk,kernel.release) $(call filechk,kernel.release)
# Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice
# in parallel
PHONY += scripts
scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \
asm-generic gcc-plugins $(autoksyms_h)
$(Q)$(MAKE) $(build)=$(@)
# Things we need to do before we recursively start building the kernel # Things we need to do before we recursively start building the kernel
# or the modules are listed in "prepare". # or the modules are listed in "prepare".
...@@ -1088,7 +1097,7 @@ endif ...@@ -1088,7 +1097,7 @@ endif
# that need to depend on updated CONFIG_* values can be checked here. # that need to depend on updated CONFIG_* values can be checked here.
prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic
prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
include/config/auto.conf include/config/auto.conf
$(cmd_crmodverdir) $(cmd_crmodverdir)
...@@ -1327,7 +1336,7 @@ endif # CONFIG_MODULES ...@@ -1327,7 +1336,7 @@ endif # CONFIG_MODULES
# make distclean Remove editor backup files, patch leftover files and the like # make distclean Remove editor backup files, patch leftover files and the like
# Directories & files removed with 'make clean' # Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR) CLEAN_DIRS += $(MODVERDIR) include/ksym
# Directories & files removed with 'make mrproper' # Directories & files removed with 'make mrproper'
MRPROPER_DIRS += include/config usr/include include/generated \ MRPROPER_DIRS += include/config usr/include include/generated \
......
...@@ -596,12 +596,6 @@ config CC_STACKPROTECTOR_AUTO ...@@ -596,12 +596,6 @@ config CC_STACKPROTECTOR_AUTO
endchoice endchoice
config THIN_ARCHIVES
def_bool y
help
Select this if the architecture wants to use thin archives
instead of ld -r to create the built-in.o files.
config LD_DEAD_CODE_DATA_ELIMINATION config LD_DEAD_CODE_DATA_ELIMINATION
bool bool
help help
......
...@@ -45,7 +45,7 @@ data_start=$(($__data_loc - $base_offset)) ...@@ -45,7 +45,7 @@ data_start=$(($__data_loc - $base_offset))
data_end=$(($_edata_loc - $base_offset)) data_end=$(($_edata_loc - $base_offset))
# Make sure data occupies the last part of the file. # Make sure data occupies the last part of the file.
file_end=$(stat -c "%s" "$XIPIMAGE") file_end=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$XIPIMAGE")
if [ "$file_end" != "$data_end" ]; then if [ "$file_end" != "$data_end" ]; then
printf "end of xipImage doesn't match with _edata_loc (%#x vs %#x)\n" \ printf "end of xipImage doesn't match with _edata_loc (%#x vs %#x)\n" \
$(($file_end + $base_offset)) $_edata_loc 1>&2 $(($file_end + $base_offset)) $_edata_loc 1>&2
......
...@@ -355,7 +355,7 @@ vmz="$tmpdir/`basename \"$kernel\"`.$ext" ...@@ -355,7 +355,7 @@ vmz="$tmpdir/`basename \"$kernel\"`.$ext"
# Calculate the vmlinux.strip size # Calculate the vmlinux.strip size
${CROSS}objcopy $objflags "$kernel" "$vmz.$$" ${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
strip_size=$(stat -c %s $vmz.$$) strip_size=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$vmz.$$")
if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then
# recompress the image if we need to # recompress the image if we need to
......
...@@ -165,7 +165,7 @@ systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i ...@@ -165,7 +165,7 @@ systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i
$(call cmd,systbl_chk) $(call cmd,systbl_chk)
ifeq ($(CONFIG_PPC_OF_BOOT_TRAMPOLINE),y) ifeq ($(CONFIG_PPC_OF_BOOT_TRAMPOLINE),y)
$(obj)/built-in.o: prom_init_check $(obj)/built-in.a: prom_init_check
quiet_cmd_prom_init_check = CALL $< quiet_cmd_prom_init_check = CALL $<
cmd_prom_init_check = $(CONFIG_SHELL) $< "$(NM)" "$(obj)/prom_init.o" cmd_prom_init_check = $(CONFIG_SHELL) $< "$(NM)" "$(obj)/prom_init.o"
......
...@@ -2,42 +2,23 @@ ...@@ -2,42 +2,23 @@
# #
# Cavium Liquidio ethernet device driver # Cavium Liquidio ethernet device driver
# #
obj-$(CONFIG_LIQUIDIO) += liquidio.o
liquidio-$(CONFIG_LIQUIDIO) += lio_ethtool.o \ common-objs := lio_ethtool.o \
lio_core.o \ lio_core.o \
request_manager.o \ request_manager.o \
response_manager.o \ response_manager.o \
octeon_device.o \ octeon_device.o \
cn66xx_device.o \ cn66xx_device.o \
cn68xx_device.o \ cn68xx_device.o \
cn23xx_pf_device.o \ cn23xx_pf_device.o \
cn23xx_vf_device.o \ cn23xx_vf_device.o \
octeon_mailbox.o \ octeon_mailbox.o \
octeon_mem_ops.o \ octeon_mem_ops.o \
octeon_droq.o \ octeon_droq.o \
octeon_nic.o octeon_nic.o
liquidio-objs := lio_main.o octeon_console.o lio_vf_rep.o $(liquidio-y) obj-$(CONFIG_LIQUIDIO) += liquidio.o
liquidio-y := lio_main.o octeon_console.o lio_vf_rep.o $(common-objs)
obj-$(CONFIG_LIQUIDIO_VF) += liquidio_vf.o obj-$(CONFIG_LIQUIDIO_VF) += liquidio_vf.o
liquidio_vf-y := lio_vf_main.o $(common-objs)
ifeq ($(CONFIG_LIQUIDIO)$(CONFIG_LIQUIDIO_VF), yy)
liquidio_vf-objs := lio_vf_main.o
else
liquidio_vf-$(CONFIG_LIQUIDIO_VF) += lio_ethtool.o \
lio_core.o \
request_manager.o \
response_manager.o \
octeon_device.o \
cn66xx_device.o \
cn68xx_device.o \
cn23xx_pf_device.o \
cn23xx_vf_device.o \
octeon_mailbox.o \
octeon_mem_ops.o \
octeon_droq.o \
octeon_nic.o
liquidio_vf-objs := lio_vf_main.o $(liquidio_vf-y)
endif
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
obj-y += cio/ block/ char/ crypto/ net/ scsi/ virtio/ obj-y += cio/ block/ char/ crypto/ net/ scsi/ virtio/
drivers-y += drivers/s390/built-in.o drivers-y += drivers/s390/built-in.a
...@@ -70,7 +70,4 @@ ...@@ -70,7 +70,4 @@
*/ */
#define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
/* Make sure we always have all types and struct attributes defined. */
#include <linux/compiler_types.h>
#endif /* __LINUX_KCONFIG_H */ #endif /* __LINUX_KCONFIG_H */
...@@ -324,11 +324,11 @@ config DEBUG_SECTION_MISMATCH ...@@ -324,11 +324,11 @@ config DEBUG_SECTION_MISMATCH
the analysis would not catch the illegal reference. the analysis would not catch the illegal reference.
This option tells gcc to inline less (but it does result in This option tells gcc to inline less (but it does result in
a larger kernel). a larger kernel).
- Run the section mismatch analysis for each module/built-in.o file. - Run the section mismatch analysis for each module/built-in.a file.
When we run the section mismatch analysis on vmlinux.o, we When we run the section mismatch analysis on vmlinux.o, we
lose valuable information about where the mismatch was lose valuable information about where the mismatch was
introduced. introduced.
Running the analysis for each module/built-in.o file Running the analysis for each module/built-in.a file
tells where the mismatch happens much closer to the tells where the mismatch happens much closer to the
source. The drawback is that the same mismatch is source. The drawback is that the same mismatch is
reported at least twice. reported at least twice.
......
...@@ -3,16 +3,7 @@ obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd_decompress.o ...@@ -3,16 +3,7 @@ obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd_decompress.o
ccflags-y += -O3 ccflags-y += -O3
# Object files unique to zstd_compress and zstd_decompress zstd_compress-y := fse_compress.o huf_compress.o compress.o \
zstd_compress-y := fse_compress.o huf_compress.o compress.o entropy_common.o fse_decompress.o zstd_common.o
zstd_decompress-y := huf_decompress.o decompress.o zstd_decompress-y := huf_decompress.o decompress.o \
entropy_common.o fse_decompress.o zstd_common.o
# These object files are shared between the modules.
# Always add them to zstd_compress.
# Unless both zstd_compress and zstd_decompress are built in
# then also add them to zstd_decompress.
zstd_compress-y += entropy_common.o fse_decompress.o zstd_common.o
ifneq ($(CONFIG_ZSTD_COMPRESS)$(CONFIG_ZSTD_DECOMPRESS),yy)
zstd_decompress-y += entropy_common.o fse_decompress.o zstd_common.o
endif
...@@ -237,9 +237,7 @@ cc-ldoption = $(call try-run-cached,\ ...@@ -237,9 +237,7 @@ cc-ldoption = $(call try-run-cached,\
# ld-option # ld-option
# Usage: LDFLAGS += $(call ld-option, -X) # Usage: LDFLAGS += $(call ld-option, -X)
ld-option = $(call try-run-cached,\ ld-option = $(call try-run-cached, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2))
$(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \
$(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
# ar-option # ar-option
# Usage: KBUILD_ARFLAGS := $(call ar-option,D) # Usage: KBUILD_ARFLAGS := $(call ar-option,D)
...@@ -368,7 +366,7 @@ ksym_dep_filter = \ ...@@ -368,7 +366,7 @@ ksym_dep_filter = \
$(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \ $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \
boot*|build*|cpp_its_S|*cpp_lds_S|dtc|host*|vdso*) : ;; \ boot*|build*|cpp_its_S|*cpp_lds_S|dtc|host*|vdso*) : ;; \
*) echo "Don't know how to preprocess $(1)" >&2; false ;; \ *) echo "Don't know how to preprocess $(1)" >&2; false ;; \
esac | tr ";" "\n" | sed -rn 's/^.*=== __KSYM_(.*) ===.*$$/KSYM_\1/p' esac | tr ";" "\n" | sed -n 's/^.*=== __KSYM_\(.*\) ===.*$$/_\1/p'
cmd_and_fixdep = \ cmd_and_fixdep = \
$(echo-cmd) $(cmd_$(1)); \ $(echo-cmd) $(cmd_$(1)); \
......
...@@ -73,11 +73,11 @@ endif ...@@ -73,11 +73,11 @@ endif
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
lib-target := $(obj)/lib.a lib-target := $(obj)/lib.a
obj-y += $(obj)/lib-ksyms.o real-obj-y += $(obj)/lib-ksyms.o
endif endif
ifneq ($(strip $(obj-y) $(need-builtin)),) ifneq ($(strip $(real-obj-y) $(need-builtin)),)
builtin-target := $(obj)/built-in.o builtin-target := $(obj)/built-in.a
endif endif
modorder-target := $(obj)/modules.order modorder-target := $(obj)/modules.order
...@@ -104,7 +104,7 @@ ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) ...@@ -104,7 +104,7 @@ ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ; cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ;
endif endif
# Do section mismatch analysis for each module/built-in.o # Do section mismatch analysis for each module/built-in.a
ifdef CONFIG_DEBUG_SECTION_MISMATCH ifdef CONFIG_DEBUG_SECTION_MISMATCH
cmd_secanalysis = ; scripts/mod/modpost $@ cmd_secanalysis = ; scripts/mod/modpost $@
endif endif
...@@ -119,29 +119,17 @@ modkern_cflags = \ ...@@ -119,29 +119,17 @@ modkern_cflags = \
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
quiet_modtag := $(empty) $(empty) quiet_modtag := $(empty) $(empty)
$(real-objs-m) : part-of-module := y $(real-obj-m) : part-of-module := y
$(real-objs-m:.o=.i) : part-of-module := y $(real-obj-m:.o=.i) : part-of-module := y
$(real-objs-m:.o=.s) : part-of-module := y $(real-obj-m:.o=.s) : part-of-module := y
$(real-objs-m:.o=.lst): part-of-module := y $(real-obj-m:.o=.lst): part-of-module := y
$(real-objs-m) : quiet_modtag := [M] $(real-obj-m) : quiet_modtag := [M]
$(real-objs-m:.o=.i) : quiet_modtag := [M] $(real-obj-m:.o=.i) : quiet_modtag := [M]
$(real-objs-m:.o=.s) : quiet_modtag := [M] $(real-obj-m:.o=.s) : quiet_modtag := [M]
$(real-objs-m:.o=.lst): quiet_modtag := [M] $(real-obj-m:.o=.lst): quiet_modtag := [M]
$(obj-m) : quiet_modtag := [M] $(obj-m) : quiet_modtag := [M]
# Default for not multi-part modules
modname = $(basetarget)
$(multi-objs-m) : modname = $(modname-multi)
$(multi-objs-m:.o=.i) : modname = $(modname-multi)
$(multi-objs-m:.o=.s) : modname = $(modname-multi)
$(multi-objs-m:.o=.lst) : modname = $(modname-multi)
$(multi-objs-y) : modname = $(modname-multi)
$(multi-objs-y:.o=.i) : modname = $(modname-multi)
$(multi-objs-y:.o=.s) : modname = $(modname-multi)
$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
...@@ -314,7 +302,7 @@ endef ...@@ -314,7 +302,7 @@ endef
# List module undefined symbols (or empty line if not enabled) # List module undefined symbols (or empty line if not enabled)
ifdef CONFIG_TRIM_UNUSED_KSYMS ifdef CONFIG_TRIM_UNUSED_KSYMS
cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo cmd_undef_syms = $(NM) $@ | sed -n 's/^ *U //p' | xargs echo
else else
cmd_undef_syms = echo cmd_undef_syms = echo
endif endif
...@@ -345,8 +333,8 @@ $(obj)/%.lst: $(src)/%.c FORCE ...@@ -345,8 +333,8 @@ $(obj)/%.lst: $(src)/%.c FORCE
modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) $(real-obj-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) $(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
# .S file exports must have their C prototypes defined in asm/asm-prototypes.h # .S file exports must have their C prototypes defined in asm/asm-prototypes.h
# or a file that it includes, in order to get versioned symbols. We build a # or a file that it includes, in order to get versioned symbols. We build a
...@@ -424,7 +412,7 @@ endif ...@@ -424,7 +412,7 @@ endif
$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
$(call if_changed_rule,as_o_S) $(call if_changed_rule,as_o_S)
targets += $(real-objs-y) $(real-objs-m) $(lib-y) targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
targets += $(extra-y) $(MAKECMDGOALS) $(always) targets += $(extra-y) $(MAKECMDGOALS) $(always)
# Linker scripts preprocessor (.lds.S -> .lds) # Linker scripts preprocessor (.lds.S -> .lds)
...@@ -458,24 +446,16 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; ...@@ -458,24 +446,16 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
# #
ifdef builtin-target ifdef builtin-target
ifdef CONFIG_THIN_ARCHIVES # built-in.a archives are made with no symbol table or index which
cmd_make_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) # makes them small and fast, but unable to be used by the linker.
cmd_make_empty_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) # scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol
quiet_cmd_link_o_target = AR $@ # table and index.
else quiet_cmd_ar_builtin = AR $@
cmd_make_builtin = $(LD) $(ld_flags) -r -o cmd_ar_builtin = rm -f $@; \
cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^)
quiet_cmd_link_o_target = LD $@
endif
# If the list of objects to link is empty, just create an empty built-in.o
cmd_link_o_target = $(if $(strip $(obj-y)),\
$(cmd_make_builtin) $@ $(filter $(obj-y), $^) \
$(cmd_secanalysis),\
$(cmd_make_empty_builtin) $@)
$(builtin-target): $(obj-y) FORCE $(builtin-target): $(real-obj-y) FORCE
$(call if_changed,link_o_target) $(call if_changed,ar_builtin)
targets += $(builtin-target) targets += $(builtin-target)
endif # builtin-target endif # builtin-target
...@@ -499,11 +479,8 @@ $(modorder-target): $(subdir-ym) FORCE ...@@ -499,11 +479,8 @@ $(modorder-target): $(subdir-ym) FORCE
ifdef lib-target ifdef lib-target
quiet_cmd_link_l_target = AR $@ quiet_cmd_link_l_target = AR $@
ifdef CONFIG_THIN_ARCHIVES # lib target archives do get a symbol table and index
cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y)
else
cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
endif
$(lib-target): $(lib-y) FORCE $(lib-target): $(lib-y) FORCE
$(call if_changed,link_l_target) $(call if_changed,link_l_target)
...@@ -549,22 +526,8 @@ $($(subst $(obj)/,,$(@:.o=-objs))) \ ...@@ -549,22 +526,8 @@ $($(subst $(obj)/,,$(@:.o=-objs))) \
$($(subst $(obj)/,,$(@:.o=-y))) \ $($(subst $(obj)/,,$(@:.o=-y))) \
$($(subst $(obj)/,,$(@:.o=-m)))), $^) $($(subst $(obj)/,,$(@:.o=-m)))), $^)
cmd_link_multi-link = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
ifdef CONFIG_THIN_ARCHIVES
quiet_cmd_link_multi-y = AR $@
cmd_link_multi-y = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(link_multi_deps)
else
quiet_cmd_link_multi-y = LD $@
cmd_link_multi-y = $(cmd_link_multi-link)
endif
quiet_cmd_link_multi-m = LD [M] $@ quiet_cmd_link_multi-m = LD [M] $@
cmd_link_multi-m = $(cmd_link_multi-link) cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
$(multi-used-y): FORCE
$(call if_changed,link_multi-y)
$(call multi_depend, $(multi-used-y), .o, -objs -y)
$(multi-used-m): FORCE $(multi-used-m): FORCE
$(call if_changed,link_multi-m) $(call if_changed,link_multi-m)
...@@ -572,7 +535,7 @@ $(multi-used-m): FORCE ...@@ -572,7 +535,7 @@ $(multi-used-m): FORCE
$(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
$(call multi_depend, $(multi-used-m), .o, -objs -y -m) $(call multi_depend, $(multi-used-m), .o, -objs -y -m)
targets += $(multi-used-y) $(multi-used-m) targets += $(multi-used-m)
targets := $(filter-out $(PHONY), $(targets)) targets := $(filter-out $(PHONY), $(targets))
# Descending # Descending
......
...@@ -27,7 +27,7 @@ modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko ...@@ -27,7 +27,7 @@ modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko
# Handle objects in subdirs # Handle objects in subdirs
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a
# and add the directory to the list of dirs to descend into: $(subdir-y) # and add the directory to the list of dirs to descend into: $(subdir-y)
# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) # o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
# and add the directory to the list of dirs to descend into: $(subdir-m) # and add the directory to the list of dirs to descend into: $(subdir-m)
...@@ -35,7 +35,7 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) ...@@ -35,7 +35,7 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
subdir-y += $(__subdir-y) subdir-y += $(__subdir-y)
__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
subdir-m += $(__subdir-m) subdir-m += $(__subdir-m)
obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) obj-y := $(patsubst %/, %/built-in.a, $(obj-y))
obj-m := $(filter-out %/, $(obj-m)) obj-m := $(filter-out %/, $(obj-m))
# Subdirectories we need to descend into # Subdirectories we need to descend into
...@@ -47,18 +47,14 @@ multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m ...@@ -47,18 +47,14 @@ multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m
multi-used := $(multi-used-y) $(multi-used-m) multi-used := $(multi-used-y) $(multi-used-m)
single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
# Build list of the parts of our composite objects, our composite
# objects depend on those (obviously)
multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
# tell kbuild to descend # tell kbuild to descend
subdir-obj-y := $(filter %/built-in.o, $(obj-y)) subdir-obj-y := $(filter %/built-in.a, $(obj-y))
# Replace multi-part objects by their individual parts, look at local dir only # Replace multi-part objects by their individual parts,
real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) # including built-in.a from subdirectories
real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
# DTB # DTB
# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
...@@ -71,29 +67,29 @@ extra-y := $(addprefix $(obj)/,$(extra-y)) ...@@ -71,29 +67,29 @@ extra-y := $(addprefix $(obj)/,$(extra-y))
always := $(addprefix $(obj)/,$(always)) always := $(addprefix $(obj)/,$(always))
targets := $(addprefix $(obj)/,$(targets)) targets := $(addprefix $(obj)/,$(targets))
modorder := $(addprefix $(obj)/,$(modorder)) modorder := $(addprefix $(obj)/,$(modorder))
obj-y := $(addprefix $(obj)/,$(obj-y))
obj-m := $(addprefix $(obj)/,$(obj-m)) obj-m := $(addprefix $(obj)/,$(obj-m))
lib-y := $(addprefix $(obj)/,$(lib-y)) lib-y := $(addprefix $(obj)/,$(lib-y))
subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
single-used-m := $(addprefix $(obj)/,$(single-used-m)) single-used-m := $(addprefix $(obj)/,$(single-used-m))
multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
# Finds the multi-part object the current object will be linked into.
# If the object belongs to two or more multi-part objects, all of them are
# concatenated with a colon separator.
modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))))
modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
# These flags are needed for modversions and compiling, so we define them here # These flags are needed for modversions and compiling, so we define them here
# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
# end up in (or would, if it gets compiled in) # end up in (or would, if it gets compiled in)
# Note: Files that end up in two or more modules are compiled without the
# KBUILD_MODNAME definition. The reason is that any made-up name would
# differ in different configs.
name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
modname_flags = $(if $(filter 1,$(words $(modname))),\ modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname))
-DKBUILD_MODNAME=$(call name-fix,$(modname)))
orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
$(ccflags-y) $(CFLAGS_$(basetarget).o) $(ccflags-y) $(CFLAGS_$(basetarget).o)
...@@ -156,6 +152,7 @@ __cpp_flags = $(call flags,_cpp_flags) ...@@ -156,6 +152,7 @@ __cpp_flags = $(call flags,_cpp_flags)
endif endif
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
-include $(srctree)/include/linux/compiler_types.h \
$(__c_flags) $(modkern_cflags) \ $(__c_flags) $(modkern_cflags) \
$(basename_flags) $(modname_flags) $(basename_flags) $(modname_flags)
...@@ -173,10 +170,6 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ ...@@ -173,10 +170,6 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
$(addprefix -I,$(DTC_INCLUDE)) \ $(addprefix -I,$(DTC_INCLUDE)) \
-undef -D__DTS__ -undef -D__DTS__
# Finds the multi-part object the current object will be linked into
modname-multi = $(sort $(foreach m,$(multi-used),\
$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
# Useful for describing the dependency of composite objects # Useful for describing the dependency of composite objects
# Usage: # Usage:
# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add) # $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
...@@ -329,7 +322,7 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) ...@@ -329,7 +322,7 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
size_append = printf $(shell \ size_append = printf $(shell \
dec_size=0; \ dec_size=0; \
for F in $1; do \ for F in $1; do \
fsize=$$(stat -c "%s" $$F); \ fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \
dec_size=$$(expr $$dec_size + $$fsize); \ dec_size=$$(expr $$dec_size + $$fsize); \
done; \ done; \
printf "%08x\n" $$dec_size | \ printf "%08x\n" $$dec_size | \
......
...@@ -48,9 +48,6 @@ case "${KCONFIG_CONFIG}" in ...@@ -48,9 +48,6 @@ case "${KCONFIG_CONFIG}" in
. "./${KCONFIG_CONFIG}" . "./${KCONFIG_CONFIG}"
esac esac
# In case it doesn't exist yet...
if [ -e "$cur_ksyms_file" ]; then touch "$cur_ksyms_file"; fi
# Generate a new ksym list file with symbols needed by the current # Generate a new ksym list file with symbols needed by the current
# set of modules. # set of modules.
cat > "$new_ksyms_file" << EOT cat > "$new_ksyms_file" << EOT
...@@ -60,7 +57,9 @@ cat > "$new_ksyms_file" << EOT ...@@ -60,7 +57,9 @@ cat > "$new_ksyms_file" << EOT
EOT EOT
[ "$(ls -A "$MODVERDIR")" ] && [ "$(ls -A "$MODVERDIR")" ] &&
sed -ns -e '3{s/ /\n/g;/^$/!p;}' "$MODVERDIR"/*.mod | sort -u | for mod in "$MODVERDIR"/*.mod; do
sed -n -e '3{s/ /\n/g;/^$/!p;}' "$mod"
done | sort -u |
while read sym; do while read sym; do
if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then
sym="${sym#_}" sym="${sym#_}"
...@@ -81,7 +80,7 @@ sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u | ...@@ -81,7 +80,7 @@ sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u |
sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" | sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" |
while read sympath; do while read sympath; do
if [ -z "$sympath" ]; then continue; fi if [ -z "$sympath" ]; then continue; fi
depfile="include/config/ksym/${sympath}.h" depfile="include/ksym/${sympath}.h"
mkdir -p "$(dirname "$depfile")" mkdir -p "$(dirname "$depfile")"
touch "$depfile" touch "$depfile"
# Filesystems with coarse time precision may create timestamps # Filesystems with coarse time precision may create timestamps
......
...@@ -113,11 +113,11 @@ static void usage(void) ...@@ -113,11 +113,11 @@ static void usage(void)
/* /*
* Print out a dependency path from a symbol name * Print out a dependency path from a symbol name
*/ */
static void print_config(const char *m, int slen) static void print_dep(const char *m, int slen, const char *dir)
{ {
int c, i; int c, i;
printf(" $(wildcard include/config/"); printf(" $(wildcard %s/", dir);
for (i = 0; i < slen; i++) { for (i = 0; i < slen; i++) {
c = m[i]; c = m[i];
if (c == '_') if (c == '_')
...@@ -140,7 +140,7 @@ static void do_extra_deps(void) ...@@ -140,7 +140,7 @@ static void do_extra_deps(void)
fprintf(stderr, "fixdep: bad data on stdin\n"); fprintf(stderr, "fixdep: bad data on stdin\n");
exit(1); exit(1);
} }
print_config(buf, len - 1); print_dep(buf, len - 1, "include/ksym");
} }
} }
...@@ -208,7 +208,7 @@ static void use_config(const char *m, int slen) ...@@ -208,7 +208,7 @@ static void use_config(const char *m, int slen)
return; return;
define_config(m, slen, hash); define_config(m, slen, hash);
print_config(m, slen); print_dep(m, slen, "include/config");
} }
/* test if s ends in sub */ /* test if s ends in sub */
......
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# clang-version [-p] clang-command
#
# Prints the compiler version of `clang-command' in a canonical 4-digit form
# such as `0500' for clang-5.0 etc.
#
# With the -p option, prints the patchlevel as well, for example `050001' for
# clang-5.0.1 etc.
#
if [ "$1" = "-p" ] ; then
with_patchlevel=1;
shift;
fi
compiler="$*"
if [ ${#compiler} -eq 0 ]; then
echo "Error: No compiler specified."
printf "Usage:\n\t$0 <clang-command>\n"
exit 1
fi
MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1)
MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1)
if [ "x$with_patchlevel" != "x" ] ; then
PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1)
printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
else
printf "%02d%02d\\n" $MAJOR $MINOR
fi
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
set -- $(ls -dn "$1")
printf '%s\n' "$5"
...@@ -194,7 +194,7 @@ input_file() { ...@@ -194,7 +194,7 @@ input_file() {
source="$1" source="$1"
if [ -f "$1" ]; then if [ -f "$1" ]; then
${dep_list}header "$1" ${dep_list}header "$1"
is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')" is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\{0,1\}/cpio/')"
if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then
cpio_file=$1 cpio_file=$1
echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed"
......
...@@ -31,13 +31,13 @@ trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT ...@@ -31,13 +31,13 @@ trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT
for i in "$@" for i in "$@"
do do
FILE="$(basename "$i")" FILE="$(basename "$i")"
sed -r \ sed -E \
-e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \ -e 's/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g' \
-e 's/__attribute_const__([ \t]|$)/\1/g' \ -e 's/__attribute_const__([[:space:]]|$)/\1/g' \
-e 's@^#include <linux/compiler(|_types).h>@@' \ -e 's@^#include <linux/compiler(|_types).h>@@' \
-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
-e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \ -e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \
-e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ -e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \
"$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1 "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \
> "$OUTDIR/$FILE" > "$OUTDIR/$FILE"
......
...@@ -38,8 +38,6 @@ nconfig: $(obj)/nconf ...@@ -38,8 +38,6 @@ nconfig: $(obj)/nconf
# for external use. # for external use.
silentoldconfig: $(obj)/conf silentoldconfig: $(obj)/conf
$(Q)mkdir -p include/config include/generated $(Q)mkdir -p include/config include/generated
$(Q)test -e include/generated/autoksyms.h || \
touch include/generated/autoksyms.h
$< $(silent) --$@ $(Kconfig) $< $(silent) --$@ $(Kconfig)
localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# link vmlinux # link vmlinux
# #
# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and
# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.o files # $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files
# from top-level directories in the kernel tree, others are specified in # from top-level directories in the kernel tree, others are specified in
# arch/$(ARCH)/Makefile. Ordering when linking is important, and # arch/$(ARCH)/Makefile. Ordering when linking is important, and
# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives # $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# | +--< init/version.o + more # | +--< init/version.o + more
# | # |
# +--< $(KBUILD_VMLINUX_MAIN) # +--< $(KBUILD_VMLINUX_MAIN)
# | +--< drivers/built-in.o mm/built-in.o + more # | +--< drivers/built-in.a mm/built-in.a + more
# | # |
# +--< $(KBUILD_VMLINUX_LIBS) # +--< $(KBUILD_VMLINUX_LIBS)
# | +--< lib/lib.a + more # | +--< lib/lib.a + more
...@@ -51,17 +51,15 @@ info() ...@@ -51,17 +51,15 @@ info()
# #
# Traditional incremental style of link does not require this step # Traditional incremental style of link does not require this step
# #
# built-in.o output file # built-in.a output file
# #
archive_builtin() archive_builtin()
{ {
if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then info AR built-in.a
info AR built-in.o rm -f built-in.a;
rm -f built-in.o; ${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \
${AR} rcsTP${KBUILD_ARFLAGS} built-in.o \ ${KBUILD_VMLINUX_INIT} \
${KBUILD_VMLINUX_INIT} \ ${KBUILD_VMLINUX_MAIN}
${KBUILD_VMLINUX_MAIN}
fi
} }
# Link of vmlinux.o used for section mismatch analysis # Link of vmlinux.o used for section mismatch analysis
...@@ -70,20 +68,13 @@ modpost_link() ...@@ -70,20 +68,13 @@ modpost_link()
{ {
local objects local objects
if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then objects="--whole-archive \
objects="--whole-archive \ built-in.a \
built-in.o \ --no-whole-archive \
--no-whole-archive \ --start-group \
--start-group \ ${KBUILD_VMLINUX_LIBS} \
${KBUILD_VMLINUX_LIBS} \ --end-group"
--end-group"
else
objects="${KBUILD_VMLINUX_INIT} \
--start-group \
${KBUILD_VMLINUX_MAIN} \
${KBUILD_VMLINUX_LIBS} \
--end-group"
fi
${LD} ${LDFLAGS} -r -o ${1} ${objects} ${LD} ${LDFLAGS} -r -o ${1} ${objects}
} }
...@@ -96,46 +87,28 @@ vmlinux_link() ...@@ -96,46 +87,28 @@ vmlinux_link()
local objects local objects
if [ "${SRCARCH}" != "um" ]; then if [ "${SRCARCH}" != "um" ]; then
if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then objects="--whole-archive \
objects="--whole-archive \ built-in.a \
built-in.o \ --no-whole-archive \
--no-whole-archive \ --start-group \
--start-group \ ${KBUILD_VMLINUX_LIBS} \
${KBUILD_VMLINUX_LIBS} \ --end-group \
--end-group \ ${1}"
${1}"
else ${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \
objects="${KBUILD_VMLINUX_INIT} \
--start-group \
${KBUILD_VMLINUX_MAIN} \
${KBUILD_VMLINUX_LIBS} \
--end-group \
${1}"
fi
${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \
-T ${lds} ${objects} -T ${lds} ${objects}
else else
if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then objects="-Wl,--whole-archive \
objects="-Wl,--whole-archive \ built-in.a \
built-in.o \ -Wl,--no-whole-archive \
-Wl,--no-whole-archive \ -Wl,--start-group \
-Wl,--start-group \ ${KBUILD_VMLINUX_LIBS} \
${KBUILD_VMLINUX_LIBS} \ -Wl,--end-group \
-Wl,--end-group \ ${1}"
${1}"
else ${CC} ${CFLAGS_vmlinux} -o ${2} \
objects="${KBUILD_VMLINUX_INIT} \ -Wl,-T,${lds} \
-Wl,--start-group \ ${objects} \
${KBUILD_VMLINUX_MAIN} \
${KBUILD_VMLINUX_LIBS} \
-Wl,--end-group \
${1}"
fi
${CC} ${CFLAGS_vmlinux} -o ${2} \
-Wl,-T,${lds} \
${objects} \
-lutil -lrt -lpthread -lutil -lrt -lpthread
rm -f linux rm -f linux
fi fi
...@@ -191,7 +164,7 @@ cleanup() ...@@ -191,7 +164,7 @@ cleanup()
rm -f .tmp_System.map rm -f .tmp_System.map
rm -f .tmp_kallsyms* rm -f .tmp_kallsyms*
rm -f .tmp_vmlinux* rm -f .tmp_vmlinux*
rm -f built-in.o rm -f built-in.a
rm -f System.map rm -f System.map
rm -f vmlinux rm -f vmlinux
rm -f vmlinux.o rm -f vmlinux.o
...@@ -296,8 +269,8 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then ...@@ -296,8 +269,8 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
# step 3 # step 3
size1=$(stat -c "%s" .tmp_kallsyms1.o) size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms1.o)
size2=$(stat -c "%s" .tmp_kallsyms2.o) size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms2.o)
if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
kallsymso=.tmp_kallsyms3.o kallsymso=.tmp_kallsyms3.o
......
...@@ -164,7 +164,7 @@ sub linux_objects ...@@ -164,7 +164,7 @@ sub linux_objects
s:^\./::; s:^\./::;
if (/.*\.o$/ && if (/.*\.o$/ &&
! ( ! (
m:/built-in.o$: m:/built-in.a$:
|| m:arch/x86/vdso/: || m:arch/x86/vdso/:
|| m:arch/x86/boot/: || m:arch/x86/boot/:
|| m:arch/ia64/ia32/ia32.o$: || m:arch/ia64/ia32/ia32.o$:
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
ld -m elf_i386 --format binary --oformat elf32-i386 -r \ ld -m elf_i386 --format binary --oformat elf32-i386 -r \
-T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o
ld -m elf_i386 -r -o built-in.o initramfs_data.o ld -m elf_i386 -r -o built-in.a initramfs_data.o
For including the .init.ramfs sections, see include/asm-generic/vmlinux.lds. For including the .init.ramfs sections, see include/asm-generic/vmlinux.lds.
......
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