1 #!/bin/sh 1 #!/bin/sh 2 # SPDX-License-Identifier: GPL-2.0-only 2 # SPDX-License-Identifier: GPL-2.0-only 3 # 3 # 4 # Staring v4.18, Kconfig evaluates compiler ca 4 # Staring v4.18, Kconfig evaluates compiler capabilities, and hides CONFIG 5 # options your compiler does not support. This 5 # options your compiler does not support. This works well if you configure and 6 # build the kernel on the same host machine. 6 # build the kernel on the same host machine. 7 # 7 # 8 # It is inconvenient if you prepare the .confi 8 # It is inconvenient if you prepare the .config that is carried to a different 9 # build environment (typically this happens wh 9 # build environment (typically this happens when you package the kernel for 10 # distros) because using a different compiler 10 # distros) because using a different compiler potentially produces different 11 # CONFIG options than the real build environme 11 # CONFIG options than the real build environment. So, you probably want to make 12 # as many options visible as possible. In othe 12 # as many options visible as possible. In other words, you need to create a 13 # super-set of CONFIG options that cover any b 13 # super-set of CONFIG options that cover any build environment. If some of the 14 # CONFIG options turned out to be unsupported 14 # CONFIG options turned out to be unsupported on the build machine, they are 15 # automatically disabled by the nature of Kcon 15 # automatically disabled by the nature of Kconfig. 16 # 16 # 17 # However, it is not feasible to get a full-fe 17 # However, it is not feasible to get a full-featured compiler for every arch. 18 # Hence these dummy toolchains to make all com 18 # Hence these dummy toolchains to make all compiler tests pass. 19 # 19 # 20 # Usage: 20 # Usage: 21 # 21 # 22 # From the top directory of the source tree, r 22 # From the top directory of the source tree, run 23 # 23 # 24 # $ make CROSS_COMPILE=scripts/dummy-tools/ 24 # $ make CROSS_COMPILE=scripts/dummy-tools/ oldconfig 25 # 25 # 26 # Most of compiler features are tested by cc-o 26 # Most of compiler features are tested by cc-option, which simply checks the 27 # exit code of $(CC). This script does nothing 27 # exit code of $(CC). This script does nothing and just exits with 0 in most 28 # cases. So, $(cc-option, ...) is evaluated as 28 # cases. So, $(cc-option, ...) is evaluated as 'y'. 29 # 29 # 30 # This scripts caters to more checks; handle - 30 # This scripts caters to more checks; handle --version and pre-process __GNUC__ 31 # etc. to pretend to be GCC, and also do right 31 # etc. to pretend to be GCC, and also do right things to satisfy some scripts. 32 32 33 # Check if the first parameter appears in the 33 # Check if the first parameter appears in the rest. Succeeds if found. 34 # This helper is useful if a particular option 34 # This helper is useful if a particular option was passed to this script. 35 # Typically used like this: 35 # Typically used like this: 36 # arg_contain <word-you-are-searching-for> " 36 # arg_contain <word-you-are-searching-for> "$@" 37 arg_contain () 37 arg_contain () 38 { 38 { 39 search="$1" 39 search="$1" 40 shift 40 shift 41 41 42 while [ $# -gt 0 ] 42 while [ $# -gt 0 ] 43 do 43 do 44 if [ "$search" = "$1" ]; then 44 if [ "$search" = "$1" ]; then 45 return 0 45 return 0 46 fi 46 fi 47 shift 47 shift 48 done 48 done 49 49 50 return 1 50 return 1 51 } 51 } 52 52 53 # To set CONFIG_CC_IS_GCC=y 53 # To set CONFIG_CC_IS_GCC=y 54 if arg_contain --version "$@"; then 54 if arg_contain --version "$@"; then 55 echo "gcc (scripts/dummy-tools/gcc)" 55 echo "gcc (scripts/dummy-tools/gcc)" 56 exit 0 56 exit 0 57 fi 57 fi 58 58 59 if arg_contain -E "$@"; then 59 if arg_contain -E "$@"; then 60 # For scripts/cc-version.sh; This emul 60 # For scripts/cc-version.sh; This emulates GCC 20.0.0 61 if arg_contain - "$@"; then 61 if arg_contain - "$@"; then 62 sed -n '/^GCC/{s/__GNUC__/20/; !! 62 sed -n '/^GCC/{s/__GNUC__/20/; s/__GNUC_MINOR__/0/; s/__GNUC_PATCHLEVEL__/0/; p;}' 63 exit 0 63 exit 0 64 else 64 else 65 echo "no input files" >&2 65 echo "no input files" >&2 66 exit 1 66 exit 1 67 fi 67 fi 68 fi 68 fi 69 69 70 # To set CONFIG_AS_IS_GNU 70 # To set CONFIG_AS_IS_GNU 71 if arg_contain -Wa,--version "$@"; then 71 if arg_contain -Wa,--version "$@"; then 72 echo "GNU assembler (scripts/dummy-too 72 echo "GNU assembler (scripts/dummy-tools) 2.50" 73 exit 0 73 exit 0 74 fi 74 fi 75 75 76 if arg_contain -S "$@"; then 76 if arg_contain -S "$@"; then 77 # For scripts/gcc-x86-*-has-stack-prot 77 # For scripts/gcc-x86-*-has-stack-protector.sh 78 if arg_contain -fstack-protector "$@"; 78 if arg_contain -fstack-protector "$@"; then 79 if arg_contain -mstack-protect 79 if arg_contain -mstack-protector-guard-reg=fs "$@"; then 80 echo "%fs" 80 echo "%fs" 81 else 81 else 82 echo "%gs" 82 echo "%gs" 83 fi 83 fi 84 exit 0 84 exit 0 85 fi 85 fi 86 86 87 # For arch/powerpc/tools/gcc-check-mpr 87 # For arch/powerpc/tools/gcc-check-mprofile-kernel.sh 88 if arg_contain -m64 "$@" && arg_contai !! 88 if arg_contain -m64 "$@" && arg_contain -mlittle-endian "$@" && >> 89 arg_contain -mprofile-kernel "$@"; then 89 if ! test -t 0 && ! grep -q no 90 if ! test -t 0 && ! grep -q notrace; then 90 echo "_mcount" 91 echo "_mcount" 91 fi 92 fi 92 exit 0 << 93 fi << 94 << 95 # For arch/powerpc/tools/gcc-check-fpa << 96 if arg_contain -m64 "$@" && arg_contai << 97 echo "func:" << 98 echo ".section __patchable_fun << 99 echo ".localentry" << 100 echo " nop" << 101 echo " nop" << 102 exit 0 93 exit 0 103 fi 94 fi 104 fi 95 fi 105 96 106 # To set GCC_PLUGINS 97 # To set GCC_PLUGINS 107 if arg_contain -print-file-name=plugin "$@"; t 98 if arg_contain -print-file-name=plugin "$@"; then 108 # Use $0 to find the in-tree dummy dir 99 # Use $0 to find the in-tree dummy directory 109 echo "$(dirname "$(readlink -f "$0")") 100 echo "$(dirname "$(readlink -f "$0")")/dummy-plugin-dir" 110 exit 0 101 exit 0 111 fi 102 fi 112 103 113 # inverted return value 104 # inverted return value 114 if arg_contain -D__SIZEOF_INT128__=0 "$@"; the 105 if arg_contain -D__SIZEOF_INT128__=0 "$@"; then 115 exit 1 106 exit 1 116 fi 107 fi
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.