The 'scripts' directory was searched under arch/${SRCARCH} to copy
arch/ia64/scripts, but commit cf8e865810 ("arch: Remove Itanium
(IA-64) architecture") removed arch/ia64/ entirely.
There is another 'scripts' directory in arch/um/, but this script
is never executed with SRCARCH=um because UML does not support the
linux-headers package.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
There are two ways of managing separate debug info files:
[1] The executable contains the .gnu_debuglink section, which specifies
the name and the CRC of the separate debug info file.
[2] The executable contains a build ID, and the corresponding debug info
file is placed in the .build-id directory.
We could do both, but the former, which 'make deb-pkg' currently does,
results in complicated installation steps because we need to manually
strip the debug sections, create debug links, and re-sign the modules.
Besides, it is not working with module compression.
This commit abandons the approach [1], and instead opts for [2].
Debian kernel commit de26137e2a9f ("Drop not needed extra step to add
debug links") also stopped adding debug links.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Commit 36862e14e3 ("kbuild: deb-pkg: use dh_listpackages to know
enabled packages") started to require the debhelper tool suite.
Use more dh_* commands in create_package():
- dh_installdocs to install copyright
- dh_installchangelogs to install changelog
- dh_compress to compress changelog
- dh_fixperms to replace the raw chmod command
- dh_gencontrol to replace the raw dpkg-gencontrol command
- dh_md5sums to record the md5sum of included files
- dh_builddeb to replace the raw dpkg-deb command
Set DEB_RULES_REQUIRES_ROOT to 'no' in case debian/rules is executed
directly.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
This is unneeded because the Makefile in the output directory wraps
the top-level Makefile in the srctree.
Just run $(MAKE) irrespective of the build location.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
'make O=... deb-pkg' creates the debian directory in the output
directory. However, currently it is impossible to run debian/rules
created in the separate output directory.
This commit delays the $(srctree) expansion by escaping '$' and by
quoting the entire command, making it possible to run debian/rules in
the output directory.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
Since commit 491b146d4c ("kbuild: builddeb: Eliminate debian/arch
use"), direct execution of debian/rules results in the following error:
dpkg-architecture: error: unknown option 'DEB_HOST_MULTIARCH'
The current code:
dpkg-architecture -a$DEB_HOST_ARCH -qDEB_HOST_MULTIARCH
... does not look sensible because:
- For this code to work correctly, DEB_HOST_ARCH must be pre-defined,
which is true when the packages are built via dpkg-buildpackage.
In this case, DEB_HOST_MULTIARCH is also likely defined, hence there
is no need to query DEB_HOST_MULTIARCH in the first place.
- If DEB_HOST_MULTIARCH is undefined, DEB_HOST_ARCH is likely undefined
too. So, you cannot query DEB_HOST_MULTIARCH in this way. This is
mostly the case where debian/rules is directly executed.
When debian/rules is directly executed, querying DEB_HOST_MUCHARCH is
not enough because we need to know DEB_{BUILD,HOST}_GNU_TYPE as well.
All DEB_* variables are defined when the package build is initiated by
dpkg-buildpackage, but otherwise, let's call dpkg-architecture to set
all DEB_* environment variables.
This requires dpkg 1.20.6 or newer because --print-format option
was added in dpkg commit 7c54fa2b232e ("dpkg-architecture: Add a
--print-format option").
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
The binary-arch target needs to use the same CROSS_COMPILE as used in
build-arch; otherwise, 'make run-command' may attempt to resync the
.config file.
Squash scripts/package/deb-build-option into debian/rules, as it is a
small amount of code.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
This avoids code duplication between binary-arch and built-arch.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
The condition to require libelf-dev:native is stale because objtool is
now enabled by CONFIG_OBJTOOL instead of CONFIG_UNWINDER_ORC. Not only
objtool but also resolve_btfids requires libelf-dev:native; therefore,
CONFIG_DEBUG_INFO_BTF should be checked as well.
Similarly, CONFIG_SYSTEM_TRUSTED_KEYRING is not the only case that
requires libssl-dev:native.
Perhaps, the following code would provide better coverage, but it is
hard to maintain (and may still be imperfect).
if is_enabled CONFIG_OBJTOOL ||
is_enabled CONFIG_DEBUG_INFO_BTF; then
build_depends="${build_depends}, libelf-dev:native"
fi
if is_enabled CONFIG_SYSTEM_TRUSTED_KEYRING ||
is_enabled CONFIG_SYSTEM_REVOCATION_LIST ||
is_enabled CONFIG_MODULE_SIG_FORMAT; then
build_depends="${build_depends}, libssl-dev:native"
fi
Let's hard-code the build dependency.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
Copy debian/copyright instead of generating it by the 'cat' command.
I also updated '2018' to '2023' while I was here.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
While the kernel community has been good at maintaining backwards
compatibility with kernel UAPIs, it would be helpful to have a tool
to check if a commit introduces changes that break backwards
compatibility.
To that end, introduce check-uapi.sh: a simple shell script that
checks for changes to UAPI headers using libabigail.
libabigail is "a framework which aims at helping developers and
software distributors to spot some ABI-related issues like interface
incompatibility in ELF shared libraries by performing a static
analysis of the ELF binaries at hand."
The script uses one of libabigail's tools, "abidiff", to compile the
changed header before and after the commit to detect any changes.
abidiff "compares the ABI of two shared libraries in ELF format. It
emits a meaningful report describing the differences between the two
ABIs."
The script also includes the ability to check the compatibility of
all UAPI headers across commits. This allows developers to inspect
the stability of the UAPIs over time.
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
When reviewing patches, it looks much nicer to have some changes shown
before others, which allow better understanding of the patch before the
the .c files reviewing.
Introduce a default git.orderFile, in order to help developers getting the
best ordering easier.
Signed-off-by: Leonardo Bras <leobras@redhat.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
When KCONFIG_WERROR env variable is set treat unmet direct
symbol dependency as a terminal condition (error).
Suggested-by: Stefan Reinauer <reinauer@google.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
When using a custom location for kernel config files this merge config
command fails as it doesn't use the configuration set with
KCONFIG_CONFIG.
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
menu_has_help() and menu_get_help() functions are only used within
menu_get_ext_help().
Squash them into menu_get_ext_help(). It revealed the if-conditional
in menu_get_help() was unneeded, as menu_has_help() has already checked
that menu->help is not NULL.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Now compilers can recognize fatal() never returns.
While GCC 4.5 dropped support for -Wunreachable-code, Clang is capable
of detecting the unreachable code.
$ make HOSTCC=clang HOSTCFLAGS=-Wunreachable-code-return
[snip]
HOSTCC scripts/mod/modpost.o
scripts/mod/modpost.c:520:11: warning: 'return' will never be executed [-Wunreachable-code-return]
return 0;
^
scripts/mod/modpost.c:477:10: warning: 'return' will never be executed [-Wunreachable-code-return]
return 0;
^
2 warnings generated.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
This initializer was added to avoid -Wmaybe-uninitialized (gcc) and
-Wsometimes-uninitialized (clang) warnings.
Now that compilers recognize fatal() never returns, it is unneeded.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
The function fatal() never returns because modpost_log() calls exit(1)
when LOG_FATAL is passed.
Inform compilers of this fact so that unreachable code flow can be
identified at compile time.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
This attribute must be added to the function declaration in a header
for comprehensive checking of all the callsites.
Fixes: 6d9a89ea4b ("kbuild: declare the modpost error functions as printf like")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
When using the -dtbs syntax, you need to list the base first, as
follows:
foo-dtbs := foo_base.dtb foo_overlay1.dtbo foo_overlay2.dtbo
dtb-y := foo.dtb
You cannot do this arrangement:
foo-dtbs := foo_overlay1.dtbo foo_overlay2.dtbo foo_base.dtb
This restriction comes from $(firstword ...) in the current
implementation, but it is unneeded to rely on the order in the
-dtbs syntax.
Instead, you can simply determine the base by the suffix because
the base (*.dtb) and overlays (*.dtbo) use different suffixes.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
In 2017, the dpkg suite introduced the rootless builds support with the
following commits:
- 2436807c87b0 ("dpkg-deb: Add support for rootless builds")
- fca1bfe84068 ("dpkg-buildpackage: Add support for rootless builds")
This feature is available in the default dpkg on Debian 10 and Ubuntu
20.04.
Remove the old method.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
When a default property is missing in an int or hex symbol, it defaults
to an empty string, which is not a valid symbol value.
It results in an incorrect .config, and can also lead to an infinite
loop in scripting.
Use "0" for int and "0x0" for hex as a default value.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Yoann Congal <yoann.congal@smile.fr>
This is used only for initializing other variables.
Use the empty string "" directly.
Please note newval.tri is unused for S_INT/HEX/STRING.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
A little more janitorial work after commit cf8e865810 ("arch: Remove
Itanium (IA-64) architecture").
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
KCONFIG_WARN_UNKNOWN_SYMBOLS=1 and KCONFIG_WERROR=1 are descriptive
and suitable in scripting, but typing them from the command line can
be tedious.
Associate them with KBUILD_EXTRA_WARN (and the W= shorthand).
Support a new letter 'c' to enable extra checks in Kconfig. You can
still manage compiler warnings (W=1) and Kconfig warnings (W=c)
independently.
Reuse the letter 'e' to turn Kconfig warnings into errors.
As usual, you can combine multiple letters in KCONFIG_EXTRA_WARN.
$ KCONFIG_WARN_UNKNOWN_SYMBOLS=1 KCONFIG_WERROR=1 make defconfig
can be shortened to:
$ KBUILD_EXTRA_WARN=ce make defconfig
or, even shorter:
$ make W=ce defconfig
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
The rpm-pkg and deb-pkg targets have transitioned to using 'git archive'
for tarball creation.
Although the old cmd_src_tar is still used by snap-pkg, there is no need
to pack and unpack a tarball solely for passing the source to snapcraft.
Instead, you can use 'source-type: local' to tell the source location to
snapcraft.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
It is done for the same reasons as 4243afdb93 does it for builddeb:
always runs make modules to install modules.builtin* files, which are
needed for e.g. initramfs-tools or LTP testing tool.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
The shell variable $dirs is not used any more since 1fc9095846
("kbuild: tar-pkg: use tar rules in scripts/Makefile.package"),
therefore remove it".
Fixes: 1fc9095846 ("kbuild: tar-pkg: use tar rules in scripts/Makefile.package")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Make the while-loop code a little more readable.
The gain is that "CONFIG_FOO" without '=' is warned as unexpected data.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Currently, any string starting "is not set" disables a CONFIG option.
For example, "# CONFIG_FOO is not settled down" is accepted as valid
input, functioning the same as "# CONFIG_FOO is not set". It is a
long-standing oddity.
Check the line against the exact pattern "is not set".
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Currently, newline characters are stripped away in multiple places
on the caller.
Doing that in the callee is helpful for further cleanups.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as
a valid input, but conf_read_simple() duplicates similar code to handle
them. Factor out the common code.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
The 'else' arm here is unreachable in practical use cases.
include/config/auto.conf does not include "# CONFIG_... is not set"
line unless it is manually hacked.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Currently, when an input line starts with '#', (line + 2) is passed to
memcmp() without checking line[1].
It means that line[1] can be any arbitrary character. For example,
"#KCONFIG_FOO is not set" is accepted as valid input, functioning the
same as "# CONFIG_FOO is not set".
More importantly, this can potentially lead to a buffer overrun if
line[1] == '\0'. It occurs if the input only contains '#', as
(line + 2) points to an uninitialized buffer.
Check line[1], and skip the line if it is not a space.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
xrealloc() never returns NULL as it is checked in the callee.
This is a left-over of commit d717f24d8c ("kconfig: add xrealloc()
helper").
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
The long version --rules-file and --jobs are available since 1.18.8
while their short analogues -R and -j have been added since 1.14.7.
The option --rules-file the way it works currently was introduced in the
commit 5cd52673aabdf5eaa58181972119a41041fc85f2 of dpkg dated 23.07.18
with the following changelog entry:
* Fix dpkg-buildpackage option --rules-file parsing. It was trying to parse
it as --rules-target, which due to the ordering was a no-op.
The current behavior of the long version --rules-file is guaranteed to
be in use starting 1.19.1 and might cause build failures for some
versions newer than 1.18.8 even in spite of being documented that way.
Signed-off-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
When a user-supplied value is out of range, (NEW) and an incorrect default
value are shown.
[Test Kconfig]
config FOO
int "foo"
range 10 20
[Test .config]
CONFIG_FOO=30
[Result without this fix]
$ make config
*
* Main menu
*
foo (FOO) [10] (NEW)
[Result with this fix]
$ make config
*
* Main menu
*
foo (FOO) [20]
Currently, the SYMBOL_DEF_USER is cleared if the user input does not
reside within the range. Kconfig forgets the initial value 30, and
prints (NEW) and an incorrect default [10].
Kconfig should remember the user's input. The default should be [20]
because the user's input, 30, is closer to the upper limit of the range.
Please note it will not show up in "make oldconfig" because it is no
longer considered as a new symbol. It also fixes the inconsistent
behavior in listnewconfig/helpnewconfig.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
getopt_long() is used by various tools in the kernel (e.g. Kconfig).
It should be fine to use it all the time.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Commit 74d9317161 ("genksyms: remove symbol prefix support") removed
the -s (--symbol-prefix) option.
Clean up the left-over.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
For some unknown reason the regular expression for checkstack only matches
three digit numbers starting with the number "3", or any higher
number. Which means that it skips any stack sizes smaller than 304
bytes. This makes the checkstack script a bit less useful than it could be.
Change the script to match any number. To be filtered out stack sizes
can be configured with the min_stack variable, which omits any stack
frame sizes smaller than 100 bytes by default.
Tested-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
- Fix section mismatch warning messages for riscv and loongarch
- Remove CONFIG_IA64 left-over from linux/export-internal.h
- Fix the location of the quotes for UIMAGE_NAME
- Fix a memory leak bug in Kconfig
-----BEGIN PGP SIGNATURE-----
iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmVaPGwVHG1hc2FoaXJv
eUBrZXJuZWwub3JnAAoJED2LAQed4NsGcCsP/RmB0YOMxnUsG7/OX+Wb1ULN13Y7
jWwwVEHU9k8GWrLfG/kDRROw1+VGGaP0l340YuTJWc8mqs+uiLNTzDIL8iRKPPTw
Og/dr+UzTxYI+8DaW5l062VwC4pRdtm4LfScihUtP19319f3sEMFxSFazIrJDDFs
/mZPu4WSvSOvzD5vxNfxrk6zlwMMKJ7vj9fwtHpZoiU299hHcS12IxHzsGGngRSE
/AJH8fLzmYToJY3ZF82MJm/xy6LDS1yfm7L+o5rcxNeFC3VizBjqW96EgWGxILuV
5zcDcPqfMLYF0UoNhgXhGEG1hJ7qBJ1JWEdozP2V8YmXnqM2PHhvcYC2MCjT+oY7
KC/Kket2N6s6FDE9RK8AkCc8t4mPnDMEot+t/YydBVAEE36f415UC7ocYho05ULz
r6lXWSCW1+yu58vBu9o9hJ3MMAdinyYHGPdP8a4rFhdlqlbad24cHtqlpO+HdSOA
2NV3Jt/48yoL2DBElNIjc5ynT2WRDXKgH63G5n+XKIN4AEdBj/zAPWhK3wXMNP0o
Lx+BB4ynWNEz8tDJv/P1Ay3MHhGGPI9FIDssn00qRDwuHtCs5AgzsUr1Dam9RHyd
Fy2Qes1xAoe4WsqcGB7Dz3D2VJuKm0EGF/U5iPtJ77hgdE0y6NafwrUamp3s/P9R
OAd+4YeA0VUnc9J6
=cAfu
-----END PGP SIGNATURE-----
Merge tag 'kbuild-fixes-v6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild fixes from Masahiro Yamada:
- Fix section mismatch warning messages for riscv and loongarch
- Remove CONFIG_IA64 left-over from linux/export-internal.h
- Fix the location of the quotes for UIMAGE_NAME
- Fix a memory leak bug in Kconfig
* tag 'kbuild-fixes-v6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
kconfig: fix memory leak from range properties
kbuild: Move the single quotes for image name
linux/export: clean up the IA-64 KSYM_FUNC macro
modpost: fix section mismatch message for RELA
Currently, sym_validate_range() duplicates the range string using
xstrdup(), which is overwritten by a subsequent sym_calc_value() call.
It results in a memory leak.
Instead, only the pointer should be copied.
Below is a test case, with a summary from Valgrind.
[Test Kconfig]
config FOO
int "foo"
range 10 20
[Test .config]
CONFIG_FOO=0
[Before]
LEAK SUMMARY:
definitely lost: 3 bytes in 1 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 17,465 bytes in 21 blocks
suppressed: 0 bytes in 0 blocks
[After]
LEAK SUMMARY:
definitely lost: 0 bytes in 0 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 17,462 bytes in 20 blocks
suppressed: 0 bytes in 0 blocks
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Add quotes where UIMAGE_NAME is used, rather than where it is defined.
This allows the UIMAGE_NAME variable to be set by the user.
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
The section mismatch check prints a bogus symbol name on some
architectures.
[test code]
#include <linux/init.h>
int __initdata foo;
int get_foo(void) { return foo; }
If you compile it with GCC for riscv or loongarch, modpost will show an
incorrect symbol name:
WARNING: modpost: vmlinux: section mismatch in reference: get_foo+0x8 (section: .text) -> done (section: .init.data)
To get the correct symbol address, the st_value must be added.
This issue has never been noticed since commit 93684d3b80 ("kbuild:
include symbol names in section mismatch warnings") presumably because
st_value becomes zero on most architectures when the referenced symbol
is looked up. It is not true for riscv or loongarch, at least.
With this fix, modpost will show the correct symbol name:
WARNING: modpost: vmlinux: section mismatch in reference: get_foo+0x8 (section: .text) -> foo (section: .init.data)
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>