mirror of
https://github.com/torvalds/linux.git
synced 2025-04-12 06:49:52 +00:00
Kbuild updates for v6.15
- Improve performance in gendwarfksyms - Remove deprecated EXTRA_*FLAGS and KBUILD_ENABLE_EXTRA_GCC_CHECKS - Support CONFIG_HEADERS_INSTALL for ARCH=um - Use more relative paths to sources files for better reproducibility - Support the loong64 Debian architecture - Add Kbuild bash completion - Introduce intermediate vmlinux.unstripped for architectures that need static relocations to be stripped from the final vmlinux - Fix versioning in Debian packages for -rc releases - Treat missing MODULE_DESCRIPTION() as an error - Convert Nios2 Makefiles to use the generic rule for built-in DTB - Add debuginfo support to the RPM package -----BEGIN PGP SIGNATURE----- iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmfxp2EVHG1hc2FoaXJv eUBrZXJuZWwub3JnAAoJED2LAQed4NsGkIUP/AgNiP6or6fmY5+HSyjlrdutBWAh QNW0AiKh5vytmBIv63/i103OE0SRbt+U6IApn9c7FQKkeuyIlD1e9NfSwFMZixmP P7t6JqDCL61G5d3W2Iisqle1cpBoVvNgUwu0k3sTSXl0vNsDbiyxcCzQzLhZMKsd O+Ppwp3zNGE2vIUwpIjzJsR5Dt/Z5MfuKDi4UShsyWpFZ1rg9X93YKc9QJOXjKwj 4Np2x2cukDo2oz4uXuZQ8F1+bOFsKYoilCwjtxlrC6BO0lSPiJsRTN6nGJ0ejns9 GGD56mBNGcGk+NEPGhAMQmZHqNAP4JfjEvAgaoSBn0Rdnjd9Cj/2T+4n61xkR4Wu MXCP/LEJ3MyctmkZjUq+0fDAe2wjxuaAG15kAHCha+9KxIG2NzHbf2XXb4E49DDU 2rw3fqA41/cKCq1ZEaqRn3pZZgU6ysfsEW42JmnNxO+7zz9k8RX4rk8CVaVIEUuw Xojkis//KnE6+OCBe6Tb0H2Rzo0JF3AG2eNF4zY/xnc562FRIMS19WYS38tKZng6 Gr1BRG0bA4t9mf2Vck1W1LcAb3Jh0mddtyrgYKhbcwq0YOj2q/H6F50DkC+wL282 wvhV6B/vKAH8BByEWAn3rBcN0N+w/VFc0uPCz//tkoAm4nPg8PvKq63JHPrHsyZe mOMhifoiVbjF4KFo =GiQ6 -----END PGP SIGNATURE----- Merge tag 'kbuild-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild Pull Kbuild updates from Masahiro Yamada: - Improve performance in gendwarfksyms - Remove deprecated EXTRA_*FLAGS and KBUILD_ENABLE_EXTRA_GCC_CHECKS - Support CONFIG_HEADERS_INSTALL for ARCH=um - Use more relative paths to sources files for better reproducibility - Support the loong64 Debian architecture - Add Kbuild bash completion - Introduce intermediate vmlinux.unstripped for architectures that need static relocations to be stripped from the final vmlinux - Fix versioning in Debian packages for -rc releases - Treat missing MODULE_DESCRIPTION() as an error - Convert Nios2 Makefiles to use the generic rule for built-in DTB - Add debuginfo support to the RPM package * tag 'kbuild-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (40 commits) kbuild: rpm-pkg: build a debuginfo RPM kconfig: merge_config: use an empty file as initfile nios2: migrate to the generic rule for built-in DTB rust: kbuild: skip `--remap-path-prefix` for `rustdoc` kbuild: pacman-pkg: hardcode module installation path kbuild: deb-pkg: don't set KBUILD_BUILD_VERSION unconditionally modpost: require a MODULE_DESCRIPTION() kbuild: make all file references relative to source root x86: drop unnecessary prefix map configuration kbuild: deb-pkg: add comment about future removal of KDEB_COMPRESS kbuild: Add a help message for "headers" kbuild: deb-pkg: remove "version" variable in mkdebian kbuild: deb-pkg: fix versioning for -rc releases Documentation/kbuild: Fix indentation in modules.rst example x86: Get rid of Makefile.postlink kbuild: Create intermediate vmlinux build with relocations preserved kbuild: Introduce Kconfig symbol for linking vmlinux with relocations kbuild: link-vmlinux.sh: Make output file name configurable kbuild: do not generate .tmp_vmlinux*.map when CONFIG_VMLINUX_MAP=y Revert "kheaders: Ignore silly-rename files" ...
This commit is contained in:
commit
f4d2ef4825
1
.gitignore
vendored
1
.gitignore
vendored
@ -65,6 +65,7 @@ modules.order
|
||||
/vmlinux.32
|
||||
/vmlinux.map
|
||||
/vmlinux.symvers
|
||||
/vmlinux.unstripped
|
||||
/vmlinux-gdb.py
|
||||
/vmlinuz
|
||||
/System.map
|
||||
|
@ -342,24 +342,6 @@ API usage
|
||||
|
||||
See: https://www.kernel.org/doc/html/latest/RCU/whatisRCU.html#full-list-of-rcu-apis
|
||||
|
||||
**DEPRECATED_VARIABLE**
|
||||
EXTRA_{A,C,CPP,LD}FLAGS are deprecated and should be replaced by the new
|
||||
flags added via commit f77bf01425b1 ("kbuild: introduce ccflags-y,
|
||||
asflags-y and ldflags-y").
|
||||
|
||||
The following conversion scheme maybe used::
|
||||
|
||||
EXTRA_AFLAGS -> asflags-y
|
||||
EXTRA_CFLAGS -> ccflags-y
|
||||
EXTRA_CPPFLAGS -> cppflags-y
|
||||
EXTRA_LDFLAGS -> ldflags-y
|
||||
|
||||
See:
|
||||
|
||||
1. https://lore.kernel.org/lkml/20070930191054.GA15876@uranus.ravnborg.org/
|
||||
2. https://lore.kernel.org/lkml/1313384834-24433-12-git-send-email-lacombar@gmail.com/
|
||||
3. https://www.kernel.org/doc/html/latest/kbuild/makefiles.html#compilation-flags
|
||||
|
||||
**DEVICE_ATTR_FUNCTIONS**
|
||||
The function names used in DEVICE_ATTR is unusual.
|
||||
Typically, the store and show functions are used with <attr>_store and
|
||||
|
65
Documentation/kbuild/bash-completion.rst
Normal file
65
Documentation/kbuild/bash-completion.rst
Normal file
@ -0,0 +1,65 @@
|
||||
.. SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
==========================
|
||||
Bash completion for Kbuild
|
||||
==========================
|
||||
|
||||
The kernel build system is written using Makefiles, and Bash completion
|
||||
for the `make` command is available through the `bash-completion`_ project.
|
||||
|
||||
However, the Makefiles for the kernel build are complex. The generic completion
|
||||
rules for the `make` command do not provide meaningful suggestions for the
|
||||
kernel build system, except for the options of the `make` command itself.
|
||||
|
||||
To enhance completion for various variables and targets, the kernel source
|
||||
includes its own completion script at `scripts/bash-completion/make`.
|
||||
|
||||
This script provides additional completions when working within the kernel tree.
|
||||
Outside the kernel tree, it defaults to the generic completion rules for the
|
||||
`make` command.
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
|
||||
The script relies on helper functions provided by `bash-completion`_ project.
|
||||
Please ensure it is installed on your system. On most distributions, you can
|
||||
install the `bash-completion` package through the standard package manager.
|
||||
|
||||
How to use
|
||||
==========
|
||||
|
||||
You can source the script directly::
|
||||
|
||||
$ source scripts/bash-completion/make
|
||||
|
||||
Or, you can copy it into the search path for Bash completion scripts.
|
||||
For example::
|
||||
|
||||
$ mkdir -p ~/.local/share/bash-completion/completions
|
||||
$ cp scripts/bash-completion/make ~/.local/share/bash-completion/completions/
|
||||
|
||||
Details
|
||||
=======
|
||||
|
||||
The additional completion for Kbuild is enabled in the following cases:
|
||||
|
||||
- You are in the root directory of the kernel source.
|
||||
- You are in the top-level build directory created by the O= option
|
||||
(checked via the `source` symlink pointing to the kernel source).
|
||||
- The -C make option specifies the kernel source or build directory.
|
||||
- The -f make option specifies a file in the kernel source or build directory.
|
||||
|
||||
If none of the above are met, it falls back to the generic completion rules.
|
||||
|
||||
The completion supports:
|
||||
|
||||
- Commonly used targets, such as `all`, `menuconfig`, `dtbs`, etc.
|
||||
- Make (or environment) variables, such as `ARCH`, `LLVM`, etc.
|
||||
- Single-target builds (`foo/bar/baz.o`)
|
||||
- Configuration files (`*_defconfig` and `*.config`)
|
||||
|
||||
Some variables offer intelligent behavior. For instance, `CROSS_COMPILE=`
|
||||
followed by a TAB displays installed toolchains. The list of defconfig files
|
||||
shown depends on the value of the `ARCH=` variable.
|
||||
|
||||
.. _bash-completion: https://github.com/scop/bash-completion/
|
@ -23,6 +23,8 @@ Kernel Build System
|
||||
llvm
|
||||
gendwarfksyms
|
||||
|
||||
bash-completion
|
||||
|
||||
.. only:: subproject and html
|
||||
|
||||
Indices
|
||||
|
@ -194,16 +194,6 @@ applicable everywhere (see syntax).
|
||||
ability to hook into a secondary subsystem while allowing the user to
|
||||
configure that subsystem out without also having to unset these drivers.
|
||||
|
||||
Note: If the combination of FOO=y and BAZ=m causes a link error,
|
||||
you can guard the function call with IS_REACHABLE()::
|
||||
|
||||
foo_init()
|
||||
{
|
||||
if (IS_REACHABLE(CONFIG_BAZ))
|
||||
baz_register(&foo);
|
||||
...
|
||||
}
|
||||
|
||||
Note: If the feature provided by BAZ is highly desirable for FOO,
|
||||
FOO should imply not only BAZ, but also its dependency BAR::
|
||||
|
||||
@ -588,7 +578,9 @@ uses the slightly counterintuitive::
|
||||
depends on BAR || !BAR
|
||||
|
||||
This means that there is either a dependency on BAR that disallows
|
||||
the combination of FOO=y with BAR=m, or BAR is completely disabled.
|
||||
the combination of FOO=y with BAR=m, or BAR is completely disabled. The BAR
|
||||
module must provide all the stubs for !BAR case.
|
||||
|
||||
For a more formalized approach if there are multiple drivers that have
|
||||
the same dependency, a helper symbol can be used, like::
|
||||
|
||||
@ -599,6 +591,21 @@ the same dependency, a helper symbol can be used, like::
|
||||
config BAR_OPTIONAL
|
||||
def_tristate BAR || !BAR
|
||||
|
||||
Much less favorable way to express optional dependency is IS_REACHABLE() within
|
||||
the module code, useful for example when the module BAR does not provide
|
||||
!BAR stubs::
|
||||
|
||||
foo_init()
|
||||
{
|
||||
if (IS_REACHABLE(CONFIG_BAR))
|
||||
bar_register(&foo);
|
||||
...
|
||||
}
|
||||
|
||||
IS_REACHABLE() is generally discouraged, because the code will be silently
|
||||
discarded, when CONFIG_BAR=m and this code is built-in. This is not what users
|
||||
usually expect when enabling BAR as module.
|
||||
|
||||
Kconfig recursive dependency limitations
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -318,9 +318,6 @@ ccflags-y, asflags-y and ldflags-y
|
||||
These three flags apply only to the kbuild makefile in which they
|
||||
are assigned. They are used for all the normal cc, as and ld
|
||||
invocations happening during a recursive build.
|
||||
Note: Flags with the same behaviour were previously named:
|
||||
EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS.
|
||||
They are still supported but their usage is deprecated.
|
||||
|
||||
ccflags-y specifies options for compiling with $(CC).
|
||||
|
||||
@ -670,6 +667,20 @@ cc-cross-prefix
|
||||
endif
|
||||
endif
|
||||
|
||||
$(RUSTC) support functions
|
||||
--------------------------
|
||||
|
||||
rustc-min-version
|
||||
rustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater
|
||||
than or equal to the provided value and evaluates to y if so.
|
||||
|
||||
Example::
|
||||
|
||||
rustflags-$(call rustc-min-version, 108500) := -Cfoo
|
||||
|
||||
In this example, rustflags-y will be assigned the value -Cfoo if
|
||||
$(CONFIG_RUSTC_VERSION) is >= 1.85.0.
|
||||
|
||||
$(LD) support functions
|
||||
-----------------------
|
||||
|
||||
|
@ -318,7 +318,7 @@ Several Subdirectories
|
||||
| |__ include
|
||||
| |__ hardwareif.h
|
||||
|__ include
|
||||
|__ complex.h
|
||||
|__ complex.h
|
||||
|
||||
To build the module complex.ko, we then need the following
|
||||
kbuild file::
|
||||
|
@ -46,21 +46,6 @@ The kernel embeds the building user and host names in
|
||||
`KBUILD_BUILD_USER and KBUILD_BUILD_HOST`_ variables. If you are
|
||||
building from a git commit, you could use its committer address.
|
||||
|
||||
Absolute filenames
|
||||
------------------
|
||||
|
||||
When the kernel is built out-of-tree, debug information may include
|
||||
absolute filenames for the source files. This must be overridden by
|
||||
including the ``-fdebug-prefix-map`` option in the `KCFLAGS`_ variable.
|
||||
|
||||
Depending on the compiler used, the ``__FILE__`` macro may also expand
|
||||
to an absolute filename in an out-of-tree build. Kbuild automatically
|
||||
uses the ``-fmacro-prefix-map`` option to prevent this, if it is
|
||||
supported.
|
||||
|
||||
The Reproducible Builds web site has more information about these
|
||||
`prefix-map options`_.
|
||||
|
||||
Generated files in source packages
|
||||
----------------------------------
|
||||
|
||||
@ -131,7 +116,5 @@ See ``scripts/setlocalversion`` for details.
|
||||
|
||||
.. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp
|
||||
.. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host
|
||||
.. _KCFLAGS: kbuild.html#kcflags
|
||||
.. _prefix-map options: https://reproducible-builds.org/docs/build-path/
|
||||
.. _Reproducible Builds project: https://reproducible-builds.org/
|
||||
.. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/
|
||||
|
@ -12850,6 +12850,7 @@ F: Makefile
|
||||
F: scripts/*vmlinux*
|
||||
F: scripts/Kbuild*
|
||||
F: scripts/Makefile*
|
||||
F: scripts/bash-completion/
|
||||
F: scripts/basic/
|
||||
F: scripts/clang-tools/
|
||||
F: scripts/dummy-tools/
|
||||
|
23
Makefile
23
Makefile
@ -151,9 +151,6 @@ endif
|
||||
|
||||
export KBUILD_EXTMOD
|
||||
|
||||
# backward compatibility
|
||||
KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
|
||||
|
||||
ifeq ("$(origin W)", "command line")
|
||||
KBUILD_EXTRA_WARN := $(W)
|
||||
endif
|
||||
@ -928,6 +925,9 @@ KBUILD_CFLAGS += $(CC_AUTO_VAR_INIT_ZERO_ENABLER)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Explicitly clear padding bits during variable initialization
|
||||
KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
|
||||
|
||||
# While VLAs have been removed, GCC produces unreachable stack probes
|
||||
# for the randomize_kstack_offset feature. Disable it for all compilers.
|
||||
KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
|
||||
@ -1070,7 +1070,8 @@ endif
|
||||
|
||||
# change __FILE__ to the relative path to the source directory
|
||||
ifdef building_out_of_srctree
|
||||
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
|
||||
KBUILD_CPPFLAGS += $(call cc-option,-ffile-prefix-map=$(srcroot)/=)
|
||||
KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/=
|
||||
endif
|
||||
|
||||
# include additional Makefiles when needed
|
||||
@ -1122,6 +1123,10 @@ ifdef CONFIG_LD_ORPHAN_WARN
|
||||
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),)
|
||||
LDFLAGS_vmlinux += --emit-relocs --discard-none
|
||||
endif
|
||||
|
||||
# Align the bit size of userspace programs with the kernel
|
||||
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
|
||||
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
|
||||
@ -1364,9 +1369,12 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
|
||||
|
||||
PHONY += headers
|
||||
headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
|
||||
$(if $(filter um, $(SRCARCH)), $(error Headers not exportable for UML))
|
||||
ifdef HEADER_ARCH
|
||||
$(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
|
||||
else
|
||||
$(Q)$(MAKE) $(hdr-inst)=include/uapi
|
||||
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
|
||||
endif
|
||||
|
||||
ifdef CONFIG_HEADERS_INSTALL
|
||||
prepare: headers
|
||||
@ -1564,7 +1572,7 @@ endif # CONFIG_MODULES
|
||||
# Directories & files removed with 'make clean'
|
||||
CLEAN_FILES += vmlinux.symvers modules-only.symvers \
|
||||
modules.builtin modules.builtin.modinfo modules.nsdeps \
|
||||
modules.builtin.ranges vmlinux.o.map \
|
||||
modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
|
||||
compile_commands.json rust/test \
|
||||
rust-project.json .vmlinux.objs .vmlinux.export.c \
|
||||
.builtin-dtbs-list .builtin-dtb.S
|
||||
@ -1667,7 +1675,8 @@ help:
|
||||
@echo ' kernelrelease - Output the release version string (use with make -s)'
|
||||
@echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
|
||||
@echo ' image_name - Output the image name (use with make -s)'
|
||||
@echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
|
||||
@echo ' headers - Build ready-to-install UAPI headers in usr/include'
|
||||
@echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \
|
||||
echo ' (default: $(INSTALL_HDR_PATH))'; \
|
||||
echo ''
|
||||
@echo 'Static analysers:'
|
||||
|
@ -1699,6 +1699,13 @@ config ARCH_HAS_KERNEL_FPU_SUPPORT
|
||||
Architectures that select this option can run floating-point code in
|
||||
the kernel, as described in Documentation/core-api/floating-point.rst.
|
||||
|
||||
config ARCH_VMLINUX_NEEDS_RELOCS
|
||||
bool
|
||||
help
|
||||
Whether the architecture needs vmlinux to be built with static
|
||||
relocations preserved. This is used by some architectures to
|
||||
construct bespoke relocation tables for KASLR.
|
||||
|
||||
source "kernel/gcov/Kconfig"
|
||||
|
||||
source "scripts/gcc-plugins/Kconfig"
|
||||
|
@ -48,7 +48,7 @@ KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
|
||||
KBUILD_AFLAGS += $(compat_vdso)
|
||||
|
||||
ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y)
|
||||
ifeq ($(call rustc-min-version, 108500),y)
|
||||
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat
|
||||
else
|
||||
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"
|
||||
|
@ -2618,6 +2618,7 @@ config RELOCATABLE
|
||||
CPU_MIPS32_R6 || CPU_MIPS64_R6 || \
|
||||
CPU_P5600 || CAVIUM_OCTEON_SOC || \
|
||||
CPU_LOONGSON64
|
||||
select ARCH_VMLINUX_NEEDS_RELOCS
|
||||
help
|
||||
This builds a kernel image that retains relocation information
|
||||
so it can be loaded someplace besides the default 1MB.
|
||||
|
@ -100,10 +100,6 @@ LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
|
||||
KBUILD_AFLAGS_MODULE += -mlong-calls
|
||||
KBUILD_CFLAGS_MODULE += -mlong-calls
|
||||
|
||||
ifeq ($(CONFIG_RELOCATABLE),y)
|
||||
LDFLAGS_vmlinux += --emit-relocs
|
||||
endif
|
||||
|
||||
cflags-y += -ffreestanding
|
||||
|
||||
cflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
|
||||
|
@ -22,7 +22,7 @@ quiet_cmd_relocs = RELOCS $@
|
||||
|
||||
# `@true` prevents complaint when there is nothing to be done
|
||||
|
||||
vmlinux: FORCE
|
||||
vmlinux vmlinux.unstripped: FORCE
|
||||
@true
|
||||
ifeq ($(CONFIG_CPU_LOONGSON3_WORKAROUNDS),y)
|
||||
$(call if_changed,ls3_llsc)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
obj-y += kernel/ mm/ platform/ boot/dts/
|
||||
obj-y += kernel/ mm/ platform/
|
||||
|
||||
# for cleaning
|
||||
subdir- += boot
|
||||
|
@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
obj-y := $(patsubst %.dts,%.dtb.o,$(CONFIG_NIOS2_DTB_SOURCE))
|
||||
dtb-y := $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME))
|
||||
|
||||
dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
|
||||
dtb-$(CONFIG_OF_ALL_DTBS) += $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
|
||||
|
@ -32,7 +32,7 @@ void __init early_init_devtree(void *params)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NIOS2_DTB_SOURCE_BOOL
|
||||
#ifdef CONFIG_BUILTIN_DTB
|
||||
if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
|
||||
params = (void *)__dtb_start;
|
||||
#endif
|
||||
|
@ -35,19 +35,20 @@ config NIOS2_DTB_PHYS_ADDR
|
||||
help
|
||||
Physical address of a dtb blob.
|
||||
|
||||
config NIOS2_DTB_SOURCE_BOOL
|
||||
config BUILTIN_DTB
|
||||
bool "Compile and link device tree into kernel image"
|
||||
depends on !COMPILE_TEST
|
||||
select GENERIC_BUILTIN_DTB
|
||||
help
|
||||
This allows you to specify a dts (device tree source) file
|
||||
which will be compiled and linked into the kernel image.
|
||||
|
||||
config NIOS2_DTB_SOURCE
|
||||
string "Device tree source file"
|
||||
depends on NIOS2_DTB_SOURCE_BOOL
|
||||
config BUILTIN_DTB_NAME
|
||||
string "Built-in device tree name"
|
||||
depends on BUILTIN_DTB
|
||||
default ""
|
||||
help
|
||||
Absolute path to the device tree source (dts) file describing your
|
||||
Relative path to the device tree without suffix describing your
|
||||
system.
|
||||
|
||||
comment "Nios II instructions"
|
||||
|
@ -1108,6 +1108,7 @@ config RELOCATABLE
|
||||
bool "Build a relocatable kernel"
|
||||
depends on !XIP_KERNEL
|
||||
select MODULE_SECTIONS if MODULES
|
||||
select ARCH_VMLINUX_NEEDS_RELOCS
|
||||
help
|
||||
This builds a kernel as a Position Independent Executable (PIE),
|
||||
which retains all relocation metadata required to relocate the
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
LDFLAGS_vmlinux := -z norelro
|
||||
ifeq ($(CONFIG_RELOCATABLE),y)
|
||||
LDFLAGS_vmlinux += -shared -Bsymbolic -z notext --emit-relocs
|
||||
LDFLAGS_vmlinux += -shared -Bsymbolic -z notext
|
||||
KBUILD_CFLAGS += -fPIE
|
||||
endif
|
||||
ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
|
||||
|
@ -10,26 +10,17 @@ __archpost:
|
||||
|
||||
-include include/config/auto.conf
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
quiet_cmd_relocs_check = CHKREL $@
|
||||
cmd_relocs_check = \
|
||||
$(CONFIG_SHELL) $(srctree)/arch/riscv/tools/relocs_check.sh "$(OBJDUMP)" "$(NM)" "$@"
|
||||
|
||||
ifdef CONFIG_RELOCATABLE
|
||||
quiet_cmd_cp_vmlinux_relocs = CPREL vmlinux.relocs
|
||||
cmd_cp_vmlinux_relocs = cp vmlinux vmlinux.relocs
|
||||
|
||||
endif
|
||||
|
||||
# `@true` prevents complaint when there is nothing to be done
|
||||
|
||||
vmlinux: FORCE
|
||||
vmlinux vmlinux.unstripped: FORCE
|
||||
@true
|
||||
ifdef CONFIG_RELOCATABLE
|
||||
$(call if_changed,relocs_check)
|
||||
$(call if_changed,cp_vmlinux_relocs)
|
||||
$(call if_changed,strip_relocs)
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
@ -32,10 +32,7 @@ $(obj)/xipImage: vmlinux FORCE
|
||||
endif
|
||||
|
||||
ifdef CONFIG_RELOCATABLE
|
||||
vmlinux.relocs: vmlinux
|
||||
@ (! [ -f vmlinux.relocs ] && echo "vmlinux.relocs can't be found, please remove vmlinux and try again") || true
|
||||
|
||||
$(obj)/Image: vmlinux.relocs FORCE
|
||||
$(obj)/Image: vmlinux.unstripped FORCE
|
||||
else
|
||||
$(obj)/Image: vmlinux FORCE
|
||||
endif
|
||||
|
@ -631,6 +631,7 @@ endchoice
|
||||
|
||||
config RELOCATABLE
|
||||
def_bool y
|
||||
select ARCH_VMLINUX_NEEDS_RELOCS
|
||||
help
|
||||
This builds a kernel image that retains relocation information
|
||||
so it can be loaded at an arbitrary address.
|
||||
|
@ -15,7 +15,7 @@ KBUILD_CFLAGS_MODULE += -fPIC
|
||||
KBUILD_AFLAGS += -m64
|
||||
KBUILD_CFLAGS += -m64
|
||||
KBUILD_CFLAGS += -fPIC
|
||||
LDFLAGS_vmlinux := $(call ld-option,-no-pie) --emit-relocs --discard-none
|
||||
LDFLAGS_vmlinux := $(call ld-option,-no-pie)
|
||||
extra_tools := relocs
|
||||
aflags_dwarf := -Wa,-gdwarf-2
|
||||
KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
|
||||
|
@ -11,7 +11,6 @@ __archpost:
|
||||
|
||||
-include include/config/auto.conf
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
CMD_RELOCS=arch/s390/tools/relocs
|
||||
OUT_RELOCS = arch/s390/boot
|
||||
@ -20,9 +19,8 @@ quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/relocs.S
|
||||
mkdir -p $(OUT_RELOCS); \
|
||||
$(CMD_RELOCS) $@ > $(OUT_RELOCS)/relocs.S
|
||||
|
||||
vmlinux: FORCE
|
||||
vmlinux.unstripped: FORCE
|
||||
$(call cmd,relocs)
|
||||
$(call cmd,strip_relocs)
|
||||
|
||||
clean:
|
||||
@rm -f $(OUT_RELOCS)/relocs.S
|
||||
|
@ -2138,6 +2138,7 @@ config RANDOMIZE_BASE
|
||||
config X86_NEED_RELOCS
|
||||
def_bool y
|
||||
depends on RANDOMIZE_BASE || (X86_32 && RELOCATABLE)
|
||||
select ARCH_VMLINUX_NEEDS_RELOCS
|
||||
|
||||
config PHYSICAL_ALIGN
|
||||
hex "Alignment value to which kernel should be aligned"
|
||||
|
@ -245,12 +245,6 @@ endif
|
||||
|
||||
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
|
||||
|
||||
ifdef CONFIG_X86_NEED_RELOCS
|
||||
LDFLAGS_vmlinux := --emit-relocs --discard-none
|
||||
else
|
||||
LDFLAGS_vmlinux :=
|
||||
endif
|
||||
|
||||
#
|
||||
# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
|
||||
# the linker to force 2MB page size regardless of the default page size used
|
||||
|
@ -1,40 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# ===========================================================================
|
||||
# Post-link x86 pass
|
||||
# ===========================================================================
|
||||
#
|
||||
# 1. Separate relocations from vmlinux into vmlinux.relocs.
|
||||
# 2. Strip relocations from vmlinux.
|
||||
|
||||
PHONY := __archpost
|
||||
__archpost:
|
||||
|
||||
-include include/config/auto.conf
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
CMD_RELOCS = arch/x86/tools/relocs
|
||||
OUT_RELOCS = arch/x86/boot/compressed
|
||||
quiet_cmd_relocs = RELOCS $(OUT_RELOCS)/$@.relocs
|
||||
cmd_relocs = \
|
||||
mkdir -p $(OUT_RELOCS); \
|
||||
$(CMD_RELOCS) $@ > $(OUT_RELOCS)/$@.relocs; \
|
||||
$(CMD_RELOCS) --abs-relocs $@
|
||||
|
||||
# `@true` prevents complaint when there is nothing to be done
|
||||
|
||||
vmlinux: FORCE
|
||||
@true
|
||||
ifeq ($(CONFIG_X86_NEED_RELOCS),y)
|
||||
$(call cmd,relocs)
|
||||
$(call cmd,strip_relocs)
|
||||
endif
|
||||
|
||||
clean:
|
||||
@rm -f $(OUT_RELOCS)/vmlinux.relocs
|
||||
|
||||
PHONY += FORCE clean
|
||||
|
||||
FORCE:
|
||||
|
||||
.PHONY: $(PHONY)
|
@ -53,7 +53,6 @@ targets += cpustr.h
|
||||
|
||||
KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
|
||||
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
|
||||
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
|
||||
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
|
||||
KBUILD_CFLAGS += $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
|
||||
|
||||
|
@ -38,7 +38,6 @@ KBUILD_CFLAGS += -fno-stack-protector
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
|
||||
KBUILD_CFLAGS += -Wno-pointer-sign
|
||||
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
|
||||
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
|
||||
KBUILD_CFLAGS += -D__DISABLE_EXPORTS
|
||||
# Disable relocation relaxation in case the link is not PIE.
|
||||
@ -117,9 +116,12 @@ $(obj)/vmlinux.bin: vmlinux FORCE
|
||||
|
||||
targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
|
||||
|
||||
# vmlinux.relocs is created by the vmlinux postlink step.
|
||||
$(obj)/vmlinux.relocs: vmlinux
|
||||
@true
|
||||
CMD_RELOCS = arch/x86/tools/relocs
|
||||
quiet_cmd_relocs = RELOCS $@
|
||||
cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
|
||||
|
||||
$(obj)/vmlinux.relocs: vmlinux.unstripped FORCE
|
||||
$(call if_changed,relocs)
|
||||
|
||||
vmlinux.bin.all-y := $(obj)/vmlinux.bin
|
||||
vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
|
||||
|
@ -89,7 +89,6 @@ rm -f "${tmpdir}.contents.txt"
|
||||
|
||||
# Create archive and try to normalize metadata for reproducibility.
|
||||
tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \
|
||||
--exclude=".__afs*" --exclude=".nfs*" \
|
||||
--owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X \
|
||||
-I $XZ -cf $tarfile -C "${tmpdir}/" . > /dev/null
|
||||
|
||||
|
@ -335,12 +335,12 @@ config DEBUG_INFO_COMPRESSED_ZLIB
|
||||
Compress the debug information using zlib. Requires GCC 5.0+ or Clang
|
||||
5.0+, binutils 2.26+, and zlib.
|
||||
|
||||
Users of dpkg-deb via scripts/package/builddeb may find an increase in
|
||||
Users of dpkg-deb via debian/rules may find an increase in
|
||||
size of their debug .deb packages with this config set, due to the
|
||||
debug info being compressed with zlib, then the object files being
|
||||
recompressed with a different compression scheme. But this is still
|
||||
preferable to setting $KDEB_COMPRESS to "none" which would be even
|
||||
larger.
|
||||
preferable to setting KDEB_COMPRESS or DPKG_DEB_COMPRESSOR_TYPE to
|
||||
"none" which would be even larger.
|
||||
|
||||
config DEBUG_INFO_COMPRESSED_ZSTD
|
||||
bool "Compress debugging information with zstd"
|
||||
@ -473,7 +473,6 @@ config READABLE_ASM
|
||||
|
||||
config HEADERS_INSTALL
|
||||
bool "Install uapi headers to usr/include"
|
||||
depends on !UML
|
||||
help
|
||||
This option will install uapi headers (headers exported to user-space)
|
||||
into the usr/include directory for use during the kernel build.
|
||||
|
@ -60,10 +60,14 @@ endif
|
||||
core-cfgs = \
|
||||
--cfg no_fp_fmt_parse
|
||||
|
||||
# `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
|
||||
# since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
|
||||
# 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
|
||||
# issues skipping the flag. The former also applies to `RUSTDOC TK`.
|
||||
quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
|
||||
cmd_rustdoc = \
|
||||
OBJTREE=$(abspath $(objtree)) \
|
||||
$(RUSTDOC) $(filter-out $(skip_flags),$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
|
||||
$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
|
||||
$(rustc_target_flags) -L$(objtree)/$(obj) \
|
||||
-Zunstable-options --generate-link-to-definition \
|
||||
--output $(rustdoc_output) \
|
||||
@ -199,7 +203,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
|
||||
rm -rf $(objtree)/$(obj)/test/doctests/kernel; \
|
||||
mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \
|
||||
OBJTREE=$(abspath $(objtree)) \
|
||||
$(RUSTDOC) --test $(rust_flags) \
|
||||
$(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \
|
||||
-L$(objtree)/$(obj) --extern ffi --extern pin_init \
|
||||
--extern kernel --extern build_error --extern macros \
|
||||
--extern bindings --extern uapi \
|
||||
|
@ -20,10 +20,6 @@ always-m :=
|
||||
targets :=
|
||||
subdir-y :=
|
||||
subdir-m :=
|
||||
EXTRA_AFLAGS :=
|
||||
EXTRA_CFLAGS :=
|
||||
EXTRA_CPPFLAGS :=
|
||||
EXTRA_LDFLAGS :=
|
||||
asflags-y :=
|
||||
ccflags-y :=
|
||||
rustflags-y :=
|
||||
|
@ -67,6 +67,10 @@ gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
|
||||
# Usage: cflags-$(call clang-min-version, 110000) += -foo
|
||||
clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
|
||||
|
||||
# rustc-min-version
|
||||
# Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo
|
||||
rustc-min-version = $(call test-ge, $(CONFIG_RUSTC_VERSION), $1)
|
||||
|
||||
# ld-option
|
||||
# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
|
||||
ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
|
||||
|
@ -82,9 +82,6 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
|
||||
# Warn if there is an enum types mismatch
|
||||
KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
|
||||
|
||||
# Explicitly clear padding bits during variable initialization
|
||||
KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
|
||||
|
||||
KBUILD_CFLAGS += -Wextra
|
||||
KBUILD_CFLAGS += -Wunused
|
||||
|
||||
|
@ -1,9 +1,4 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Backward compatibility
|
||||
asflags-y += $(EXTRA_AFLAGS)
|
||||
ccflags-y += $(EXTRA_CFLAGS)
|
||||
cppflags-y += $(EXTRA_CPPFLAGS)
|
||||
ldflags-y += $(EXTRA_LDFLAGS)
|
||||
|
||||
# flags that take effect in current and sub directories
|
||||
KBUILD_AFLAGS += $(subdir-asflags-y)
|
||||
@ -377,9 +372,6 @@ quiet_cmd_ar = AR $@
|
||||
quiet_cmd_objcopy = OBJCOPY $@
|
||||
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
|
||||
|
||||
quiet_cmd_strip_relocs = RSTRIP $@
|
||||
cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' $@
|
||||
|
||||
# Gzip
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
@ -9,6 +9,20 @@ include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
targets :=
|
||||
|
||||
ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS
|
||||
vmlinux-final := vmlinux.unstripped
|
||||
|
||||
quiet_cmd_strip_relocs = RSTRIP $@
|
||||
cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' $< $@
|
||||
|
||||
vmlinux: $(vmlinux-final) FORCE
|
||||
$(call if_changed,strip_relocs)
|
||||
|
||||
targets += vmlinux
|
||||
else
|
||||
vmlinux-final := vmlinux
|
||||
endif
|
||||
|
||||
%.o: %.c FORCE
|
||||
$(call if_changed_rule,cc_o_c)
|
||||
|
||||
@ -47,7 +61,7 @@ targets += .builtin-dtbs-list
|
||||
|
||||
ifdef CONFIG_GENERIC_BUILTIN_DTB
|
||||
targets += .builtin-dtbs.S .builtin-dtbs.o
|
||||
vmlinux: .builtin-dtbs.o
|
||||
$(vmlinux-final): .builtin-dtbs.o
|
||||
endif
|
||||
|
||||
# vmlinux
|
||||
@ -55,11 +69,11 @@ endif
|
||||
|
||||
ifdef CONFIG_MODULES
|
||||
targets += .vmlinux.export.o
|
||||
vmlinux: .vmlinux.export.o
|
||||
$(vmlinux-final): .vmlinux.export.o
|
||||
endif
|
||||
|
||||
ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX
|
||||
vmlinux: arch/$(SRCARCH)/tools/vmlinux.arch.o
|
||||
$(vmlinux-final): arch/$(SRCARCH)/tools/vmlinux.arch.o
|
||||
|
||||
arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE
|
||||
$(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@
|
||||
@ -69,14 +83,18 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
|
||||
|
||||
# Final link of vmlinux with optional arch pass after final link
|
||||
cmd_link_vmlinux = \
|
||||
$< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
|
||||
$< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \
|
||||
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
|
||||
|
||||
targets += vmlinux
|
||||
vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
|
||||
targets += $(vmlinux-final)
|
||||
$(vmlinux-final): scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
|
||||
+$(call if_changed_dep,link_vmlinux)
|
||||
ifdef CONFIG_DEBUG_INFO_BTF
|
||||
vmlinux: $(RESOLVE_BTFIDS)
|
||||
$(vmlinux-final): $(RESOLVE_BTFIDS)
|
||||
endif
|
||||
|
||||
ifdef CONFIG_BUILDTIME_TABLE_SORT
|
||||
vmlinux: scripts/sorttable
|
||||
endif
|
||||
|
||||
# module.builtin.ranges
|
||||
@ -92,7 +110,7 @@ modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \
|
||||
modules.builtin vmlinux.map vmlinux.o.map FORCE
|
||||
$(call if_changed,modules_builtin_ranges)
|
||||
|
||||
vmlinux.map: vmlinux
|
||||
vmlinux.map: $(vmlinux-final)
|
||||
@:
|
||||
|
||||
endif
|
||||
|
451
scripts/bash-completion/make
Normal file
451
scripts/bash-completion/make
Normal file
@ -0,0 +1,451 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# bash completion for GNU make with kbuild extension -*- shell-script -*-
|
||||
|
||||
# Load the default completion script for make. It is typically located at
|
||||
# /usr/share/bash-completion/completions/make, but we do not rely on it.
|
||||
__kbuild_load_default_make_completion()
|
||||
{
|
||||
local -a dirs=("${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions")
|
||||
local ifs=$IFS IFS=: dir compfile this_dir
|
||||
|
||||
for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do
|
||||
dirs+=("$dir"/bash-completion/completions)
|
||||
done
|
||||
IFS=$ifs
|
||||
|
||||
this_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
for dir in "${dirs[@]}"; do
|
||||
if [[ ! -d ${dir} || ${dir} = "${this_dir}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
for compfile in make make.bash _make; do
|
||||
compfile=$dir/$compfile
|
||||
# Avoid trying to source dirs; https://bugzilla.redhat.com/903540
|
||||
if [[ -f ${compfile} ]] && . "${compfile}" &>/dev/null; then
|
||||
|
||||
__kbuild_default_make_completion=$(
|
||||
# shellcheck disable=SC2046 # word splitting is the point here
|
||||
set -- $(complete -p make)
|
||||
|
||||
while [[ $# -gt 1 && "$1" != -F ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ "$1" = -F ]]; then
|
||||
echo "$2"
|
||||
fi
|
||||
)
|
||||
|
||||
return
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
__kbuild_load_default_make_completion
|
||||
|
||||
__kbuild_handle_variable()
|
||||
{
|
||||
local var=${1%%=*}
|
||||
local cur=${cur#"${var}"=}
|
||||
local srctree=$2
|
||||
local keywords=()
|
||||
|
||||
case $var in
|
||||
ARCH)
|
||||
# sub-directories under arch/
|
||||
keywords+=($(find "${srctree}/arch" -mindepth 1 -maxdepth 1 -type d -printf '%P\n'))
|
||||
# architectures hard-coded in the top Makefile
|
||||
keywords+=(i386 x86_64 sparc32 sparc64 parisc64)
|
||||
;;
|
||||
CROSS_COMPILE)
|
||||
# toolchains with a full path
|
||||
local cross_compile=()
|
||||
local c c2
|
||||
_filedir
|
||||
|
||||
for c in "${COMPREPLY[@]}"; do
|
||||
# eval for tilde expansion
|
||||
# suppress error, as this fails when it contains a space
|
||||
eval "c2=${c}" 2>/dev/null || continue
|
||||
if [[ ${c} == *-elfedit && ! -d ${c2} && -x ${c2} ]]; then
|
||||
cross_compile+=("${c%elfedit}")
|
||||
fi
|
||||
done
|
||||
|
||||
# toolchains in the PATH environment
|
||||
while read -r c; do
|
||||
if [[ ${c} == *-elfedit ]]; then
|
||||
keywords+=("${c%elfedit}")
|
||||
fi
|
||||
done < <(compgen -c)
|
||||
|
||||
COMPREPLY=()
|
||||
_filedir -d
|
||||
|
||||
# Add cross_compile directly without passing it to compgen.
|
||||
# Otherwise, toolchain paths with a tilde do not work.
|
||||
# e.g.)
|
||||
# CROSS_COMPILE=~/0day/gcc-14.2.0-nolibc/aarch64-linux/bin/aarch64-linux-
|
||||
COMPREPLY+=("${cross_compile[@]}")
|
||||
;;
|
||||
LLVM)
|
||||
# LLVM=1 uses the default 'clang' etc.
|
||||
keywords+=(1)
|
||||
|
||||
# suffix for a particular version. LLVM=-18 uses 'clang-18' etc.
|
||||
while read -r c; do
|
||||
if [[ ${c} == clang-[0-9]* ]]; then
|
||||
keywords+=("${c#clang}")
|
||||
fi
|
||||
done < <(compgen -c)
|
||||
|
||||
# directory path to LLVM toolchains
|
||||
_filedir -d
|
||||
;;
|
||||
KCONFIG_ALLCONFIG)
|
||||
# KCONFIG_ALLCONFIG=1 selects the default fragment
|
||||
keywords+=(1)
|
||||
# or the path to a fragment file
|
||||
_filedir
|
||||
;;
|
||||
C | KBUILD_CHECKSRC)
|
||||
keywords+=(1 2)
|
||||
;;
|
||||
V | KBUILD_VERBOSE)
|
||||
keywords+=({,1}{,2})
|
||||
;;
|
||||
W | KBUILD_EXTRA_WARN)
|
||||
keywords+=({,1}{,2}{,3}{,c}{,e})
|
||||
;;
|
||||
KBUILD_ABS_SRCTREE | KBUILD_MODPOST_NOFINAL | KBUILD_MODPOST_WARN | \
|
||||
CLIPPY | KBUILD_CLIPPY | KCONFIG_NOSILENTUPDATE | \
|
||||
KCONFIG_OVERWRITECONFIG | KCONFIG_WARN_UNKNOWN_SYMBOL | \
|
||||
KCONFIG_WERROR )
|
||||
keywords+=(1)
|
||||
;;
|
||||
INSTALL_MOD_STRIP)
|
||||
keywords+=(1 --strip-debug --strip-unneeded)
|
||||
;;
|
||||
O | KBUILD_OUTPUT | M | KBUILD_EXTMOD | MO | KBUILD_EXTMOD_OUTPUT | *_PATH)
|
||||
# variables that take a directory.
|
||||
_filedir -d
|
||||
return
|
||||
;;
|
||||
KBUILD_EXTRA_SYMBOL | KBUILD_KCONFIG | KCONFIG_CONFIG)
|
||||
# variables that take a file.
|
||||
_filedir
|
||||
return
|
||||
esac
|
||||
|
||||
COMPREPLY+=($(compgen -W "${keywords[*]}" -- "${cur}"))
|
||||
}
|
||||
|
||||
# Check the -C, -f options and 'source' symlink. Return the source tree we are
|
||||
# working in.
|
||||
__kbuild_get_srctree()
|
||||
{
|
||||
local words=("$@")
|
||||
local cwd makef_dir
|
||||
|
||||
# see if a path was specified with -C/--directory
|
||||
for ((i = 1; i < ${#words[@]}; i++)); do
|
||||
if [[ ${words[i]} == -@(C|-directory) ]]; then
|
||||
# eval for tilde expansion.
|
||||
# suppress error, as this fails when it contains a space
|
||||
eval "cwd=${words[i + 1]}" 2>/dev/null
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z ${cwd} ]]; then
|
||||
cwd=.
|
||||
fi
|
||||
|
||||
# see if a Makefile was specified with -f/--file/--makefile
|
||||
for ((i = 1; i < ${#words[@]}; i++)); do
|
||||
if [[ ${words[i]} == -@(f|-?(make)file) ]]; then
|
||||
# eval for tilde expansion
|
||||
# suppress error, as this fails when it contains a space
|
||||
eval "makef_dir=${words[i + 1]%/*}" 2>/dev/null
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "${makef_dir}" ]; then
|
||||
makef_dir=${cwd}
|
||||
elif [[ ${makef_dir} != /* ]]; then
|
||||
makef_dir=${cwd}/${makef_dir}
|
||||
fi
|
||||
|
||||
# If ${makef_dir} is a build directory created by the O= option, there
|
||||
# is a symbolic link 'source', which points to the kernel source tree.
|
||||
if [[ -L ${makef_dir}/source ]]; then
|
||||
makef_dir=$(readlink "${makef_dir}/source")
|
||||
fi
|
||||
|
||||
echo "${makef_dir}"
|
||||
}
|
||||
|
||||
# Get SRCARCH to do a little more clever things
|
||||
__kbuild_get_srcarch()
|
||||
{
|
||||
local words=("$@")
|
||||
local arch srcarch uname_m
|
||||
|
||||
# see if ARCH= is explicitly specified
|
||||
for ((i = 1; i < ${#words[@]}; i++)); do
|
||||
if [[ ${words[i]} == ARCH=* ]]; then
|
||||
arch=${words[i]#ARCH=}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# If ARCH= is not specified, check the build marchine's architecture
|
||||
if [[ -z ${arch} ]]; then
|
||||
uname_m=$(uname -m)
|
||||
|
||||
# shellcheck disable=SC2209 # 'sh' is SuperH, not a shell command
|
||||
case ${uname_m} in
|
||||
arm64 | aarch64*) arch=arm64 ;;
|
||||
arm* | sa110) arch=arm ;;
|
||||
i?86 | x86_64) arch=x86 ;;
|
||||
loongarch*) arch=loongarch ;;
|
||||
mips*) arch=mips ;;
|
||||
ppc*) arch=powerpc ;;
|
||||
riscv*) arch=riscv ;;
|
||||
s390x) arch=s390 ;;
|
||||
sh[234]*) arch=sh ;;
|
||||
sun4u) arch=sparc64 ;;
|
||||
*) arch=${uname_m} ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case ${arch} in
|
||||
parisc64) srcarch=parisc ;;
|
||||
sparc32 | sparc64) srcarch=sparc ;;
|
||||
i386 | x86_64) srcarch=x86 ;;
|
||||
*) srcarch=${arch} ;;
|
||||
esac
|
||||
|
||||
echo "$srcarch"
|
||||
}
|
||||
|
||||
# small Makefile to parse obj-* syntax
|
||||
__kbuild_tmp_makefile()
|
||||
{
|
||||
cat <<'EOF'
|
||||
.PHONY: __default
|
||||
__default:
|
||||
$(foreach m,$(obj-y) $(obj-m) $(obj-),$(foreach s, -objs -y -m -,$($(m:%.o=%$s))) $(m))
|
||||
EOF
|
||||
echo "include ${1}"
|
||||
}
|
||||
|
||||
_make_for_kbuild ()
|
||||
{
|
||||
# shellcheck disable=SC2034 # these are set by _init_completion
|
||||
local cur prev words cword split
|
||||
_init_completion -s || return
|
||||
|
||||
local srctree
|
||||
srctree=$(__kbuild_get_srctree "${words[@]}")
|
||||
|
||||
# If 'kernel' and 'Documentation' directories are found, we assume this
|
||||
# is a kernel tree. Otherwise, we fall back to the generic rule provided
|
||||
# by the bash-completion project.
|
||||
if [[ ! -d ${srctree}/kernel || ! -d ${srctree}/Documentation ]]; then
|
||||
if [ -n "${__kbuild_default_make_completion}" ]; then
|
||||
"${__kbuild_default_make_completion}" "$@"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
# make options with a parameter (copied from the bash-completion project)
|
||||
case ${prev} in
|
||||
--file | --makefile | --old-file | --assume-old | --what-if | --new-file | \
|
||||
--assume-new | -!(-*)[foW])
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
--include-dir | --directory | -!(-*)[ICm])
|
||||
_filedir -d
|
||||
return
|
||||
;;
|
||||
-!(-*)E)
|
||||
COMPREPLY=($(compgen -v -- "$cur"))
|
||||
return
|
||||
;;
|
||||
--eval | -!(-*)[DVx])
|
||||
return
|
||||
;;
|
||||
--jobs | -!(-*)j)
|
||||
COMPREPLY=($(compgen -W "{1..$(($(_ncpus) * 2))}" -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
local keywords=()
|
||||
|
||||
case ${cur} in
|
||||
-*)
|
||||
# make options (copied from the bash-completion project)
|
||||
local opts
|
||||
opts="$(_parse_help "$1")"
|
||||
COMPREPLY=($(compgen -W "${opts:-$(_parse_usage "$1")}" -- "$cur"))
|
||||
if [[ ${COMPREPLY-} == *= ]]; then
|
||||
compopt -o nospace
|
||||
fi
|
||||
return
|
||||
;;
|
||||
*=*)
|
||||
__kbuild_handle_variable "${cur}" "${srctree}"
|
||||
return
|
||||
;;
|
||||
KBUILD_*)
|
||||
# There are many variables prefixed with 'KBUILD_'.
|
||||
# Display them only when 'KBUILD_' is entered.
|
||||
# shellcheck disable=SC2191 # '=' is appended for variables
|
||||
keywords+=(
|
||||
KBUILD_{CHECKSRC,EXTMOD,EXTMOD_OUTPUT,OUTPUT,VERBOSE,EXTRA_WARN,CLIPPY}=
|
||||
KBUILD_BUILD_{USER,HOST,TIMESTAMP}=
|
||||
KBUILD_MODPOST_{NOFINAL,WARN}=
|
||||
KBUILD_{ABS_SRCTREE,EXTRA_SYMBOLS,KCONFIG}=
|
||||
)
|
||||
;;
|
||||
KCONFIG_*)
|
||||
# There are many variables prefixed with 'KCONFIG_'.
|
||||
# Display them only when 'KCONFIG_' is entered.
|
||||
# shellcheck disable=SC2191 # '=' is appended for variables
|
||||
keywords+=(
|
||||
KCONFIG_{CONFIG,ALLCONFIG,NOSILENTUPDATE,OVERWRITECONFIG}=
|
||||
KCONFIG_{SEED,PROBABILITY}=
|
||||
KCONFIG_WARN_UNKNOWN_SYMBOL=
|
||||
KCONFIG_WERROR=
|
||||
)
|
||||
;;
|
||||
*)
|
||||
# By default, hide KBUILD_* and KCONFIG_* variables.
|
||||
# Instead, display only the prefix parts.
|
||||
keywords+=(KBUILD_ KCONFIG_)
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ${cur} != /* && ${cur} != *//* ]]; then
|
||||
local dir srcarch kbuild_file tmp
|
||||
srcarch=$(__kbuild_get_srcarch "${words[@]}")
|
||||
|
||||
# single build
|
||||
dir=${cur}
|
||||
while true; do
|
||||
if [[ ${dir} == */* ]]; then
|
||||
dir=${dir%/*}
|
||||
else
|
||||
dir=.
|
||||
fi
|
||||
|
||||
# Search for 'Kbuild' or 'Makefile' in the parent
|
||||
# directories (may not be a direct parent)
|
||||
if [[ -f ${srctree}/${dir}/Kbuild ]]; then
|
||||
kbuild_file=${srctree}/${dir}/Kbuild
|
||||
break
|
||||
fi
|
||||
if [[ -f ${srctree}/${dir}/Makefile ]]; then
|
||||
kbuild_file=${srctree}/${dir}/Makefile
|
||||
break
|
||||
fi
|
||||
|
||||
if [[ ${dir} == . ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n ${kbuild_file} ]]; then
|
||||
tmp=($(__kbuild_tmp_makefile "${kbuild_file}" |
|
||||
SRCARCH=${srcarch} obj=${dir} src=${srctree}/${dir} \
|
||||
"${1}" -n -f - 2>/dev/null))
|
||||
|
||||
# Add $(obj)/ prefix
|
||||
if [[ ${dir} != . ]]; then
|
||||
tmp=("${tmp[@]/#/${dir}\/}")
|
||||
fi
|
||||
|
||||
keywords+=("${tmp[@]}")
|
||||
fi
|
||||
|
||||
# *_defconfig and *.config files. These might be grouped into
|
||||
# subdirectories, e.g., arch/powerpc/configs/*/*_defconfig.
|
||||
if [[ ${cur} == */* ]]; then
|
||||
dir=${cur%/*}
|
||||
else
|
||||
dir=.
|
||||
fi
|
||||
|
||||
tmp=($(find "${srctree}/arch/${srcarch}/configs/${dir}" \
|
||||
"${srctree}/kernel/configs/${dir}" \
|
||||
-mindepth 1 -maxdepth 1 -type d -printf '%P/\n' \
|
||||
-o -printf '%P\n' 2>/dev/null))
|
||||
|
||||
if [[ ${dir} != . ]]; then
|
||||
tmp=("${tmp[@]/#/${dir}\/}")
|
||||
fi
|
||||
|
||||
keywords+=("${tmp[@]}")
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2191 # '=' is appended for variables
|
||||
keywords+=(
|
||||
#
|
||||
# variables (append =)
|
||||
#
|
||||
ARCH=
|
||||
CROSS_COMPILE=
|
||||
LLVM=
|
||||
C= M= MO= O= V= W=
|
||||
INSTALL{,_MOD,_HDR,_DTBS}_PATH=
|
||||
KERNELRELEASE=
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
all help
|
||||
clean mrproper distclean
|
||||
clang-{tidy,analyzer} compile_commands.json
|
||||
coccicheck
|
||||
dtbs{,_check,_install} dt_binding_{check,schemas}
|
||||
headers{,_install}
|
||||
vmlinux install
|
||||
modules{,_prepare,_install,_sign}
|
||||
vdso_install
|
||||
tags TAGS cscope gtags
|
||||
rust{available,fmt,fmtcheck}
|
||||
kernel{version,release} image_name
|
||||
kselftest{,-all,-install,-clean,-merge}
|
||||
|
||||
# configuration
|
||||
{,old,olddef,sync,def,savedef,rand,listnew,helpnew,test,tiny}config
|
||||
{,build_}{menu,n,g,x}config
|
||||
local{mod,yes}config
|
||||
all{no,yes,mod,def}config
|
||||
{yes2mod,mod2yes,mod2no}config
|
||||
|
||||
# docs
|
||||
{html,textinfo,info,latex,pdf,epub,xml,linkcheck,refcheck,clean}docs
|
||||
|
||||
# package
|
||||
{,bin,src}{rpm,deb}-pkg
|
||||
{pacman,dir,tar}-pkg
|
||||
tar{,gz,bz2,xz,zst}-pkg
|
||||
perf-tar{,gz,bz2,xz,zst}-src-pkg
|
||||
)
|
||||
|
||||
COMPREPLY=($(compgen -W "${keywords[*]}" -- "${cur}"))
|
||||
|
||||
# Do not append a space for variables, subdirs, "KBUILD_", "KCONFIG_".
|
||||
if [[ ${COMPREPLY-} == *[=/] || ${COMPREPLY-} =~ ^(KBUILD|KCONFIG)_$ ]]; then
|
||||
compopt -o nospace
|
||||
fi
|
||||
|
||||
} && complete -F _make_for_kbuild make
|
@ -3690,20 +3690,6 @@ sub process {
|
||||
}
|
||||
}
|
||||
|
||||
if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
|
||||
($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
|
||||
my $flag = $1;
|
||||
my $replacement = {
|
||||
'EXTRA_AFLAGS' => 'asflags-y',
|
||||
'EXTRA_CFLAGS' => 'ccflags-y',
|
||||
'EXTRA_CPPFLAGS' => 'cppflags-y',
|
||||
'EXTRA_LDFLAGS' => 'ldflags-y',
|
||||
};
|
||||
|
||||
WARN("DEPRECATED_VARIABLE",
|
||||
"Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
|
||||
}
|
||||
|
||||
# check for DT compatible documentation
|
||||
if (defined $root &&
|
||||
(($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) ||
|
||||
|
@ -167,10 +167,10 @@ def process_line(root_directory, command_prefix, file_path):
|
||||
root_directory or file_directory.
|
||||
"""
|
||||
# The .cmd files are intended to be included directly by Make, so they
|
||||
# escape the pound sign '#', either as '\#' or '$(pound)' (depending on the
|
||||
# kernel version). The compile_commands.json file is not interepreted
|
||||
# by Make, so this code replaces the escaped version with '#'.
|
||||
prefix = command_prefix.replace(r'\#', '#').replace('$(pound)', '#')
|
||||
# escape the pound sign '#' as '$(pound)'. The compile_commands.json file
|
||||
# is not interepreted by Make, so this code replaces the escaped version
|
||||
# with '#'.
|
||||
prefix = command_prefix.replace('$(pound)', '#')
|
||||
|
||||
# Return the canonical path, eliminating any symbolic links encountered in the path.
|
||||
abs_path = os.path.realpath(os.path.join(root_directory, file_path))
|
||||
|
@ -32,6 +32,7 @@ commands:
|
||||
Disable option directly after other option
|
||||
--module-after|-M beforeopt option
|
||||
Turn option into module directly after other option
|
||||
--refresh Refresh the config using old settings
|
||||
|
||||
commands can be repeated multiple times
|
||||
|
||||
@ -124,16 +125,22 @@ undef_var() {
|
||||
txt_delete "^# $name is not set" "$FN"
|
||||
}
|
||||
|
||||
if [ "$1" = "--file" ]; then
|
||||
FN="$2"
|
||||
if [ "$FN" = "" ] ; then
|
||||
usage
|
||||
FN=.config
|
||||
CMDS=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [ "$1" = "--file" ]; then
|
||||
if [ "$2" = "" ]; then
|
||||
usage
|
||||
fi
|
||||
FN="$2"
|
||||
shift 2
|
||||
else
|
||||
CMDS+=("$1")
|
||||
shift
|
||||
fi
|
||||
shift 2
|
||||
else
|
||||
FN=.config
|
||||
fi
|
||||
done
|
||||
|
||||
set -- "${CMDS[@]}"
|
||||
if [ "$1" = "" ] ; then
|
||||
usage
|
||||
fi
|
||||
@ -217,9 +224,8 @@ while [ "$1" != "" ] ; do
|
||||
set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
|
||||
;;
|
||||
|
||||
# undocumented because it ignores --file (fixme)
|
||||
--refresh)
|
||||
yes "" | make oldconfig
|
||||
yes "" | make oldconfig KCONFIG_CONFIG=$FN
|
||||
;;
|
||||
|
||||
*)
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <string.h>
|
||||
#include "gendwarfksyms.h"
|
||||
|
||||
#define DIE_HASH_BITS 15
|
||||
#define DIE_HASH_BITS 16
|
||||
|
||||
/* {die->addr, state} -> struct die * */
|
||||
static HASHTABLE_DEFINE(die_map, 1 << DIE_HASH_BITS);
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Copyright (C) 2024 Google LLC
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
@ -193,79 +194,17 @@ static void process_fmt(struct die *cache, const char *fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#define MAX_FQN_SIZE 64
|
||||
|
||||
/* Get a fully qualified name from DWARF scopes */
|
||||
static char *get_fqn(Dwarf_Die *die)
|
||||
{
|
||||
const char *list[MAX_FQN_SIZE];
|
||||
Dwarf_Die *scopes = NULL;
|
||||
bool has_name = false;
|
||||
char *fqn = NULL;
|
||||
char *p;
|
||||
int count = 0;
|
||||
int len = 0;
|
||||
int res;
|
||||
int i;
|
||||
|
||||
res = checkp(dwarf_getscopes_die(die, &scopes));
|
||||
if (!res) {
|
||||
list[count] = get_name_attr(die);
|
||||
|
||||
if (!list[count])
|
||||
return NULL;
|
||||
|
||||
len += strlen(list[count]);
|
||||
count++;
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (i = res - 1; i >= 0 && count < MAX_FQN_SIZE; i--) {
|
||||
if (dwarf_tag(&scopes[i]) == DW_TAG_compile_unit)
|
||||
continue;
|
||||
|
||||
list[count] = get_name_attr(&scopes[i]);
|
||||
|
||||
if (list[count]) {
|
||||
has_name = true;
|
||||
} else {
|
||||
list[count] = "<anonymous>";
|
||||
has_name = false;
|
||||
}
|
||||
|
||||
len += strlen(list[count]);
|
||||
count++;
|
||||
|
||||
if (i > 0) {
|
||||
list[count++] = "::";
|
||||
len += 2;
|
||||
}
|
||||
}
|
||||
|
||||
free(scopes);
|
||||
|
||||
if (count == MAX_FQN_SIZE)
|
||||
warn("increase MAX_FQN_SIZE: reached the maximum");
|
||||
|
||||
/* Consider the DIE unnamed if the last scope doesn't have a name */
|
||||
if (!has_name)
|
||||
return NULL;
|
||||
done:
|
||||
fqn = xmalloc(len + 1);
|
||||
*fqn = '\0';
|
||||
|
||||
p = fqn;
|
||||
for (i = 0; i < count; i++)
|
||||
p = stpcpy(p, list[i]);
|
||||
|
||||
return fqn;
|
||||
}
|
||||
|
||||
static void update_fqn(struct die *cache, Dwarf_Die *die)
|
||||
{
|
||||
if (!cache->fqn)
|
||||
cache->fqn = get_fqn(die) ?: "";
|
||||
struct die *fqn;
|
||||
|
||||
if (!cache->fqn) {
|
||||
if (!__die_map_get((uintptr_t)die->addr, DIE_FQN, &fqn) &&
|
||||
*fqn->fqn)
|
||||
cache->fqn = xstrdup(fqn->fqn);
|
||||
else
|
||||
cache->fqn = "";
|
||||
}
|
||||
}
|
||||
|
||||
static void process_fqn(struct die *cache, Dwarf_Die *die)
|
||||
@ -1148,8 +1087,81 @@ static void process_symbol_ptr(struct symbol *sym, void *arg)
|
||||
cache_free(&state.expansion_cache);
|
||||
}
|
||||
|
||||
static int resolve_fqns(struct state *parent, struct die *unused,
|
||||
Dwarf_Die *die)
|
||||
{
|
||||
struct state state;
|
||||
struct die *cache;
|
||||
const char *name;
|
||||
bool use_prefix;
|
||||
char *prefix = NULL;
|
||||
char *fqn = "";
|
||||
int tag;
|
||||
|
||||
if (!__die_map_get((uintptr_t)die->addr, DIE_FQN, &cache))
|
||||
return 0;
|
||||
|
||||
tag = dwarf_tag(die);
|
||||
|
||||
/*
|
||||
* Only namespaces and structures need to pass a prefix to the next
|
||||
* scope.
|
||||
*/
|
||||
use_prefix = tag == DW_TAG_namespace || tag == DW_TAG_class_type ||
|
||||
tag == DW_TAG_structure_type;
|
||||
|
||||
state.expand.current_fqn = NULL;
|
||||
name = get_name_attr(die);
|
||||
|
||||
if (parent && parent->expand.current_fqn && (use_prefix || name)) {
|
||||
/*
|
||||
* The fqn for the current DIE, and if needed, a prefix for the
|
||||
* next scope.
|
||||
*/
|
||||
if (asprintf(&prefix, "%s::%s", parent->expand.current_fqn,
|
||||
name ? name : "<anonymous>") < 0)
|
||||
error("asprintf failed");
|
||||
|
||||
if (use_prefix)
|
||||
state.expand.current_fqn = prefix;
|
||||
|
||||
/*
|
||||
* Use fqn only if the DIE has a name. Otherwise fqn will
|
||||
* remain empty.
|
||||
*/
|
||||
if (name) {
|
||||
fqn = prefix;
|
||||
/* prefix will be freed by die_map. */
|
||||
prefix = NULL;
|
||||
}
|
||||
} else if (name) {
|
||||
/* No prefix from the previous scope. Use only the name. */
|
||||
fqn = xstrdup(name);
|
||||
|
||||
if (use_prefix)
|
||||
state.expand.current_fqn = fqn;
|
||||
}
|
||||
|
||||
/* If the DIE has a non-empty name, cache it. */
|
||||
if (*fqn) {
|
||||
cache = die_map_get(die, DIE_FQN);
|
||||
/* Move ownership of fqn to die_map. */
|
||||
cache->fqn = fqn;
|
||||
cache->state = DIE_FQN;
|
||||
}
|
||||
|
||||
check(process_die_container(&state, NULL, die, resolve_fqns,
|
||||
match_all));
|
||||
|
||||
free(prefix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void process_cu(Dwarf_Die *cudie)
|
||||
{
|
||||
check(process_die_container(NULL, NULL, cudie, resolve_fqns,
|
||||
match_all));
|
||||
|
||||
check(process_die_container(NULL, NULL, cudie, process_exported_symbols,
|
||||
match_all));
|
||||
|
||||
|
@ -139,6 +139,7 @@ void symbol_free(void);
|
||||
|
||||
enum die_state {
|
||||
DIE_INCOMPLETE,
|
||||
DIE_FQN,
|
||||
DIE_UNEXPANDED,
|
||||
DIE_COMPLETE,
|
||||
DIE_SYMBOL,
|
||||
@ -170,6 +171,7 @@ static inline const char *die_state_name(enum die_state state)
|
||||
{
|
||||
switch (state) {
|
||||
CASE_CONST_TO_STR(DIE_INCOMPLETE)
|
||||
CASE_CONST_TO_STR(DIE_FQN)
|
||||
CASE_CONST_TO_STR(DIE_UNEXPANDED)
|
||||
CASE_CONST_TO_STR(DIE_COMPLETE)
|
||||
CASE_CONST_TO_STR(DIE_SYMBOL)
|
||||
|
@ -248,7 +248,7 @@ static char *get_type_name(struct die *cache)
|
||||
warn("found incomplete cache entry: %p", cache);
|
||||
return NULL;
|
||||
}
|
||||
if (cache->state == DIE_SYMBOL)
|
||||
if (cache->state == DIE_SYMBOL || cache->state == DIE_FQN)
|
||||
return NULL;
|
||||
if (!cache->fqn || !*cache->fqn)
|
||||
return NULL;
|
||||
|
@ -282,6 +282,11 @@ ARGIND == 2 && !anchor && NF == 2 && $1 ~ /^0x/ && $2 !~ /^0x/ {
|
||||
# section.
|
||||
#
|
||||
ARGIND == 2 && sect && NF == 4 && /^ [^ \*]/ && !($1 in sect_addend) {
|
||||
# There are a few sections with constant data (without symbols) that
|
||||
# can get resized during linking, so it is best to ignore them.
|
||||
if ($1 ~ /^\.rodata\.(cst|str)[0-9]/)
|
||||
next;
|
||||
|
||||
if (!($1 in sect_base)) {
|
||||
sect_base[$1] = base;
|
||||
|
||||
|
@ -176,10 +176,10 @@ repeat:
|
||||
switch (lexstate)
|
||||
{
|
||||
case ST_NORMAL:
|
||||
APP;
|
||||
switch (token)
|
||||
{
|
||||
case IDENT:
|
||||
APP;
|
||||
{
|
||||
int r = is_reserved_word(yytext, yyleng);
|
||||
if (r >= 0)
|
||||
@ -224,13 +224,11 @@ repeat:
|
||||
break;
|
||||
|
||||
case '[':
|
||||
APP;
|
||||
lexstate = ST_BRACKET;
|
||||
count = 1;
|
||||
goto repeat;
|
||||
|
||||
case '{':
|
||||
APP;
|
||||
if (dont_want_brace_phrase)
|
||||
break;
|
||||
lexstate = ST_BRACE;
|
||||
@ -238,12 +236,10 @@ repeat:
|
||||
goto repeat;
|
||||
|
||||
case '=': case ':':
|
||||
APP;
|
||||
lexstate = ST_EXPRESSION;
|
||||
break;
|
||||
|
||||
default:
|
||||
APP;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -385,7 +385,7 @@ load:
|
||||
|
||||
def_flags = SYMBOL_DEF << def;
|
||||
for_all_symbols(sym) {
|
||||
sym->flags &= ~(def_flags|SYMBOL_VALID);
|
||||
sym->flags &= ~def_flags;
|
||||
switch (sym->type) {
|
||||
case S_INT:
|
||||
case S_HEX:
|
||||
@ -398,7 +398,11 @@ load:
|
||||
}
|
||||
}
|
||||
|
||||
expr_invalidate_all();
|
||||
if (def == S_DEF_USER) {
|
||||
for_all_symbols(sym)
|
||||
sym->flags &= ~SYMBOL_VALID;
|
||||
expr_invalidate_all();
|
||||
}
|
||||
|
||||
while (getline_stripped(&line, &line_asize, in) != -1) {
|
||||
struct menu *choice;
|
||||
@ -464,6 +468,9 @@ load:
|
||||
if (conf_set_sym_val(sym, def, def_flags, val))
|
||||
continue;
|
||||
|
||||
if (def != S_DEF_USER)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* If this is a choice member, give it the highest priority.
|
||||
* If conflicting CONFIG options are given from an input file,
|
||||
@ -967,10 +974,8 @@ static int conf_touch_deps(void)
|
||||
depfile_path[depfile_prefix_len] = 0;
|
||||
|
||||
conf_read_simple(name, S_DEF_AUTO);
|
||||
sym_calc_value(modules_sym);
|
||||
|
||||
for_all_symbols(sym) {
|
||||
sym_calc_value(sym);
|
||||
if (sym_is_choice(sym))
|
||||
continue;
|
||||
if (sym->flags & SYMBOL_WRITE) {
|
||||
@ -1084,12 +1089,12 @@ int conf_write_autoconf(int overwrite)
|
||||
if (ret)
|
||||
return -1;
|
||||
|
||||
if (conf_touch_deps())
|
||||
return 1;
|
||||
|
||||
for_all_symbols(sym)
|
||||
sym_calc_value(sym);
|
||||
|
||||
if (conf_touch_deps())
|
||||
return 1;
|
||||
|
||||
ret = __conf_write_autoconf(conf_get_autoheader_name(),
|
||||
print_symbol_for_c,
|
||||
&comment_style_c);
|
||||
|
@ -112,8 +112,8 @@ INITFILE=$1
|
||||
shift;
|
||||
|
||||
if [ ! -r "$INITFILE" ]; then
|
||||
echo "The base file '$INITFILE' does not exist. Exit." >&2
|
||||
exit 1
|
||||
echo "The base file '$INITFILE' does not exist. Creating one..." >&2
|
||||
touch "$INITFILE"
|
||||
fi
|
||||
|
||||
MERGE_LIST=$*
|
||||
|
@ -879,7 +879,7 @@ const char *sym_get_string_value(struct symbol *sym)
|
||||
default:
|
||||
;
|
||||
}
|
||||
return (const char *)sym->curr.val;
|
||||
return sym->curr.val;
|
||||
}
|
||||
|
||||
bool sym_is_changeable(const struct symbol *sym)
|
||||
|
@ -31,6 +31,7 @@ set -e
|
||||
LD="$1"
|
||||
KBUILD_LDFLAGS="$2"
|
||||
LDFLAGS_vmlinux="$3"
|
||||
VMLINUX="$4"
|
||||
|
||||
is_enabled() {
|
||||
grep -q "^$1=y" include/config/auto.conf
|
||||
@ -97,8 +98,8 @@ vmlinux_link()
|
||||
ldflags="${ldflags} ${wl}--strip-debug"
|
||||
fi
|
||||
|
||||
if is_enabled CONFIG_VMLINUX_MAP; then
|
||||
ldflags="${ldflags} ${wl}-Map=${output}.map"
|
||||
if [ -n "${generate_map}" ]; then
|
||||
ldflags="${ldflags} ${wl}-Map=vmlinux.map"
|
||||
fi
|
||||
|
||||
${ld} ${ldflags} -o ${output} \
|
||||
@ -208,6 +209,7 @@ fi
|
||||
btf_vmlinux_bin_o=
|
||||
kallsymso=
|
||||
strip_debug=
|
||||
generate_map=
|
||||
|
||||
if is_enabled CONFIG_KALLSYMS; then
|
||||
true > .tmp_vmlinux0.syms
|
||||
@ -276,23 +278,27 @@ fi
|
||||
|
||||
strip_debug=
|
||||
|
||||
vmlinux_link vmlinux
|
||||
if is_enabled CONFIG_VMLINUX_MAP; then
|
||||
generate_map=1
|
||||
fi
|
||||
|
||||
vmlinux_link "${VMLINUX}"
|
||||
|
||||
# fill in BTF IDs
|
||||
if is_enabled CONFIG_DEBUG_INFO_BTF; then
|
||||
info BTFIDS vmlinux
|
||||
info BTFIDS "${VMLINUX}"
|
||||
RESOLVE_BTFIDS_ARGS=""
|
||||
if is_enabled CONFIG_WERROR; then
|
||||
RESOLVE_BTFIDS_ARGS=" --fatal_warnings "
|
||||
fi
|
||||
${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} vmlinux
|
||||
${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} "${VMLINUX}"
|
||||
fi
|
||||
|
||||
mksysmap vmlinux System.map
|
||||
mksysmap "${VMLINUX}" System.map
|
||||
|
||||
if is_enabled CONFIG_BUILDTIME_TABLE_SORT; then
|
||||
info SORTTAB vmlinux
|
||||
if ! sorttable vmlinux; then
|
||||
info SORTTAB "${VMLINUX}"
|
||||
if ! sorttable "${VMLINUX}"; then
|
||||
echo >&2 Failed to sort kernel tables
|
||||
exit 1
|
||||
fi
|
||||
@ -308,4 +314,4 @@ if is_enabled CONFIG_KALLSYMS; then
|
||||
fi
|
||||
|
||||
# For fixdep
|
||||
echo "vmlinux: $0" > .vmlinux.d
|
||||
echo "${VMLINUX}: $0" > ".${VMLINUX}.d"
|
||||
|
@ -98,6 +98,18 @@ static inline bool strends(const char *str, const char *postfix)
|
||||
return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_basename - return the last part of a pathname.
|
||||
*
|
||||
* @path: path to extract the filename from.
|
||||
*/
|
||||
const char *get_basename(const char *path)
|
||||
{
|
||||
const char *tail = strrchr(path, '/');
|
||||
|
||||
return tail ? tail + 1 : path;
|
||||
}
|
||||
|
||||
char *read_text_file(const char *filename)
|
||||
{
|
||||
struct stat st;
|
||||
@ -1461,14 +1473,8 @@ static void extract_crcs_for_object(const char *object, struct module *mod)
|
||||
const char *base;
|
||||
int dirlen, ret;
|
||||
|
||||
base = strrchr(object, '/');
|
||||
if (base) {
|
||||
base++;
|
||||
dirlen = base - object;
|
||||
} else {
|
||||
dirlen = 0;
|
||||
base = object;
|
||||
}
|
||||
base = get_basename(object);
|
||||
dirlen = base - object;
|
||||
|
||||
ret = snprintf(cmd_file, sizeof(cmd_file), "%.*s.%s.cmd",
|
||||
dirlen, object, base);
|
||||
@ -1596,8 +1602,8 @@ static void read_symbols(const char *modname)
|
||||
namespace);
|
||||
}
|
||||
|
||||
if (extra_warn && !get_modinfo(&info, "description"))
|
||||
warn("missing MODULE_DESCRIPTION() in %s\n", modname);
|
||||
if (!get_modinfo(&info, "description"))
|
||||
error("missing MODULE_DESCRIPTION() in %s\n", modname);
|
||||
}
|
||||
|
||||
for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
|
||||
@ -1703,11 +1709,7 @@ static void check_exports(struct module *mod)
|
||||
s->crc_valid = exp->crc_valid;
|
||||
s->crc = exp->crc;
|
||||
|
||||
basename = strrchr(mod->name, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = mod->name;
|
||||
basename = get_basename(mod->name);
|
||||
|
||||
if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
|
||||
modpost_log(!allow_missing_ns_imports,
|
||||
@ -1765,11 +1767,8 @@ static void check_modname_len(struct module *mod)
|
||||
{
|
||||
const char *mod_name;
|
||||
|
||||
mod_name = strrchr(mod->name, '/');
|
||||
if (mod_name == NULL)
|
||||
mod_name = mod->name;
|
||||
else
|
||||
mod_name++;
|
||||
mod_name = get_basename(mod->name);
|
||||
|
||||
if (strlen(mod_name) >= MODULE_NAME_LEN)
|
||||
error("module name is too long [%s.ko]\n", mod->name);
|
||||
}
|
||||
@ -1946,11 +1945,7 @@ static void add_depends(struct buffer *b, struct module *mod)
|
||||
continue;
|
||||
|
||||
s->module->seen = true;
|
||||
p = strrchr(s->module->name, '/');
|
||||
if (p)
|
||||
p++;
|
||||
else
|
||||
p = s->module->name;
|
||||
p = get_basename(s->module->name);
|
||||
buf_printf(b, "%s%s", first ? "" : ",", p);
|
||||
first = 0;
|
||||
}
|
||||
|
@ -216,6 +216,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen);
|
||||
/* from modpost.c */
|
||||
extern bool target_is_big_endian;
|
||||
extern bool host_is_big_endian;
|
||||
const char *get_basename(const char *path);
|
||||
char *read_text_file(const char *filename);
|
||||
char *get_line(char **stringp);
|
||||
void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);
|
||||
|
@ -309,15 +309,10 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
|
||||
|
||||
cmd = xmalloc(strlen(objfile) + sizeof("..cmd"));
|
||||
|
||||
base = strrchr(objfile, '/');
|
||||
if (base) {
|
||||
base++;
|
||||
dirlen = base - objfile;
|
||||
sprintf(cmd, "%.*s.%s.cmd", dirlen, objfile, base);
|
||||
} else {
|
||||
dirlen = 0;
|
||||
sprintf(cmd, ".%s.cmd", objfile);
|
||||
}
|
||||
base = get_basename(objfile);
|
||||
dirlen = base - objfile;
|
||||
sprintf(cmd, "%.*s.%s.cmd", dirlen, objfile, base);
|
||||
|
||||
dir = xmalloc(dirlen + 1);
|
||||
strncpy(dir, objfile, dirlen);
|
||||
dir[dirlen] = '\0';
|
||||
@ -335,7 +330,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
|
||||
line++;
|
||||
p = line;
|
||||
|
||||
if (strncmp(line, "source_", sizeof("source_")-1) == 0) {
|
||||
if (strstarts(line, "source_")) {
|
||||
p = strrchr(line, ' ');
|
||||
if (!p) {
|
||||
warn("malformed line: %s\n", line);
|
||||
@ -349,7 +344,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) {
|
||||
if (strstarts(line, "deps_")) {
|
||||
check_files = 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ build() {
|
||||
_package() {
|
||||
pkgdesc="The ${pkgdesc} kernel and modules"
|
||||
|
||||
local modulesdir="${pkgdir}/usr/${MODLIB}"
|
||||
local modulesdir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}"
|
||||
|
||||
_prologue
|
||||
|
||||
@ -81,7 +81,7 @@ _package() {
|
||||
_package-headers() {
|
||||
pkgdesc="Headers and scripts for building modules for the ${pkgdesc} kernel"
|
||||
|
||||
local builddir="${pkgdir}/usr/${MODLIB}/build"
|
||||
local builddir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}/build"
|
||||
|
||||
_prologue
|
||||
|
||||
@ -114,7 +114,7 @@ _package-debug(){
|
||||
pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
|
||||
|
||||
local debugdir="${pkgdir}/usr/src/debug/${pkgbase}"
|
||||
local builddir="${pkgdir}/usr/${MODLIB}/build"
|
||||
local builddir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}/build"
|
||||
|
||||
_prologue
|
||||
|
||||
|
@ -21,9 +21,11 @@ ifeq ($(origin KBUILD_VERBOSE),undefined)
|
||||
endif
|
||||
endif
|
||||
|
||||
revision = $(lastword $(subst -, ,$(shell dpkg-parsechangelog -S Version)))
|
||||
revision = $(shell dpkg-parsechangelog -S Version | sed -n 's/.*-//p')
|
||||
CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-)
|
||||
make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE))
|
||||
make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) \
|
||||
$(addprefix KBUILD_BUILD_VERSION=,$(revision)) \
|
||||
$(addprefix CROSS_COMPILE=,$(CROSS_COMPILE))
|
||||
|
||||
binary-targets := $(addprefix binary-, image image-dbg headers libc-dev)
|
||||
|
||||
@ -41,6 +43,10 @@ package = $($(@:binary-%=%-package))
|
||||
# which package is being processed in the build log.
|
||||
DH_OPTIONS = -p$(package)
|
||||
|
||||
# Note: future removal of KDEB_COMPRESS
|
||||
# dpkg-deb >= 1.21.10 supports the DPKG_DEB_COMPRESSOR_TYPE environment
|
||||
# variable, which provides the same functionality as KDEB_COMPRESS. The
|
||||
# KDEB_COMPRESS variable will be removed in the future.
|
||||
define binary
|
||||
$(Q)dh_testdir $(DH_OPTIONS)
|
||||
$(Q)dh_testroot $(DH_OPTIONS)
|
||||
|
@ -2,8 +2,6 @@
|
||||
%{!?_arch: %define _arch dummy}
|
||||
%{!?make: %define make make}
|
||||
%define makeflags %{?_smp_mflags} ARCH=%{ARCH}
|
||||
%define __spec_install_post /usr/lib/rpm/brp-compress || :
|
||||
%define debug_package %{nil}
|
||||
|
||||
Name: kernel
|
||||
Summary: The Linux Kernel
|
||||
@ -46,6 +44,36 @@ This package provides kernel headers and makefiles sufficient to build modules
|
||||
against the %{version} kernel package.
|
||||
%endif
|
||||
|
||||
%if %{with_debuginfo}
|
||||
# list of debuginfo-related options taken from distribution kernel.spec
|
||||
# files
|
||||
%undefine _include_minidebuginfo
|
||||
%undefine _find_debuginfo_dwz_opts
|
||||
%undefine _unique_build_ids
|
||||
%undefine _unique_debug_names
|
||||
%undefine _unique_debug_srcs
|
||||
%undefine _debugsource_packages
|
||||
%undefine _debuginfo_subpackages
|
||||
%global _find_debuginfo_opts -r
|
||||
%global _missing_build_ids_terminate_build 1
|
||||
%global _no_recompute_build_ids 1
|
||||
%{debug_package}
|
||||
%endif
|
||||
# some (but not all) versions of rpmbuild emit %%debug_package with
|
||||
# %%install. since we've already emitted it manually, that would cause
|
||||
# a package redefinition error. ensure that doesn't happen
|
||||
%define debug_package %{nil}
|
||||
|
||||
# later, we make all modules executable so that find-debuginfo.sh strips
|
||||
# them up. but they don't actually need to be executable, so remove the
|
||||
# executable bit, taking care to do it _after_ find-debuginfo.sh has run
|
||||
%define __spec_install_post \
|
||||
%{?__debug_package:%{__debug_install_post}} \
|
||||
%{__arch_install_post} \
|
||||
%{__os_install_post} \
|
||||
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\
|
||||
| xargs --no-run-if-empty chmod u-x
|
||||
|
||||
%prep
|
||||
%setup -q -n linux
|
||||
cp %{SOURCE1} .config
|
||||
@ -89,8 +117,22 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
|
||||
echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
|
||||
} > %{buildroot}/kernel.list
|
||||
|
||||
# make modules executable so that find-debuginfo.sh strips them. this
|
||||
# will be undone later in %%__spec_install_post
|
||||
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \
|
||||
| xargs --no-run-if-empty chmod u+x
|
||||
|
||||
%if %{with_debuginfo}
|
||||
# copying vmlinux directly to the debug directory means it will not get
|
||||
# stripped (but its source paths will still be collected + fixed up)
|
||||
mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
|
||||
cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
|
||||
%endif
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \
|
||||
elfbins.list
|
||||
|
||||
%post
|
||||
if [ -x /usr/bin/kernel-install ]; then
|
||||
|
@ -77,6 +77,8 @@ set_debarch() {
|
||||
debarch=i386
|
||||
fi
|
||||
;;
|
||||
loongarch64)
|
||||
debarch=loong64 ;;
|
||||
esac
|
||||
if [ -z "$debarch" ]; then
|
||||
debarch=$(dpkg-architecture -qDEB_HOST_ARCH)
|
||||
@ -155,11 +157,12 @@ while [ $# -gt 0 ]; do
|
||||
done
|
||||
|
||||
# Some variables and settings used throughout the script
|
||||
version=$KERNELRELEASE
|
||||
if [ "${KDEB_PKGVERSION:+set}" ]; then
|
||||
packageversion=$KDEB_PKGVERSION
|
||||
else
|
||||
packageversion=$(${srctree}/scripts/setlocalversion --no-local ${srctree})-$($srctree/scripts/build-version)
|
||||
upstream_version=$("${srctree}/scripts/setlocalversion" --no-local "${srctree}" | sed 's/-\(rc[1-9]\)/~\1/')
|
||||
debian_revision=$("${srctree}/scripts/build-version")
|
||||
packageversion=${upstream_version}-${debian_revision}
|
||||
fi
|
||||
sourcename=${KDEB_SOURCENAME:-linux-upstream}
|
||||
|
||||
@ -212,11 +215,11 @@ Build-Depends-Arch: bc, bison, flex,
|
||||
python3:native, rsync
|
||||
Homepage: https://www.kernel.org/
|
||||
|
||||
Package: $packagename-$version
|
||||
Package: $packagename-${KERNELRELEASE}
|
||||
Architecture: $debarch
|
||||
Description: Linux kernel, version $version
|
||||
Description: Linux kernel, version ${KERNELRELEASE}
|
||||
This package contains the Linux kernel, modules and corresponding other
|
||||
files, version: $version.
|
||||
files, version: ${KERNELRELEASE}.
|
||||
EOF
|
||||
|
||||
if [ "${SRCARCH}" != um ]; then
|
||||
@ -235,11 +238,11 @@ EOF
|
||||
if is_enabled CONFIG_MODULES; then
|
||||
cat <<EOF >> debian/control
|
||||
|
||||
Package: linux-headers-$version
|
||||
Package: linux-headers-${KERNELRELEASE}
|
||||
Architecture: $debarch
|
||||
Build-Profiles: <!pkg.${sourcename}.nokernelheaders>
|
||||
Description: Linux kernel headers for $version on $debarch
|
||||
This package provides kernel header files for $version on $debarch
|
||||
Description: Linux kernel headers for ${KERNELRELEASE} on $debarch
|
||||
This package provides kernel header files for ${KERNELRELEASE} on $debarch
|
||||
.
|
||||
This is useful for people who need to build external modules
|
||||
EOF
|
||||
@ -249,11 +252,11 @@ fi
|
||||
if is_enabled CONFIG_DEBUG_INFO; then
|
||||
cat <<EOF >> debian/control
|
||||
|
||||
Package: linux-image-$version-dbg
|
||||
Package: linux-image-${KERNELRELEASE}-dbg
|
||||
Section: debug
|
||||
Architecture: $debarch
|
||||
Build-Profiles: <!pkg.${sourcename}.nokerneldbg>
|
||||
Description: Linux kernel debugging symbols for $version
|
||||
Description: Linux kernel debugging symbols for ${KERNELRELEASE}
|
||||
This package will come in handy if you need to debug the kernel. It provides
|
||||
all the necessary debug symbols for the kernel and its modules.
|
||||
EOF
|
||||
|
@ -23,6 +23,16 @@ else
|
||||
echo '%define with_devel 0'
|
||||
fi
|
||||
|
||||
# debuginfo package generation uses find-debuginfo.sh under the hood,
|
||||
# which only works on uncompressed modules that contain debuginfo
|
||||
if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf &&
|
||||
(! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) &&
|
||||
(! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then
|
||||
echo '%define with_debuginfo %{?_without_debuginfo: 0} %{?!_without_debuginfo: 1}'
|
||||
else
|
||||
echo '%define with_debuginfo 0'
|
||||
fi
|
||||
|
||||
cat<<EOF
|
||||
%define ARCH ${ARCH}
|
||||
%define KERNELRELEASE ${KERNELRELEASE}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# show_deltas: Read list of printk messages instrumented with
|
||||
|
Loading…
x
Reference in New Issue
Block a user