10 Aug, 2020
2 commits
-
The conditional:
ifneq ($(hostprogs),)
... is evaluated to true if $(hostprogs) does not contain any word but
whitespace characters.ifneq ($(strip $(hostprogs)),)
... is a safe way to avoid interpreting whitespace as a non-empty value,
but I'd rather want to use the side-effect of $(sort ...) to do the
equivalent.$(sort ...) is used in scripts/Makefile.host in order to drop duplication
in $(hostprogs). It is also useful to strip excessive spaces.Move $(sort ...) before evaluating the ifneq.
Signed-off-by: Masahiro Yamada
-
The host shared library rules are currently implemented in
scripts/Makefile.host, but actually GCC-plugin is the only user of
them. (The VDSO .so files are built for the target by different
build rules) Hence, they do not need to be treewide available.Move all the relevant build rules to scripts/gcc-plugins/Makefile.
I also optimized the build steps so *.so is directly built from .c
because every upstream plugin is compiled from a single source file.I am still keeping the multi-file plugin support, which Kees Cook
mentioned might be needed by out-of-tree plugins.
(https://lkml.org/lkml/2019/1/11/1107)If the plugin, foo.so, is compiled from two files foo.c and foo2.c,
then you can do like follows:foo-objs := foo.o foo2.o
Single-file plugins do not need the *-objs notation.
Signed-off-by: Masahiro Yamada
Acked-by: Kees Cook
12 May, 2020
1 commit
-
This omits system headers from the generated header dependency.
System headers are not updated unless you upgrade the compiler. Nor do
they contain CONFIG options, so fixdep does not need to parse them.Having said that, the effect of this optimization will be quite small
because the kernel code generally does not include system headers
except . Host programs include a lot of system headers,
but there are not so many in the kernel tree.At first, keeping system headers in .*.cmd files might be useful to
detect the compiler update, but there is no guarantee that
is included from every file. So, I implemented a more reliable way in
the previous commit.Signed-off-by: Masahiro Yamada
08 Apr, 2020
1 commit
-
Nobody was opposed to raising minimum GCC version to 4.8 [1]
So, we will drop GCC = 4.8.This commit drops the plugin support for GCC
Acked-by: Kees Cook
04 Feb, 2020
1 commit
-
In old days, the "host-progs" syntax was used for specifying host
programs. It was renamed to the current "hostprogs-y" in 2004.It is typically useful in scripts/Makefile because it allows Kbuild to
selectively compile host programs based on the kernel configuration.This commit renames like follows:
always -> always-y
hostprogs-y -> hostprogsSo, scripts/Makefile will look like this:
always-$(CONFIG_BUILD_BIN2C) += ...
always-$(CONFIG_KALLSYMS) += ...
...
hostprogs := $(always-y) $(always-m)I think this makes more sense because a host program is always a host
program, irrespective of the kernel configuration. We want to specify
which ones to compile by CONFIG options, so always-y will be handier.The "always", "hostprogs-y", "hostprogs-m" will be kept for backward
compatibility for a while.Signed-off-by: Masahiro Yamada
04 Sep, 2019
1 commit
-
Kbuild provides per-file compiler flag addition/removal:
CFLAGS_.o
CFLAGS_REMOVE_.o
AFLAGS_.o
AFLAGS_REMOVE_.o
CPPFLAGS_.lds
HOSTCFLAGS_.o
HOSTCXXFLAGS_.oThe is the filename of the target with its directory and
suffix stripped.This syntax comes into a trouble when two files with the same basename
appear in one Makefile, for example:obj-y += foo.o
obj-y += dir/foo.o
CFLAGS_foo.o :=Here, the applies to both foo.o and dir/foo.o
The real world problem is:
scripts/kconfig/util.c
scripts/kconfig/lxdialog/util.cBoth files are compiled into scripts/kconfig/mconf, but only the
latter should be given with the ncurses flags.It is more sensible to use the relative path to the Makefile, like this:
obj-y += foo.o
CFLAGS_foo.o :=
obj-y += dir/foo.o
CFLAGS_dir/foo.o :=At first, I attempted to replace $(basetarget) with $*. The $* variable
is replaced with the stem ('%') part in a pattern rule. This works with
most of cases, but does not for explicit rules.For example, arch/ia64/lib/Makefile reuses rule_as_o_S in its own
explicit rules, so $* will be empty, resulting in ignoring the per-file
AFLAGS.I introduced a new variable, target-stem, which can be used also from
explicit rules.Signed-off-by: Masahiro Yamada
Acked-by: Marc Zyngier
14 Aug, 2019
1 commit
-
Flex and bison are used for kconfig, dtc, genksyms, all of which are
host programs. I never imagine the kernel embeds a parser or a lexer.Move the flex and bison rules to scripts/Makefile.host. This file is
included only when hostprogs-y etc. is present in the Makefile in the
directory. So, parsing these rules are skipped in most of directories.Signed-off-by: Masahiro Yamada
13 Jul, 2019
1 commit
-
Pull Kbuild updates from Masahiro Yamada:
- remove headers_{install,check}_all targets
- remove unreasonable 'depends on !UML' from CONFIG_SAMPLES
- re-implement 'make headers_install' more cleanly
- add new header-test-y syntax to compile-test headers
- compile-test exported headers to ensure they are compilable in
user-space- compile-test headers under include/ to ensure they are self-contained
- remove -Waggregate-return, -Wno-uninitialized, -Wno-unused-value
flags- add -Werror=unknown-warning-option for Clang
- add 128-bit built-in types support to genksyms
- fix missed rebuild of modules.builtin
- propagate 'No space left on device' error in fixdep to Make
- allow Clang to use its integrated assembler
- improve some coccinelle scripts
- add a new flag KBUILD_ABS_SRCTREE to request Kbuild to use absolute
path for $(srctree).- do not ignore errors when compression utility is missing
- misc cleanups
* tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (49 commits)
kbuild: use -- separater intead of $(filter-out ...) for cc-cross-prefix
kbuild: Inform user to pass ARCH= for make mrproper
kbuild: fix compression errors getting ignored
kbuild: add a flag to force absolute path for srctree
kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree
kbuild: remove src and obj from the top Makefile
scripts/tags.sh: remove unused environment variables from comments
scripts/tags.sh: drop SUBARCH support for ARM
kbuild: compile-test kernel headers to ensure they are self-contained
kheaders: include only headers into kheaders_data.tar.xz
kheaders: remove meaningless -R option of 'ls'
kbuild: support header-test-pattern-y
kbuild: do not create wrappers for header-test-y
kbuild: compile-test exported headers to ensure they are self-contained
init/Kconfig: add CONFIG_CC_CAN_LINK
kallsyms: exclude kasan local symbols on s390
kbuild: add more hints about SUBDIRS replacement
coccinelle: api/stream_open: treat all wait_.*() calls as blocking
coccinelle: put_device: Add a cast to an expression for an assignment
coccinelle: put_device: Adjust a message construction
...
10 Jul, 2019
1 commit
-
Commit 25b146c5b8ce ("kbuild: allow Kbuild to start from any directory")
deprecated KBUILD_SRCTREE.It is only used in tools/testing/selftest/ to distinguish out-of-tree
build. Replace it with a new boolean flag, building_out_of_srctree.I also replaced the conditional ($(srctree),.) because the next commit
will allow an absolute path to be used for $(srctree) even when building
in the source tree.Signed-off-by: Masahiro Yamada
15 Jun, 2019
1 commit
-
The kbuild documentation clearly shows that the documents
there are written at different times: some use markdown,
some use their own peculiar logic to split sections.Convert everything to ReST without affecting too much
the author's style and avoiding adding uneeded markups.The conversion is actually:
- add blank lines and identation in order to identify paragraphs;
- fix tables markups;
- add some lists markups;
- mark literal blocks;
- adjust title markups.At its new index.rst, let's add a :orphan: while this is not linked to
the main index.rst file, in order to avoid build warnings.Signed-off-by: Mauro Carvalho Chehab
Signed-off-by: Jonathan Corbet
18 May, 2019
1 commit
-
The 'addtree' and 'flags' in scripts/Kbuild.include are so compilecated
and ugly.As I mentioned in [1], Kbuild should stop automatic prefixing of header
search path options.I fixed up (almost) all Makefiles in the kernel. Now 'addtree' and
'flags' have been removed.Kbuild still caters to add $(srctree)/$(src) and $(objtree)/$(obj)
to the header search path for O= building, but never touches extra
compiler options from ccflags-y etc.[1]: https://patchwork.kernel.org/patch/9632347/
Signed-off-by: Masahiro Yamada
02 Apr, 2019
1 commit
-
KBUILD_SRC was conventionally used for some different purposes:
[1] To remember the source tree path
[2] As a flag to check if sub-make is already done
[3] As a flag to check if Kbuild runs out of treeFor [1], we do not need to remember it because the top Makefile
can compute it by $(realpath $(dir $(lastword $(MAKEFILE_LIST))))[2] has been replaced with self-commenting 'sub_make_done'.
For [3], we can distinguish in-tree/out-of-tree by comparing
$(srctree) and '.'This commit converts [3] to prepare for the KBUILD_SRC removal.
Signed-off-by: Masahiro Yamada
28 Jan, 2019
1 commit
-
When building an external module, $(obj) is the absolute path to it.
The header search paths from ccflags-y etc. should not be tweaked.
Signed-off-by: Masahiro Yamada
18 Jul, 2018
4 commits
-
In preparation for enabling command line LDLIBS, re-name HOST_LOADLIBES
to KBUILD_HOSTLDLIBS as the internal use only flags. Also rename
existing usage to HOSTLDLIBS for consistency. This should not have any
visible effects.Signed-off-by: Laura Abbott
Signed-off-by: Masahiro Yamada -
In preparation for enabling command line LDFLAGS, re-name HOSTLDFLAGS
to KBUILD_HOSTLDFLAGS as the internal use only flags. This should not
have any visible effects.Signed-off-by: Laura Abbott
Signed-off-by: Masahiro Yamada -
In preparation for enabling command line CXXFLAGS, re-name HOSTCXXFLAGS
to KBUILD_HOSTCXXFLAGS as the internal use only flags. This should not
have any visible effects.Signed-off-by: Laura Abbott
Signed-off-by: Masahiro Yamada -
In preparation for enabling command line CFLAGS, re-name HOSTCFLAGS to
KBUILD_HOSTCFLAGS as the internal use only flags. This should not have
any visible effects.Signed-off-by: Laura Abbott
Signed-off-by: Masahiro Yamada
07 Apr, 2018
1 commit
-
When compiling executables from a single .c file, the linker is also
invoked. Pass the HOSTLDFLAGS like for other linker commands.Signed-off-by: Robin Jarry
Cc: Josh Poimboeuf
Cc: Ingo Molnar
Signed-off-by: Masahiro Yamada
18 Nov, 2017
1 commit
-
Pull Kbuild updates from Masahiro Yamada:
"One of the most remarkable improvements in this cycle is, Kbuild is
now able to cache the result of shell commands. Some variables are
expensive to compute, for example, $(call cc-option,...) invokes the
compiler. It is not efficient to redo this computation every time,
even when we are not actually building anything. Kbuild creates a
hidden file ".cache.mk" that contains invoked shell commands and their
results. The speed-up should be noticeable.Summary:
- Fix arch build issues (hexagon, sh)
- Clean up various Makefiles and scripts
- Fix wrong usage of {CFLAGS,LDFLAGS}_MODULE in arch Makefiles
- Cache variables that are expensive to compute
- Improve cc-ldopton and ld-option for Clang
- Optimize output directory creation"
* tag 'kbuild-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (30 commits)
kbuild: move coccicheck help from scripts/Makefile.help to top Makefile
sh: decompressor: add shipped files to .gitignore
frv: .gitignore: ignore vmlinux.lds
selinux: remove unnecessary assignment to subdir-
kbuild: specify FORCE in Makefile.headersinst as .PHONY target
kbuild: remove redundant mkdir from ./Kbuild
kbuild: optimize object directory creation for incremental build
kbuild: create object directories simpler and faster
kbuild: filter-out PHONY targets from "targets"
kbuild: remove redundant $(wildcard ...) for cmd_files calculation
kbuild: create directory for make cache only when necessary
sh: select KBUILD_DEFCONFIG depending on ARCH
kbuild: fix linker feature test macros when cross compiling with Clang
kbuild: shrink .cache.mk when it exceeds 1000 lines
kbuild: do not call cc-option before KBUILD_CFLAGS initialization
kbuild: Cache a few more calls to the compiler
kbuild: Add a cache for generated variables
kbuild: add forward declaration of default target to Makefile.asm-generic
kbuild: remove KBUILD_SUBDIR_ASFLAGS and KBUILD_SUBDIR_CCFLAGS
hexagon/kbuild: replace CFLAGS_MODULE with KBUILD_CFLAGS_MODULE
...
16 Nov, 2017
1 commit
-
For the out-of-tree build, scripts/Makefile.build creates output
directories, but this operation is not efficient.scripts/Makefile.lib calculates obj-dirs as follows:
obj-dirs := $(dir $(multi-objs) $(obj-y))
Please notice $(sort ...) is not used here. Usually the result is
as many "./" as objects here.For a lot of duplicated paths, the following command is invoked.
_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
Then, the costly shell command is run over and over again.
I see many points for optimization:
[1] Use $(sort ...) to cut down duplicated paths before passing them
to system call
[2] Use single $(shell ...) instead of repeating it with $(foreach ...)
This will reduce forking.
[3] We can calculate obj-dirs more simply. Most of objects are already
accumulated in $(targets). So, $(dir $(targets)) is fine and more
comprehensive.I also removed ugly code in arch/x86/entry/vdso/Makefile. This is now
really unnecessary.Signed-off-by: Masahiro Yamada
Acked-by: Ingo Molnar
Tested-by: Douglas Anderson
02 Nov, 2017
1 commit
-
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.By default all files without license information are under the default
license of the kernel, which is GPL version 2.Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if
Reviewed-by: Philippe Ombredanne
Reviewed-by: Thomas Gleixner
Signed-off-by: Greg Kroah-Hartman
25 Jun, 2017
1 commit
-
cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines
whether an option is supported or not. This is fine for options used to
build the kernel itself, however some components like the x86 boot code
use a different set of flags.Add the new macro __cc-option which is a more generic version of
cc-option with additional parameters. One parameter is the compiler
with which the check should be performed, the other the compiler options
to be used instead KBUILD_C*FLAGS.Refactor cc-option and hostcc-option to use __cc-option and move
hostcc-option to scripts/Kbuild.include.Suggested-by: Arnd Bergmann
Suggested-by: Masahiro Yamada
Signed-off-by: Matthias Kaehlcke
Acked-by: Arnd Bergmann
Acked-by: Michal Marek
Signed-off-by: Masahiro Yamada
08 Jun, 2016
1 commit
-
Infrastructure for building independent shared library targets.
Based on work created by the PaX Team.
Signed-off-by: Emese Revfy
Acked-by: Kees Cook
Signed-off-by: Michal Marek
19 Aug, 2014
1 commit
-
Assume we have a Makefile like:
hostprogs-y := foo bar
foo-objs := foo1.o foo2.o
bar-objs := bar1.o bar2.oWithout this commit, the host program foo depends on all of
foo1.o foo2.o bar1.o bar2.o.This commit allows to handle the dependency of each host program
separately.Signed-off-by: Masahiro Yamada
Signed-off-by: Michal Marek
16 Jul, 2014
5 commits
-
Assume we have a Makefile like this:
hostprogs-y := foo
foo-cxxobjs := bar/baz.o
foo-objs := qux/quux.oIn this case, Kbuild creates bar/ directory,
but fails to create qux/ directory.This commit re-writes directory creation more simply,
fixing that bug.Signed-off-by: Masahiro Yamada
Signed-off-by: Michal Marek -
The directory creation can be more simplified by two levels.
[1] Drop $(dir ...)
$(dir $(f)) always returns non-empty string.
So, $(if $(dir $(f)),$(dir $(f)) is equivalent to $(dir $(f)).
[2] Unroll $(foreach ...) loop
$(dir ...) can take one or more arguments and returns a list of
directories of them.$(foreach f, $(progs), $(dir $(f))) can be unrolled as $(dir $(progs)).
Signed-off-by: Masahiro Yamada
Signed-off-by: Michal Marek -
The shared library feature in Makefile.host is no longer used.
Rip it off to keep the build infrastucture simple.Update Documentation/kbuild/makefiles.txt too.
The section "4.3 Definition shared libraries" should be removed
and the following sections should be re-numbered.Signed-off-by: Masahiro Yamada
Suggested-by: Sam Ravnborg
Signed-off-by: Michal Marek -
The comment claims:
C++ executables compiled from at least one .cc file
and zero or more .c filesBut C++ executables with zero .c file fail in build.
For example, assume we have a Makefile like this:
hostprogs-y := foo
foo-cxxobjs := bar.oIn this case, foo is treated as host-csingle
and Kbuild tries to search non-existing foo.c source.Signed-off-by: Masahiro Yamada
Signed-off-by: Michal Marek -
Signed-off-by: Masahiro Yamada
Signed-off-by: Michal Marek
13 Jun, 2014
1 commit
-
Pull kbuild misc updates from Michal Marek:
"This is the non-critical part of kbuild for v3.16-rc1:
- make deb-pkg can do s390x and arm64
- new patterns in scripts/tags.sh
- scripts/tags.sh skips userspace tools' sources (which sometimes
have copies of kernel structures) and symlinks
- improvements to the objdiff tool
- two new coccinelle patches
- other minor fixes"* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
scripts: objdiff: support directories for the augument of record command
scripts: objdiff: fix a comment
scripts: objdiff: change the extension of disassembly from .o to .dis
scripts: objdiff: improve path flexibility for record command
scripts: objdiff: remove unnecessary code
scripts: objdiff: direct error messages to stderr
scripts: objdiff: get the path to .tmp_objdiff more simply
deb-pkg: Add automatic support for s390x architecture
coccicheck: Add unneeded return variable test
kbuild: Fix a typo in documentation
kbuild: trivial - use tabs for code indent where possible
kbuild: trivial - remove trailing empty lines
coccinelle: Check for missing NULL terminators in of_device_id tables
scripts/tags.sh: ignore symlink'ed source files
scripts/tags.sh: add regular expression replacement pattern for memcg
builddeb: add arm64 in the supported architectures
builddeb: use $OBJCOPY variable instead of objcopy
scripts/tags.sh: ignore code of user space tools
scripts/tags.sh: add pattern for DEFINE_HASHTABLE
.gitignore: ignore Module.symvers in all directories
10 Jun, 2014
1 commit
-
Signed-off-by: Masahiro Yamada
30 Apr, 2014
1 commit
-
Signed-off-by: Masahiro Yamada
Signed-off-by: Michal Marek
26 Apr, 2008
1 commit
-
Signed-off-by: Robert P. J. Day
Signed-off-by: Sam Ravnborg
06 May, 2007
1 commit
-
To introduce support for source in one directory but output files
in another directory during a non O= build prefix all paths
with $(src) repsectively $(obj).Signed-off-by: Sam Ravnborg
25 Sep, 2006
2 commits
-
Signed-off-by: Sam Ravnborg
-
hostprogs-y only supported creating output directory for the final
program. Extend this to also cover the situation where a .o
file (used when host program is made from compositie objects) is
locate in another directory.
First user of this is the built-in lxdialog that.Signed-off-by: Sam Ravnborg
17 Sep, 2006
1 commit
-
Signed-off-by: Ross Biro
Acked-by: Sam Ravnborg
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
01 Jul, 2006
1 commit
-
kbuild used $¤(*F to get filename of target without extension.
This was used in several places all over kbuild, but introducing
make -rR broke his for all cases where we specified full path to
target/prerequsite. It is assumed that make -rR disables old style
suffix-rules which is why is suddenly failed.ia64 was impacted by this change because several div* routines in
arch/ia64/lib are build using explicit paths and then kbuild failed.Thanks to David Mosberger-Tang for an explanation
what was the root-cause and for testing on ia64.This patch also fixes two uses of $(*F) in arch/um
Signed-off-by: Sam Ravnborg
27 Jun, 2006
1 commit
-
This reverts commit e5c44fd88c146755da6941d047de4d97651404a9.
Thanks to Daniel Ritz and Michal Piotrowski for noticing the problem.
Daniel says:
"[The] reason is a recent change that made modules always shows as
module.mod. it breaks modprobe and probably many scripts..besides
lsmod looking horriblestuff like this in modprobe.conf:
install pcmcia_core /sbin/modprobe --ignore-install pcmcia_core; /sbin/modprobe pcmcia
makes modprobe fork/exec endlessly calling itself...until oom
interrupts it"Signed-off-by: Linus Torvalds
25 Jun, 2006
1 commit
-
make failed to supply the filename when using make -rR and using $(*F)
to get target filename without extension.
This bug was not reproduceable in small scale but using:
$(basename $(notdir $@)) fixes it with same functionality.Signed-off-by: Sam Ravnborg