aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Kconfig.include29
-rw-r--r--scripts/Kconfig.toolchain274
-rw-r--r--scripts/Makefile8
-rw-r--r--scripts/Makefile.autofdo2
-rw-r--r--scripts/Makefile.btf7
-rw-r--r--scripts/Makefile.build21
-rw-r--r--scripts/Makefile.gcc-plugins4
-rw-r--r--scripts/Makefile.lib4
-rw-r--r--scripts/Makefile.package2
-rw-r--r--scripts/Makefile.vmlinux20
-rw-r--r--scripts/Makefile.vmlinux_o2
-rw-r--r--scripts/Makefile.warn28
-rwxr-xr-xscripts/check-function-names.sh3
-rwxr-xr-xscripts/checkkconfigsymbols.py2
-rwxr-xr-xscripts/checkpatch.pl11
-rwxr-xr-xscripts/clang-tools/run-clang-tools.py1
-rw-r--r--scripts/coccinelle/api/kmalloc_objs.cocci161
-rwxr-xr-xscripts/container86
-rw-r--r--scripts/context-analysis-suppression.txt1
-rw-r--r--scripts/elf-parse.c103
-rw-r--r--scripts/elf-parse.h54
-rwxr-xr-xscripts/faddr2line2
-rw-r--r--scripts/gcc-plugins/randomize_layout_plugin.c63
-rw-r--r--scripts/gdb/linux/mm.py14
-rwxr-xr-xscripts/gen-btf.sh31
-rw-r--r--scripts/gen_init_cpio.c782
-rwxr-xr-xscripts/gen_initramfs.sh250
-rwxr-xr-xscripts/jobserver-exec3
-rw-r--r--scripts/kallsyms-sysmap.c248
-rw-r--r--scripts/kallsyms.c379
-rw-r--r--scripts/kallsyms.h44
-rw-r--r--scripts/kconfig/conf.c19
-rw-r--r--scripts/kconfig/confdata.c6
-rwxr-xr-xscripts/kconfig/kconfig-sym-check.pl2
-rw-r--r--scripts/kconfig/lexer.l3
-rw-r--r--scripts/kconfig/lkc.h2
-rw-r--r--scripts/kconfig/lkc_proto.h1
-rw-r--r--scripts/kconfig/lxdialog/textbox.c2
-rw-r--r--scripts/kconfig/menu.c66
-rw-r--r--scripts/kconfig/parser.y8
-rwxr-xr-xscripts/kconfig/streamline_config.pl20
-rw-r--r--scripts/kconfig/symbol.c106
-rw-r--r--scripts/kconfig/tests/conftest.py27
-rw-r--r--scripts/kconfig/tests/def_type/Kconfig28
-rw-r--r--scripts/kconfig/tests/def_type/__init__.py18
-rw-r--r--scripts/kconfig/tests/def_type/expected_guard_n9
-rw-r--r--scripts/kconfig/tests/def_type/expected_guard_y11
-rw-r--r--scripts/kconfig/tests/def_type/guard_n.config1
-rw-r--r--scripts/kconfig/tests/def_type/guard_y.config1
-rw-r--r--scripts/kconfig/tests/err_num_bounds/Kconfig79
-rw-r--r--scripts/kconfig/tests/err_num_bounds/__init__.py12
-rw-r--r--scripts/kconfig/tests/err_num_bounds/expected_stderr10
-rw-r--r--scripts/kconfig/tests/err_num_mismatch/Kconfig38
-rw-r--r--scripts/kconfig/tests/err_num_mismatch/__init__.py9
-rw-r--r--scripts/kconfig/tests/err_num_mismatch/expected_stderr4
-rw-r--r--scripts/kconfig/tests/err_num_non_numeric_ref/Kconfig75
-rw-r--r--scripts/kconfig/tests/err_num_non_numeric_ref/__init__.py9
-rw-r--r--scripts/kconfig/tests/err_num_non_numeric_ref/expected_stderr16
-rw-r--r--scripts/kconfig/tests/err_recursive_dep/Kconfig24
-rw-r--r--scripts/kconfig/tests/err_recursive_dep/expected_stderr13
-rw-r--r--scripts/kconfig/tests/randconfig_probability/Kconfig12
-rw-r--r--scripts/kconfig/tests/randconfig_probability/__init__.py130
-rw-r--r--scripts/kconfig/tests/savedefconfig_range/Kconfig67
-rw-r--r--scripts/kconfig/tests/savedefconfig_range/__init__.py8
-rw-r--r--scripts/kconfig/tests/savedefconfig_range/config8
-rw-r--r--scripts/kconfig/tests/savedefconfig_range/expected_defconfig0
-rw-r--r--scripts/kconfig/tests/warn_changed_input/Kconfig5
-rw-r--r--scripts/kconfig/tests/warn_changed_input/__init__.py21
-rw-r--r--scripts/kconfig/tests/warn_changed_input/expected_config1
-rw-r--r--scripts/kconfig/tests/warn_num_bounds/Kconfig24
-rw-r--r--scripts/kconfig/tests/warn_num_bounds/__init__.py25
-rw-r--r--scripts/kconfig/tests/warn_num_bounds/config7
-rw-r--r--scripts/kconfig/tests/warn_num_bounds/expected_config11
-rw-r--r--scripts/kconfig/tests/warn_num_bounds/expected_config_stderr3
-rw-r--r--scripts/kconfig/tests/warn_num_bounds/expected_frontend_config11
-rw-r--r--scripts/kconfig/tests/warn_num_bounds/expected_frontend_stderr0
-rwxr-xr-xscripts/link-vmlinux.sh32
-rwxr-xr-xscripts/make_fit.py3
-rwxr-xr-xscripts/mkcompile_h2
-rwxr-xr-xscripts/mksysmap94
-rw-r--r--scripts/mod/devicetable-offsets.c8
-rw-r--r--scripts/mod/file2alias.c20
-rw-r--r--scripts/mod/modpost.h2
-rw-r--r--scripts/package/kernel.spec10
-rwxr-xr-xscripts/remove-stale-files4
-rw-r--r--scripts/rustdoc_test_builder.rs7
-rw-r--r--scripts/rustdoc_test_gen.rs73
-rw-r--r--scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py2
-rwxr-xr-xscripts/setlocalversion3
-rw-r--r--scripts/sorttable.c15
-rwxr-xr-xscripts/ver_linux1
-rwxr-xr-xscripts/xz_wrap.sh5
93 files changed, 3402 insertions, 471 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 4215c2208f7e..700456543910 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
/asn1_compiler
+/gen_init_cpio
/gen_packed_field_checks
/generate_rust_target
/insert-sys-cert
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index fc10671c297c..a7d9201acfcc 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -23,13 +23,33 @@ success = $(if-success,$(1),y,n)
# Return n if <command> exits with 0, y otherwise
failure = $(if-success,$(1),n,y)
+# $(cc-probe,<flag>)
+# The command $(cc-option) and $(cc-option-str) test <flag> with. Not meant
+# to be called directly; use one of those two instead.
+cc-probe = trap "rm -rf .tmp_$$" EXIT; mkdir .tmp_$$; $(CC) -Werror $(CLANG_FLAGS) $(shell,echo $(1) | sed "s;^-Wno-;-W;") -c -x c /dev/null -o .tmp_$$/tmp.o
+
# $(cc-option,<flag>)
# Return y if the compiler supports <flag>, n otherwise
-cc-option = $(success,trap "rm -rf .tmp_$$" EXIT; mkdir .tmp_$$; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$/tmp.o)
+cc-option = $(success,$(cc-probe,$(1)))
+
+# $(cc-option-str,<flag>[,<fallback>])
+# Return <flag> if the compiler supports it, <fallback> otherwise.
+# <fallback> defaults to an empty string and is returned untested.
+cc-option-str = $(if-success,$(cc-probe,$(1)),$(1),$(2))
+
+# $(ld-probe,<flag>)
+# The command $(ld-option) and $(ld-option-str) test <flag> with. Not meant
+# to be called directly; use one of those two instead.
+ld-probe = $(LD) -v $(1)
# $(ld-option,<flag>)
# Return y if the linker supports <flag>, n otherwise
-ld-option = $(success,$(LD) -v $(1))
+ld-option = $(success,$(ld-probe,$(1)))
+
+# $(ld-option-str,<flag>[,<fallback>])
+# Return <flag> if the linker supports it, <fallback> otherwise.
+# <fallback> defaults to an empty string and is returned untested.
+ld-option-str = $(if-success,$(ld-probe,$(1)),$(1),$(2))
# $(as-instr,<instr>)
# Return y if the assembler supports <instr>, n otherwise
@@ -61,9 +81,8 @@ ld-version := $(shell,set -- $(ld-info) && echo $2)
# machine bit flags
# $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
# $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.
-cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1))
-m32-flag := $(cc-option-bit,-m32)
-m64-flag := $(cc-option-bit,-m64)
+m32-flag := $(cc-option-str,-m32)
+m64-flag := $(cc-option-str,-m64)
# Test whether the compiler can link userspace applications
cc_can_link_user = $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(1))
diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
new file mode 100644
index 000000000000..4b962831d62a
--- /dev/null
+++ b/scripts/Kconfig.toolchain
@@ -0,0 +1,274 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config CC_VERSION_TEXT
+ string
+ default "$(CC_VERSION_TEXT)"
+ help
+ This is used in unclear ways:
+
+ - Re-run Kconfig when the compiler is updated
+ The 'default' property references the environment variable,
+ CC_VERSION_TEXT so it is recorded in include/config/auto.conf.cmd.
+ When the compiler is updated, Kconfig will be invoked.
+
+ - Ensure full rebuild when the compiler is updated
+ include/linux/compiler-version.h contains this option in the comment
+ line so fixdep adds include/config/CC_VERSION_TEXT into the
+ auto-generated dependency. When the compiler is updated, syncconfig
+ will touch it and then every file will be rebuilt.
+
+config CC_IS_GCC
+ def_bool $(success,test "$(cc-name)" = GCC)
+
+config GCC_VERSION
+ int
+ default $(cc-version) if CC_IS_GCC
+ default 0
+
+config CC_IS_CLANG
+ def_bool $(success,test "$(cc-name)" = Clang)
+
+config CLANG_VERSION
+ int
+ default $(cc-version) if CC_IS_CLANG
+ default 0
+
+config AS_IS_GNU
+ def_bool $(success,test "$(as-name)" = GNU)
+
+config AS_IS_LLVM
+ def_bool $(success,test "$(as-name)" = LLVM)
+
+config AS_VERSION
+ int
+ # Use clang version if this is the integrated assembler
+ default CLANG_VERSION if AS_IS_LLVM
+ default $(as-version)
+
+config LD_IS_BFD
+ def_bool $(success,test "$(ld-name)" = BFD)
+
+config LD_VERSION
+ int
+ default $(ld-version) if LD_IS_BFD
+ default 0
+
+config LD_IS_LLD
+ def_bool $(success,test "$(ld-name)" = LLD)
+
+config LLD_VERSION
+ int
+ default $(ld-version) if LD_IS_LLD
+ default 0
+
+config RUSTC_VERSION
+ int
+ default $(rustc-version)
+ help
+ It does not depend on `RUST` since that one may need to use the version
+ in a `depends on`.
+
+config RUST_IS_AVAILABLE
+ def_bool $(success,$(srctree)/scripts/rust_is_available.sh)
+ help
+ This shows whether a suitable Rust toolchain is available (found).
+
+ Please see Documentation/rust/quick-start.rst for instructions on how
+ to satisfy the build requirements of Rust support.
+
+ In particular, the Makefile target 'rustavailable' is useful to check
+ why the Rust toolchain is not being detected.
+
+config RUSTC_LLVM_VERSION
+ int
+ default $(rustc-llvm-version)
+
+config RUSTC_LLVM_MAJOR_VERSION
+ int
+ default $(shell,expr $(rustc-llvm-version) / 10000)
+
+config RUSTC_CLANG_LLVM_COMPATIBLE
+ bool
+ default y if CC_IS_CLANG && RUSTC_LLVM_MAJOR_VERSION = $(shell,expr $(cc-version) / 10000)
+ help
+ This indicates whether Rust and Clang use LLVM of the same major
+ version.
+
+ Operations involving handling LLVM IR or bitcode (e.g. cross-language
+ LTO) require the same LLVM major version to work properly. For best
+ compatibility it is recommended that the exact same LLVM is used.
+
+config ARCH_HAS_CC_CAN_LINK
+ bool
+
+config CC_CAN_LINK
+ bool
+ default ARCH_CC_CAN_LINK if ARCH_HAS_CC_CAN_LINK
+ default $(cc_can_link_user,$(m64-flag)) if 64BIT
+ default $(cc_can_link_user,$(m32-flag))
+
+# Fixed in GCC 14, 13.3, 12.4 and 11.5
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113921
+config GCC_ASM_GOTO_OUTPUT_BROKEN
+ bool
+ depends on CC_IS_GCC
+ default y if GCC_VERSION < 110500
+ default y if GCC_VERSION >= 120000 && GCC_VERSION < 120400
+ default y if GCC_VERSION >= 130000 && GCC_VERSION < 130300
+
+config CC_HAS_ASM_GOTO_OUTPUT
+ def_bool y
+ depends on !GCC_ASM_GOTO_OUTPUT_BROKEN
+ depends on $(success,echo 'int foo(int x) { asm goto ("": "=r"(x) ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null)
+
+config CC_HAS_ASM_GOTO_TIED_OUTPUT
+ depends on CC_HAS_ASM_GOTO_OUTPUT
+ # Detect buggy gcc and clang, fixed in gcc-11 clang-14.
+ def_bool $(success,echo 'int foo(int *x) { asm goto (".long (%l[bar]) - .": "+m"(*x) ::: bar); return *x; bar: return 0; }' | $CC -x c - -c -o /dev/null)
+
+config TOOLS_SUPPORT_RELR
+ def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh)
+
+config CC_HAS_ASM_INLINE
+ def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null)
+
+config CC_HAS_ASSUME
+ bool
+ # clang needs to be at least 19.1.0 since the meaning of the assume
+ # attribute changed:
+ # https://github.com/llvm/llvm-project/commit/c44fa3e8a9a44c2e9a575768a3c185354b9f6c17
+ default y if CC_IS_CLANG && CLANG_VERSION >= 190100
+ # supported since gcc 13.1.0
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106654
+ default y if CC_IS_GCC && GCC_VERSION >= 130100
+
+config CC_HAS_NO_PROFILE_FN_ATTR
+ def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
+
+config CC_OPT_ZERO_INIT_PADDING_BITS
+ def_string "$(cc-option-str,-fzero-init-padding-bits=all)"
+
+config CC_OPT_NO_ADDRSIG
+ def_string "$(cc-option-str,-fno-addrsig)"
+
+config CC_OPT_DIAGNOSTICS_SHOW_CONTEXT
+ def_string "$(cc-option-str,-fdiagnostics-show-context=2)"
+
+config CC_OPT_DIAGNOSTICS_SHOW_INLINING_CHAIN
+ def_string "$(cc-option-str,-fdiagnostics-show-inlining-chain)"
+
+config CC_OPT_STRICT_FLEX_ARRAYS
+ def_string "$(cc-option-str,-fstrict-flex-arrays=3)"
+
+# gcc-10 renamed --param=allow-store-data-races=0 to -fno-allow-store-data-races
+config CC_OPT_ALLOW_STORE_DATA_RACES_PARAM
+ def_string "$(cc-option-str,--param=allow-store-data-races=0)"
+
+config CC_OPT_NO_ALLOW_STORE_DATA_RACES
+ def_string "$(cc-option-str,-fno-allow-store-data-races)"
+
+config CC_HAS_MNOP_MCOUNT
+ def_bool $(cc-option,-mnop-mcount)
+
+# s390-linux-gnu-gcc did not support -mfentry until gcc-9.
+config CC_HAS_MFENTRY
+ def_bool $(cc-option,-mfentry)
+
+config LD_OPT_FORCE_GROUP_ALLOCATION
+ def_string "$(ld-option-str,--force-group-allocation)"
+
+config LD_OPT_NO_WARN_RWX_SEGMENTS
+ def_string "$(ld-option-str,--no-warn-rwx-segments)"
+
+config CC_OPT_WNO_ADDRESS_OF_PACKED_MEMBER
+ def_string "$(cc-option-str,-Wno-address-of-packed-member)"
+
+config CC_OPT_WNO_FORMAT_OVERFLOW_NON_KPRINTF
+ def_string "$(cc-option-str,-Wno-format-overflow-non-kprintf)"
+
+config CC_OPT_WNO_FORMAT_TRUNCATION_NON_KPRINTF
+ def_string "$(cc-option-str,-Wno-format-truncation-non-kprintf)"
+
+config CC_OPT_WNO_DEFAULT_CONST_INIT_UNSAFE
+ def_string "$(cc-option-str,-Wno-default-const-init-unsafe)"
+
+config CC_OPT_WNO_DANGLING_POINTER
+ def_string "$(cc-option-str,-Wno-dangling-pointer)"
+
+config CC_OPT_WVLA_LARGER_THAN
+ def_string "$(cc-option-str,-Wvla-larger-than=1)"
+
+config CC_HAS_WSTRINGOP_OVERFLOW
+ def_bool $(cc-option,-Wstringop-overflow)
+
+config CC_OPT_WNO_UNTERMINATED_STRING_INITIALIZATION
+ def_string "$(cc-option-str,-Wno-unterminated-string-initialization)"
+
+config CC_OPT_WERROR_DESIGNATED_INIT
+ def_string "$(cc-option-str,-Werror=designated-init)"
+
+config CC_OPT_WENUM_CONVERSION
+ def_string "$(cc-option-str,-Wenum-conversion)"
+
+config CC_OPT_WNO_PACKED_NOT_ALIGNED
+ def_string "$(cc-option-str,-Wno-packed-not-aligned)"
+
+config CC_OPT_WNO_FORMAT_OVERFLOW
+ def_string "$(cc-option-str,-Wno-format-overflow)"
+
+config CC_OPT_WNO_STRINGOP_TRUNCATION
+ def_string "$(cc-option-str,-Wno-stringop-truncation)"
+
+config CC_HAS_COUNTED_BY
+ bool
+ # clang needs to be at least 20.1.0 to avoid potential crashes
+ # when building structures that contain __counted_by
+ # https://github.com/ClangBuiltLinux/linux/issues/2114
+ # https://github.com/llvm/llvm-project/commit/160fb1121cdf703c3ef5e61fb26c5659eb581489
+ default y if CC_IS_CLANG && CLANG_VERSION >= 200100
+ # supported since gcc 15.1.0
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
+ default y if CC_IS_GCC && GCC_VERSION >= 150100
+
+config CC_HAS_COUNTED_BY_PTR
+ bool
+ # supported since clang 22
+ default y if CC_IS_CLANG && CLANG_VERSION >= 220100
+ # supported since gcc 16.0.0
+ default y if CC_IS_GCC && GCC_VERSION >= 160000
+
+config CC_HAS_BROKEN_COUNTED_BY_REF
+ bool
+ # https://github.com/llvm/llvm-project/issues/182575
+ default y if CC_IS_CLANG && CLANG_VERSION < 220100
+
+config CC_HAS_ALLOC_TOKEN
+ def_bool $(cc-option,-falloc-token-max=123)
+
+config CC_HAS_MULTIDIMENSIONAL_NONSTRING
+ def_bool $(success,echo 'char tag[][4] __attribute__((__nonstring__)) = { };' | $(CC) $(CLANG_FLAGS) -x c - -c -o /dev/null -Werror)
+
+config CC_OPT_INLINE_MEMSET
+ string
+ default "-finline-stringops=memset" if $(cc-option,-finline-stringops=memset)
+ default "-mllvm -max-store-memset=4294967294" if $(cc-option,-mllvm -max-store-memset=4294967294)
+
+config LD_CAN_USE_KEEP_IN_OVERLAY
+ # ld.lld prior to 21.0.0 did not support KEEP within an overlay description
+ # https://github.com/llvm/llvm-project/pull/130661
+ def_bool LD_IS_BFD || LLD_VERSION >= 210000
+
+config RUSTC_HAS_UNNECESSARY_TRANSMUTES
+ def_bool RUSTC_VERSION >= 108800
+
+config RUSTC_HAS_FILE_WITH_NUL
+ def_bool RUSTC_VERSION >=