gcc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-only
  3. #
  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.
  7. #
  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.
  16. #
  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.
  19. #
  20. # Usage:
  21. #
  22. # From the top directory of the source tree, run
  23. #
  24. # $ make CROSS_COMPILE=scripts/dummy-tools/ oldconfig
  25. #
  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'.
  29. #
  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.
  32. # Check if the first parameter appears in the rest. Succeeds if found.
  33. # This helper is useful if a particular option was passed to this script.
  34. # Typically used like this:
  35. # arg_contain <word-you-are-searching-for> "$@"
  36. arg_contain ()
  37. {
  38. search="$1"
  39. shift
  40. while [ $# -gt 0 ]
  41. do
  42. if [ "$search" = "$1" ]; then
  43. return 0
  44. fi
  45. shift
  46. done
  47. return 1
  48. }
  49. # To set CONFIG_CC_IS_GCC=y
  50. if arg_contain --version "$@"; then
  51. echo "gcc (scripts/dummy-tools/gcc)"
  52. exit 0
  53. fi
  54. if arg_contain -E "$@"; then
  55. # For scripts/cc-version.sh; This emulates GCC 20.0.0
  56. if arg_contain - "$@"; then
  57. sed -n '/^GCC/{s/__GNUC__/20/; s/__GNUC_MINOR__/0/; s/__GNUC_PATCHLEVEL__/0/; p;}; s/__LONG_DOUBLE_128__/1/ p'
  58. exit 0
  59. else
  60. echo "no input files" >&2
  61. exit 1
  62. fi
  63. fi
  64. # To set CONFIG_AS_IS_GNU
  65. if arg_contain -Wa,--version "$@"; then
  66. echo "GNU assembler (scripts/dummy-tools) 2.50"
  67. exit 0
  68. fi
  69. if arg_contain -S "$@"; then
  70. # For scripts/gcc-x86-*-has-stack-protector.sh
  71. if arg_contain -fstack-protector "$@"; then
  72. if arg_contain -mstack-protector-guard-reg=fs "$@"; then
  73. echo "%fs"
  74. else
  75. echo "%gs"
  76. fi
  77. exit 0
  78. fi
  79. # For arch/powerpc/tools/gcc-check-mprofile-kernel.sh
  80. if arg_contain -m64 "$@" && arg_contain -mlittle-endian "$@" &&
  81. arg_contain -mprofile-kernel "$@"; then
  82. if ! test -t 0 && ! grep -q notrace; then
  83. echo "_mcount"
  84. fi
  85. exit 0
  86. fi
  87. fi
  88. # To set GCC_PLUGINS
  89. if arg_contain -print-file-name=plugin "$@"; then
  90. # Use $0 to find the in-tree dummy directory
  91. echo "$(dirname "$(readlink -f "$0")")/dummy-plugin-dir"
  92. exit 0
  93. fi
  94. # inverted return value
  95. if arg_contain -D__SIZEOF_INT128__=0 "$@"; then
  96. exit 1
  97. fi