mirror of
https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9.git
synced 2026-09-09 00:08:12 +08:00
JIRA: https://issues.redhat.com/browse/RHEL-107194 commit b1992c3772e69a6fd0e3fc81cd4d2820c8b6eca0 Author: Masahiro Yamada <masahiroy@kernel.org> Date: Sat Apr 27 23:55:02 2024 +0900 kbuild: use $(src) instead of $(srctree)/$(src) for source directory Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for checked-in source files. It is merely a convention without any functional difference. In fact, $(obj) and $(src) are exactly the same, as defined in scripts/Makefile.build: src := $(obj) When the kernel is built in a separate output directory, $(src) does not accurately reflect the source directory location. While Kbuild resolves this discrepancy by specifying VPATH=$(srctree) to search for source files, it does not cover all cases. For example, when adding a header search path for local headers, -I$(srctree)/$(src) is typically passed to the compiler. This introduces inconsistency between upstream and downstream Makefiles because $(src) is used instead of $(srctree)/$(src) for the latter. To address this inconsistency, this commit changes the semantics of $(src) so that it always points to the directory in the source tree. Going forward, the variables used in Makefiles will have the following meanings: $(obj) - directory in the object tree $(src) - directory in the source tree (changed by this commit) $(objtree) - the top of the kernel object tree $(srctree) - the top of the kernel source tree Consequently, $(srctree)/$(src) in upstream Makefiles need to be replaced with $(src). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu> Conflicts: There is a extensive list of fixes/conflicts due the amount of files originally changed by this commit, plus the difference of rhel-9 code against upstream. All conflicts/differences are listed below: - Context difference at Documentation/Makefile since RHEL 9 does not have the change "docs: allow to pass extra DOCS_CSS themes via make" and later changes. - Conflict at Documentation/devicetree/bindings/Makefile, patch find_cmd instead of find_all_cmd since RHEL-9 doesn't have "dt-bindings: Consider DT_SCHEMA_FILES when finding all json-schema", "dt-bindings: kbuild: Split targets out to separate rules" and later changes. - Conflict at Documentation/kbuild/makefiles.rst due different identation since RHEL-9 doesn't have the change "docs/kbuild/makefiles: clean up indentation and whitespace" - Patched additional $(srctree)/$(src) references at: * arch/arm/mach-davinci/Makefile * arch/arm/mach-omap2/Makefile * arch/arm/mach-spear/Makefile * arch/arm/plat-pxa/Makefile * arch/arm/plat-versatile/Makefile * arch/ia64/kernel/Makefile * arch/nds32/boot/Makefile * arch/nds32/kernel/vdso/Makefile * drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile * drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile * drivers/staging/rtl8188eu/Makefile * drivers/staging/unisys/visorhba/Makefile * drivers/staging/unisys/visornic/Makefile * scripts/gcc-plugins/Makefile Since RHEL-9 does not have later upstream changes that dropped/made those references uneeded. - Conflict at arch/arm/mach-s3c/Makefile since RHEL-9 doesn't have "ARM: s3c: remove s3c24xx specific hacks" and related changes. Also, extra locations needed patching because of not having the changes "ARM: s3c: remove all s3c24xx support" and "ARM: s3c: fix include path". Due lacking the last change also arch/arm/mach-s3c/Makefile.s3c64xx needs additional two places patched as well. - Conflict at arch/arm/plat-orion/Makefile since RHEL-9 doesn't have the commit "ARM: orion: fix include path" and its previous related changes. - Dropped changes for arch/loongarch since it doesn't exist on rhel-9 - Dropped changes to arch/parisc/kernel/{vdso32,vdso64}/Makefile since RHEL 9 does not have the change "parisc: Add vDSO support" and later updates to it. - Dropped change to arch/riscv/kernel/compat_vdso/Makefile since RHEL 9 does not have the change "riscv: compat: vdso: Add COMPAT_VDSO base code implementation" - Dropped change to arch/riscv/kvm/Makefile since there is no KVM support/commits in RHEL 9 for riscv. - Apply change for arch/riscv/kernel/vdso/Makefile in a different place since RHEL-9 does not have the change "riscv: explicitly use symbol offsets for VDSO" which changed the location of the $(srctree)/$(src) reference - Dropped change to certs/Makefile related to check-blacklist-hashes.awk since that script was only added with commit "certs: Check that builtin blacklist hashes are valid" which is not backported/available in RHEL 9 code right now. - Dropped change to drivers/md/dm-vdo/Makefile since dm-vdo was never backported to RHEL-9 main. - Dropped change to drivers/net/ethernet/fungible/funeth/Makefile since fungible ethernet driver/devices code is not available/backported to RHEL-9. - Fixed conflict at drivers/net/ethernet/hisilicon/hns3/Makefile since RHEL-9 does not have the change "net: hns3: refactor hns3 makefile to support hns3_common module" - Fixed conflict at drivers/net/wireless/intel/iwlwifi/mvm/Makefile due already backported commit "wifi: iwlwifi: mvm: implement link grading" - Dropped change to init/Makefile since we are not backporting "kbuild: build init/built-in.a just once" that introduced the section patched. - Dropped change to rust/Makefile since there is no rust support backported to RHEL-9. - Fixed conflict at scripts/dtc/Makefile since RHEL-9 does not have the change "dt-bindings: kbuild: Use DTB files for validation" - Dropped change to security/tomoyo/Makefile since it's not needed, it's just reverting the change "tomoyo: fix broken dependency on *.conf.default" which was never applied to RHEL-9. However, we also bring a different change/patch location since RHEL-9 does not have the change "tomoyo: Omit use of bin2c". - Dropped change to usr/include/Makefile since "kbuild: move headers_check.pl to usr/include/" is not being backported to RHEL-9. - Misc/minor context differences at other places. Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
147 lines
4.2 KiB
Makefile
147 lines
4.2 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# ===========================================================================
|
|
# Module versions
|
|
# ===========================================================================
|
|
#
|
|
# Stage one of module building created the following:
|
|
# a) The individual .o files used for the module
|
|
# b) A <module>.o file which is the .o files above linked together
|
|
# c) A <module>.mod file, listing the name of the preliminary <module>.o file,
|
|
# plus all .o files
|
|
# d) modules.order, which lists all the modules
|
|
|
|
# Stage 2 is handled by this file and does the following
|
|
# 1) Find all modules listed in modules.order
|
|
# 2) modpost is then used to
|
|
# 3) create one <module>.mod.c file pr. module
|
|
# 4) create one Module.symvers file with CRC for all exported symbols
|
|
|
|
# Step 3 is used to place certain information in the module's ELF
|
|
# section, including information such as:
|
|
# Version magic (see include/linux/vermagic.h for full details)
|
|
# - Kernel release
|
|
# - SMP is CONFIG_SMP
|
|
# - PREEMPT is CONFIG_PREEMPT[_RT]
|
|
# - GCC Version
|
|
# Module info
|
|
# - Module version (MODULE_VERSION)
|
|
# - Module alias'es (MODULE_ALIAS)
|
|
# - Module license (MODULE_LICENSE)
|
|
# - See include/linux/module.h for more details
|
|
|
|
# Step 4 is solely used to allow module versioning in external modules,
|
|
# where the CRC of each module is retrieved from the Module.symvers file.
|
|
|
|
# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
|
|
# This is solely useful to speed up test compiles
|
|
|
|
PHONY := __modpost
|
|
__modpost:
|
|
|
|
include include/config/auto.conf
|
|
include $(srctree)/scripts/Kbuild.include
|
|
|
|
MODPOST = scripts/mod/modpost \
|
|
$(if $(CONFIG_MODVERSIONS),-m) \
|
|
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
|
|
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
|
|
-o $@
|
|
|
|
ifdef MODPOST_VMLINUX
|
|
|
|
quiet_cmd_modpost = MODPOST $@
|
|
cmd_modpost = $(MODPOST) $<
|
|
|
|
vmlinux.symvers: vmlinux.o
|
|
$(call cmd,modpost)
|
|
|
|
__modpost: vmlinux.symvers
|
|
|
|
else
|
|
|
|
ifeq ($(KBUILD_EXTMOD),)
|
|
|
|
input-symdump := vmlinux.symvers
|
|
output-symdump := modules-only.symvers
|
|
|
|
quiet_cmd_cat = GEN $@
|
|
cmd_cat = cat $(real-prereqs) > $@
|
|
|
|
ifneq ($(wildcard vmlinux.symvers),)
|
|
|
|
__modpost: Module.symvers
|
|
Module.symvers: vmlinux.symvers modules-only.symvers FORCE
|
|
$(call if_changed,cat)
|
|
|
|
targets += Module.symvers
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
# set src + obj - they may be used in the modules's Makefile
|
|
obj := $(KBUILD_EXTMOD)
|
|
src := $(if $(VPATH),$(VPATH)/)$(obj)
|
|
|
|
# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
|
|
include $(kbuild-file)
|
|
|
|
# modpost option for external modules
|
|
MODPOST += -e
|
|
|
|
input-symdump := Module.symvers $(KBUILD_EXTRA_SYMBOLS)
|
|
output-symdump := $(KBUILD_EXTMOD)/Module.symvers
|
|
|
|
endif
|
|
|
|
existing-input-symdump := $(wildcard $(input-symdump))
|
|
|
|
# modpost options for modules (both in-kernel and external)
|
|
MODPOST += \
|
|
$(addprefix -i ,$(existing-input-symdump)) \
|
|
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \
|
|
$(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N)
|
|
|
|
# 'make -i -k' ignores compile errors, and builds as many modules as possible.
|
|
ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
|
|
MODPOST += -n
|
|
endif
|
|
|
|
# Clear VPATH to not search for *.symvers in $(srctree). Check only $(objtree).
|
|
VPATH :=
|
|
$(input-symdump):
|
|
@echo >&2 'WARNING: Symbol version dump "$@" is missing.'
|
|
@echo >&2 ' Modules may not have dependencies or modversions.'
|
|
@echo >&2 ' You may get many unresolved symbol warnings.'
|
|
|
|
# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined symbols
|
|
ifneq ($(KBUILD_MODPOST_WARN)$(filter-out $(existing-input-symdump), $(input-symdump)),)
|
|
MODPOST += -w
|
|
endif
|
|
|
|
# Read out modules.order to pass in modpost.
|
|
# Otherwise, allmodconfig would fail with "Argument list too long".
|
|
quiet_cmd_modpost = MODPOST $@
|
|
cmd_modpost = sed 's/ko$$/o/' $< | $(MODPOST) -T -
|
|
|
|
$(output-symdump): $(MODORDER) $(input-symdump) FORCE
|
|
$(call if_changed,modpost)
|
|
|
|
targets += $(output-symdump)
|
|
|
|
__modpost: $(output-symdump)
|
|
ifneq ($(KBUILD_MODPOST_NOFINAL),1)
|
|
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
|
|
endif
|
|
|
|
PHONY += FORCE
|
|
FORCE:
|
|
|
|
existing-targets := $(wildcard $(sort $(targets)))
|
|
|
|
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
|
|
|
|
endif
|
|
|
|
.PHONY: $(PHONY)
|