kbuild: add dummy toolchains to enable all cc-option etc. in Kconfig
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 7 Apr 2020 15:53:52 +0000 (00:53 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 8 Apr 2020 15:13:45 +0000 (00:13 +0900)
commit76426e238834f0927dee9925e8832179b8d56d6e
treef907bea1fb4870f52202542d097f9a06563ea076
parent7273ad2b08f8ac9563579d16a3cf528857b26f49
kbuild: add dummy toolchains to enable all cc-option etc. in Kconfig

Staring v4.18, Kconfig evaluates compiler capabilities, and hides CONFIG
options your compiler does not support. This works well if you configure
and build the kernel on the same host machine.

It is inconvenient if you prepare the .config that is carried to a
different build environment (typically this happens when you package
the kernel for distros) because using a different compiler potentially
produces different CONFIG options than the real build environment.
So, you probably want to make as many options visible as possible.
In other words, you need to create a super-set of CONFIG options that
cover any build environment. If some of the CONFIG options turned out
to be unsupported on the build machine, they are automatically disabled
by the nature of Kconfig.

However, it is not feasible to get a full-featured compiler for every
arch.

This issue was discussed here:

  https://lkml.org/lkml/2019/12/9/620

Other than distros, savedefconfig is also a problem. Some arch sub-systems
periodically resync defconfig files. If you use a less-capable compiler
for savedefconfig, options that do not meet 'depends on $(cc-option,...)'
will be forcibly disabled. So, 'make defconfig && make savedefconfig'
may silently change the behavior.

This commit adds a set of dummy toolchains that pretend to support any
feature.

Most of compiler features are tested by cc-option, which simply checks
the exit code of $(CC). The dummy tools are shell scripts that always
exit with 0. So, $(cc-option, ...) is evaluated as 'y'.

There are more complicated checks such as:

  scripts/gcc-x86_{32,64}-has-stack-protector.sh
  scripts/gcc-plugin.sh
  scripts/tools-support-relr.sh

scripts/dummy-tools/gcc passes all checks.

From the top directory of the source tree, you can do:

   $ make CROSS_COMPILE=scripts/dummy-tools/ oldconfig

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Tested-by: Jeremy Cline <jcline@redhat.com>
scripts/dummy-tools/gcc [new file with mode: 0755]
scripts/dummy-tools/ld [new file with mode: 0755]
scripts/dummy-tools/nm [new symlink]
scripts/dummy-tools/objcopy [new symlink]