18c2ecf20Sopenharmony_ci#!/bin/sh 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only 38c2ecf20Sopenharmony_ci# 48c2ecf20Sopenharmony_ci# Staring v4.18, Kconfig evaluates compiler capabilities, and hides CONFIG 58c2ecf20Sopenharmony_ci# options your compiler does not support. This works well if you configure and 68c2ecf20Sopenharmony_ci# build the kernel on the same host machine. 78c2ecf20Sopenharmony_ci# 88c2ecf20Sopenharmony_ci# It is inconvenient if you prepare the .config that is carried to a different 98c2ecf20Sopenharmony_ci# build environment (typically this happens when you package the kernel for 108c2ecf20Sopenharmony_ci# distros) because using a different compiler potentially produces different 118c2ecf20Sopenharmony_ci# CONFIG options than the real build environment. So, you probably want to make 128c2ecf20Sopenharmony_ci# as many options visible as possible. In other words, you need to create a 138c2ecf20Sopenharmony_ci# super-set of CONFIG options that cover any build environment. If some of the 148c2ecf20Sopenharmony_ci# CONFIG options turned out to be unsupported on the build machine, they are 158c2ecf20Sopenharmony_ci# automatically disabled by the nature of Kconfig. 168c2ecf20Sopenharmony_ci# 178c2ecf20Sopenharmony_ci# However, it is not feasible to get a full-featured compiler for every arch. 188c2ecf20Sopenharmony_ci# Hence these dummy toolchains to make all compiler tests pass. 198c2ecf20Sopenharmony_ci# 208c2ecf20Sopenharmony_ci# Usage: 218c2ecf20Sopenharmony_ci# 228c2ecf20Sopenharmony_ci# From the top directory of the source tree, run 238c2ecf20Sopenharmony_ci# 248c2ecf20Sopenharmony_ci# $ make CROSS_COMPILE=scripts/dummy-tools/ oldconfig 258c2ecf20Sopenharmony_ci# 268c2ecf20Sopenharmony_ci# Most of compiler features are tested by cc-option, which simply checks the 278c2ecf20Sopenharmony_ci# exit code of $(CC). This script does nothing and just exits with 0 in most 288c2ecf20Sopenharmony_ci# cases. So, $(cc-option, ...) is evaluated as 'y'. 298c2ecf20Sopenharmony_ci# 308c2ecf20Sopenharmony_ci# This scripts caters to more checks; handle --version and pre-process __GNUC__ 318c2ecf20Sopenharmony_ci# etc. to pretend to be GCC, and also do right things to satisfy some scripts. 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci# Check if the first parameter appears in the rest. Succeeds if found. 348c2ecf20Sopenharmony_ci# This helper is useful if a particular option was passed to this script. 358c2ecf20Sopenharmony_ci# Typically used like this: 368c2ecf20Sopenharmony_ci# arg_contain <word-you-are-searching-for> "$@" 378c2ecf20Sopenharmony_ciarg_contain () 388c2ecf20Sopenharmony_ci{ 398c2ecf20Sopenharmony_ci search="$1" 408c2ecf20Sopenharmony_ci shift 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci while [ $# -gt 0 ] 438c2ecf20Sopenharmony_ci do 448c2ecf20Sopenharmony_ci if [ "$search" = "$1" ]; then 458c2ecf20Sopenharmony_ci return 0 468c2ecf20Sopenharmony_ci fi 478c2ecf20Sopenharmony_ci shift 488c2ecf20Sopenharmony_ci done 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci return 1 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci# To set CONFIG_CC_IS_GCC=y 548c2ecf20Sopenharmony_ciif arg_contain --version "$@"; then 558c2ecf20Sopenharmony_ci echo "gcc (scripts/dummy-tools/gcc)" 568c2ecf20Sopenharmony_ci exit 0 578c2ecf20Sopenharmony_cifi 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciif arg_contain -E "$@"; then 608c2ecf20Sopenharmony_ci # For scripts/gcc-version.sh; This emulates GCC 20.0.0 618c2ecf20Sopenharmony_ci if arg_contain - "$@"; then 628c2ecf20Sopenharmony_ci sed 's/^__GNUC__$/20/; s/^__GNUC_MINOR__$/0/; s/^__GNUC_PATCHLEVEL__$/0/' 638c2ecf20Sopenharmony_ci exit 0 648c2ecf20Sopenharmony_ci else 658c2ecf20Sopenharmony_ci echo "no input files" >&2 668c2ecf20Sopenharmony_ci exit 1 678c2ecf20Sopenharmony_ci fi 688c2ecf20Sopenharmony_cifi 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci# To set CONFIG_AS_IS_GNU 718c2ecf20Sopenharmony_ciif arg_contain -Wa,--version "$@"; then 728c2ecf20Sopenharmony_ci echo "GNU assembler (scripts/dummy-tools) 2.50" 738c2ecf20Sopenharmony_ci exit 0 748c2ecf20Sopenharmony_cifi 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciif arg_contain -S "$@"; then 778c2ecf20Sopenharmony_ci # For scripts/gcc-x86-*-has-stack-protector.sh 788c2ecf20Sopenharmony_ci if arg_contain -fstack-protector "$@"; then 798c2ecf20Sopenharmony_ci echo "%gs" 808c2ecf20Sopenharmony_ci exit 0 818c2ecf20Sopenharmony_ci fi 828c2ecf20Sopenharmony_cifi 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci# To set GCC_PLUGINS 858c2ecf20Sopenharmony_ciif arg_contain -print-file-name=plugin "$@"; then 868c2ecf20Sopenharmony_ci # Use $0 to find the in-tree dummy directory 878c2ecf20Sopenharmony_ci echo "$(dirname "$(readlink -f "$0")")/dummy-plugin-dir" 888c2ecf20Sopenharmony_ci exit 0 898c2ecf20Sopenharmony_cifi 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci# inverted return value 928c2ecf20Sopenharmony_ciif arg_contain -D__SIZEOF_INT128__=0 "$@"; then 938c2ecf20Sopenharmony_ci exit 1 948c2ecf20Sopenharmony_cifi 95