2 # SPDX-License-Identifier: GPL-2.0-only
4 # Staring v4.18, Kconfig evaluates compiler capabilities, and hides CONFIG
5 # options your compiler does not support. This works well if you configure and
6 # build the kernel on the same host machine.
8 # It is inconvenient if you prepare the .config that is carried to a different
9 # build environment (typically this happens when you package the kernel for
10 # distros) because using a different compiler potentially produces different
11 # CONFIG options than the real build environment. So, you probably want to make
12 # as many options visible as possible. In other words, you need to create a
13 # super-set of CONFIG options that cover any build environment. If some of the
14 # CONFIG options turned out to be unsupported on the build machine, they are
15 # automatically disabled by the nature of Kconfig.
17 # However, it is not feasible to get a full-featured compiler for every arch.
18 # Hence these dummy toolchains to make all compiler tests pass.
22 # From the top directory of the source tree, run
24 # $ make CROSS_COMPILE=scripts/dummy-tools/ oldconfig
26 # Most of compiler features are tested by cc-option, which simply checks the
27 # exit code of $(CC). This script does nothing and just exits with 0 in most
28 # cases. So, $(cc-option, ...) is evaluated as 'y'.
30 # This scripts caters to more checks; handle --version and pre-process __GNUC__
31 # etc. to pretend to be GCC, and also do right things to satisfy some scripts.
33 # Check if the first parameter appears in the rest. Succeeds if found.
34 # This helper is useful if a particular option was passed to this script.
35 # Typically used like this:
36 # arg_contain <word-you-are-searching-for> "$@"
44 if [ "$search" = "$1" ]; then
53 # To set CONFIG_CC_IS_GCC=y
54 if arg_contain --version "$@"; then
55 echo "gcc (scripts/dummy-tools/gcc)"
59 if arg_contain -E "$@"; then
60 # For scripts/cc-version.sh; This emulates GCC 20.0.0
61 if arg_contain - "$@"; then
62 sed -n '/^GCC/{s/__GNUC__/20/; s/__GNUC_MINOR__/0/; s/__GNUC_PATCHLEVEL__/0/; p;}'
65 echo "no input files" >&2
70 # To set CONFIG_AS_IS_GNU
71 if arg_contain -Wa,--version "$@"; then
72 echo "GNU assembler (scripts/dummy-tools) 2.50"
76 if arg_contain -S "$@"; then
77 # For scripts/gcc-x86-*-has-stack-protector.sh
78 if arg_contain -fstack-protector "$@"; then
79 if arg_contain -mstack-protector-guard-reg=fs "$@"; then
87 # For arch/powerpc/tools/gcc-check-mprofile-kernel.sh
88 if arg_contain -m64 "$@" && arg_contain -mlittle-endian "$@" &&
89 arg_contain -mprofile-kernel "$@"; then
90 if ! test -t 0 && ! grep -q notrace; then
98 if arg_contain -print-file-name=plugin "$@"; then
99 # Use $0 to find the in-tree dummy directory
100 echo "$(dirname "$(readlink -f "$0")")/dummy-plugin-dir"
104 # inverted return value
105 if arg_contain -D__SIZEOF_INT128__=0 "$@"; then