help me, what is this witchcraft

This commit is contained in:
SaschaNes
2025-08-12 20:55:37 +02:00
parent 65a1eeb079
commit 4a4cd14ef8
5 changed files with 1528 additions and 181 deletions

436
Makefile
View File

@@ -5,16 +5,13 @@ SUBLEVEL = 30
EXTRAVERSION = EXTRAVERSION =
NAME = Hurr durr I'ma ninja sloth NAME = Hurr durr I'ma ninja sloth
# *DOCUMENTATION* # *DOCUMENTATION*
# To see a list of typical targets execute "make help" # To see a list of typical targets execute "make help"
# More info can be located in ./README # More info can be located in ./README
# Comments in this file are targeted only to the developer, do not # Comments in this file are targeted only to the developer, do not
# expect to learn how to build the kernel reading this file. # expect to learn how to build the kernel reading this file.
ifeq ($(filter undefine,$(.FEATURES)),)
$(error GNU Make >= 3.82 is required. Your Make version is $(MAKE_VERSION))
endif
$(if $(filter __%, $(MAKECMDGOALS)), \ $(if $(filter __%, $(MAKECMDGOALS)), \
$(error targets prefixed with '__' are only for internal use)) $(error targets prefixed with '__' are only for internal use))
@@ -38,10 +35,6 @@ __all:
# descending is started. They are now explicitly listed as the # descending is started. They are now explicitly listed as the
# prepare rule. # prepare rule.
this-makefile := $(lastword $(MAKEFILE_LIST))
export abs_srctree := $(realpath $(dir $(this-makefile)))
export abs_objtree := $(CURDIR)
ifneq ($(sub_make_done),1) ifneq ($(sub_make_done),1)
# Do not use make's built-in rules and variables # Do not use make's built-in rules and variables
@@ -60,21 +53,26 @@ unexport GREP_OPTIONS
# Beautify output # Beautify output
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
# Most of build commands in Kbuild start with "cmd_". You can optionally define # Normally, we echo the whole command before executing it. By making
# "quiet_cmd_*". If defined, the short log is printed. Otherwise, no log from # that echo $($(quiet)$(cmd)), we now have the possibility to set
# that command is printed by default. # $(quiet) to choose other forms of output instead, e.g.
# #
# e.g.) # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
# quiet_cmd_depmod = DEPMOD $(MODLIB) # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
# cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE) #
# If $(quiet) is empty, the whole command will be printed.
# If it is set to "quiet_", only the short version will be printed.
# If it is set to "silent_", nothing will be printed at all, since
# the variable $(silent_cmd_cc_o_c) doesn't exist.
# #
# A simple variant is to prefix commands with $(Q) - that's useful # A simple variant is to prefix commands with $(Q) - that's useful
# for commands that shall be hidden in non-verbose mode. # for commands that shall be hidden in non-verbose mode.
# #
# $(Q)$(MAKE) $(build)=scripts/basic # $(Q)ln $@ :<
# #
# If KBUILD_VERBOSE contains 1, the whole command is echoed. # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
# If KBUILD_VERBOSE contains 2, the reason for rebuilding is printed. # If KBUILD_VERBOSE equals 1 then the above command is displayed.
# If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt.
# #
# To put more focus on warnings, be less verbose as default # To put more focus on warnings, be less verbose as default
# Use 'make V=1' to see the full commands # Use 'make V=1' to see the full commands
@@ -82,13 +80,16 @@ unexport GREP_OPTIONS
ifeq ("$(origin V)", "command line") ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V) KBUILD_VERBOSE = $(V)
endif endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
quiet = quiet_ ifeq ($(KBUILD_VERBOSE),1)
Q = @
ifneq ($(findstring 1, $(KBUILD_VERBOSE)),)
quiet = quiet =
Q = Q =
else
quiet=quiet_
Q = @
endif endif
# If the user is running make -s (silent mode), suppress echoing of # If the user is running make -s (silent mode), suppress echoing of
@@ -96,14 +97,14 @@ endif
# make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS. # make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
ifeq ($(filter 3.%,$(MAKE_VERSION)),) ifeq ($(filter 3.%,$(MAKE_VERSION)),)
short-opts := $(firstword -$(MAKEFLAGS)) silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
else else
short-opts := $(filter-out --%,$(MAKEFLAGS)) silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
endif endif
ifneq ($(findstring s,$(short-opts)),) ifeq ($(silence),s)
quiet=silent_ quiet=silent_
override KBUILD_VERBOSE := KBUILD_VERBOSE = 0
endif endif
export quiet Q KBUILD_VERBOSE export quiet Q KBUILD_VERBOSE
@@ -207,12 +208,32 @@ $(if $(abs_objtree),, \
# $(realpath ...) resolves symlinks # $(realpath ...) resolves symlinks
abs_objtree := $(realpath $(abs_objtree)) abs_objtree := $(realpath $(abs_objtree))
else
abs_objtree := $(CURDIR)
endif # ifneq ($(KBUILD_OUTPUT),) endif # ifneq ($(KBUILD_OUTPUT),)
ifeq ($(abs_objtree),$(CURDIR))
# Suppress "Entering directory ..." unless we are changing the work directory.
MAKEFLAGS += --no-print-directory
else
need-sub-make := 1
endif
this-makefile := $(lastword $(MAKEFILE_LIST))
abs_srctree := $(realpath $(dir $(this-makefile)))
ifneq ($(words $(subst :, ,$(abs_srctree))), 1) ifneq ($(words $(subst :, ,$(abs_srctree))), 1)
$(error source directory cannot contain spaces or colons) $(error source directory cannot contain spaces or colons)
endif endif
ifneq ($(abs_srctree),$(abs_objtree))
# Look for make include files relative to root of kernel src
#
# --included-dir is added for backward compatibility, but you should not rely on
# it. Please add $(srctree)/ prefix to include Makefiles in the source tree.
MAKEFLAGS += --include-dir=$(abs_srctree)
endif
ifneq ($(filter 3.%,$(MAKE_VERSION)),) ifneq ($(filter 3.%,$(MAKE_VERSION)),)
# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
# We need to invoke sub-make to avoid implicit rules in the top Makefile. # We need to invoke sub-make to avoid implicit rules in the top Makefile.
@@ -221,25 +242,9 @@ need-sub-make := 1
$(this-makefile): ; $(this-makefile): ;
endif endif
export abs_srctree abs_objtree
export sub_make_done := 1 export sub_make_done := 1
endif # sub_make_done
ifeq ($(abs_objtree),$(CURDIR))
# Suppress "Entering directory ..." if we are at the final work directory.
no-print-directory := --no-print-directory
else
# Recursion to show "Entering directory ..."
need-sub-make := 1
endif
ifeq ($(filter --no-print-directory, $(MAKEFLAGS)),)
# If --no-print-directory is unset, recurse once again to set it.
# You may end up recursing into __sub-make twice. This is needed due to the
# behavior change in GNU Make 4.4.1.
need-sub-make := 1
endif
ifeq ($(need-sub-make),1) ifeq ($(need-sub-make),1)
PHONY += $(MAKECMDGOALS) __sub-make PHONY += $(MAKECMDGOALS) __sub-make
@@ -249,12 +254,18 @@ $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
# Invoke a second make in the output directory, passing relevant variables # Invoke a second make in the output directory, passing relevant variables
__sub-make: __sub-make:
$(Q)$(MAKE) $(no-print-directory) -C $(abs_objtree) \ $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
-f $(abs_srctree)/Makefile $(MAKECMDGOALS)
else # need-sub-make endif # need-sub-make
endif # sub_make_done
# We process the rest of the Makefile if this is the final invocation of make # We process the rest of the Makefile if this is the final invocation of make
ifeq ($(need-sub-make),)
# Do not print "Entering directory ...",
# but we want to display it when entering to the output directory
# so that IDEs/editors are able to understand relative filenames.
MAKEFLAGS += --no-print-directory
ifeq ($(abs_srctree),$(abs_objtree)) ifeq ($(abs_srctree),$(abs_objtree))
# building in the source tree # building in the source tree
@@ -298,10 +309,10 @@ no-dot-config-targets := $(clean-targets) \
# Installation targets should not require compiler. Unfortunately, vdso_install # Installation targets should not require compiler. Unfortunately, vdso_install
# is an exception where build artifacts may be updated. This must be fixed. # is an exception where build artifacts may be updated. This must be fixed.
no-compiler-targets := $(no-dot-config-targets) install dtbs_install \ no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
headers_install modules_install modules_sign kernelrelease image_name headers_install modules_install kernelrelease image_name
no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \ no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
image_name image_name
single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/ single-targets := %.a %.i %.rsi %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
config-build := config-build :=
mixed-build := mixed-build :=
@@ -384,7 +395,7 @@ else # !mixed-build
include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Kbuild.include
# Read KERNELRELEASE from include/config/kernel.release (if it exists) # Read KERNELRELEASE from include/config/kernel.release (if it exists)
KERNELRELEASE = $(call read-file, include/config/kernel.release) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
@@ -467,7 +478,8 @@ HOSTRUSTC = rustc
HOSTPKG_CONFIG = pkg-config HOSTPKG_CONFIG = pkg-config
KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
-O2 -fomit-frame-pointer -std=gnu11 -O2 -fomit-frame-pointer -std=gnu11 \
-Wdeclaration-after-statement
KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
KBUILD_USERLDFLAGS := $(USERLDFLAGS) KBUILD_USERLDFLAGS := $(USERLDFLAGS)
@@ -485,7 +497,6 @@ export rust_common_flags := --edition=2021 \
-Dclippy::let_unit_value -Dclippy::mut_mut \ -Dclippy::let_unit_value -Dclippy::mut_mut \
-Dclippy::needless_bitwise_bool \ -Dclippy::needless_bitwise_bool \
-Dclippy::needless_continue \ -Dclippy::needless_continue \
-Dclippy::no_mangle_with_rust_abi \
-Wclippy::dbg_macro -Wclippy::dbg_macro
KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
@@ -528,6 +539,7 @@ LEX = flex
YACC = bison YACC = bison
AWK = awk AWK = awk
INSTALLKERNEL := installkernel INSTALLKERNEL := installkernel
DEPMOD = depmod
PERL = perl PERL = perl
PYTHON3 = python3 PYTHON3 = python3
CHECK = sparse CHECK = sparse
@@ -573,17 +585,14 @@ LINUXINCLUDE := \
$(USERINCLUDE) $(USERINCLUDE)
KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
KBUILD_CFLAGS := -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
KBUILD_CFLAGS += -std=gnu11 -Werror=implicit-function-declaration -Werror=implicit-int \
KBUILD_CFLAGS += -fshort-wchar -Werror=return-type -Wno-format-security \
KBUILD_CFLAGS += -funsigned-char -std=gnu11
KBUILD_CFLAGS += -fno-common
KBUILD_CFLAGS += -fno-PIE
KBUILD_CFLAGS += -fno-strict-aliasing
KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_RUSTFLAGS := $(rust_common_flags) \ KBUILD_RUSTFLAGS := $(rust_common_flags) \
--target=$(objtree)/rust/target.json \
-Cpanic=abort -Cembed-bitcode=n -Clto=n \ -Cpanic=abort -Cembed-bitcode=n -Clto=n \
-Cforce-unwind-tables=n -Ccodegen-units=1 \ -Cforce-unwind-tables=n -Ccodegen-units=1 \
-Csymbol-mangling-version=v0 \ -Csymbol-mangling-version=v0 \
@@ -834,6 +843,10 @@ endif # may-sync-config
endif # need-config endif # need-config
KBUILD_CFLAGS += -fno-delete-null-pointer-checks KBUILD_CFLAGS += -fno-delete-null-pointer-checks
KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
KBUILD_CFLAGS += -O2 KBUILD_CFLAGS += -O2
@@ -864,15 +877,40 @@ ifdef CONFIG_READABLE_ASM
KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
endif endif
ifneq ($(CONFIG_FRAME_WARN),0)
KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
endif
stackp-flags-y := -fno-stack-protector stackp-flags-y := -fno-stack-protector
stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
KBUILD_CFLAGS += $(stackp-flags-y) KBUILD_CFLAGS += $(stackp-flags-y)
KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y) KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y)
ifdef CONFIG_CC_IS_CLANG
KBUILD_CPPFLAGS += -Qunused-arguments
# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
KBUILD_CFLAGS += -Wno-gnu
else
# gcc inanely warns about local variables called 'main'
KBUILD_CFLAGS += -Wno-main
endif
# These warnings generated too much noise in a regular build.
# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
# These result in bogus false positives
KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
ifdef CONFIG_FRAME_POINTER ifdef CONFIG_FRAME_POINTER
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
@@ -899,9 +937,7 @@ ifdef CONFIG_INIT_STACK_ALL_ZERO
KBUILD_CFLAGS += -ftrivial-auto-var-init=zero KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
ifdef CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO_ENABLER ifdef CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO_ENABLER
# https://github.com/llvm/llvm-project/issues/44842 # https://github.com/llvm/llvm-project/issues/44842
CC_AUTO_VAR_INIT_ZERO_ENABLER := -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
export CC_AUTO_VAR_INIT_ZERO_ENABLER
KBUILD_CFLAGS += $(CC_AUTO_VAR_INIT_ZERO_ENABLER)
endif endif
endif endif
@@ -925,9 +961,7 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
endif endif
endif endif
ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
ifdef CONFIG_HAVE_OBJTOOL_NOP_MCOUNT
CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
endif
endif endif
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
ifdef CONFIG_HAVE_C_RECORDMCOUNT ifdef CONFIG_HAVE_C_RECORDMCOUNT
@@ -963,7 +997,6 @@ ifdef CONFIG_SHADOW_CALL_STACK
ifndef CONFIG_DYNAMIC_SCS ifndef CONFIG_DYNAMIC_SCS
CC_FLAGS_SCS := -fsanitize=shadow-call-stack CC_FLAGS_SCS := -fsanitize=shadow-call-stack
KBUILD_CFLAGS += $(CC_FLAGS_SCS) KBUILD_CFLAGS += $(CC_FLAGS_SCS)
KBUILD_RUSTFLAGS += -Zsanitizer=shadow-call-stack
endif endif
export CC_FLAGS_SCS export CC_FLAGS_SCS
endif endif
@@ -989,7 +1022,7 @@ KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
# Check for frame size exceeding threshold during prolog/epilog insertion # Check for frame size exceeding threshold during prolog/epilog insertion
# when using lld < 13.0.0. # when using lld < 13.0.0.
ifneq ($(CONFIG_FRAME_WARN),0) ifneq ($(CONFIG_FRAME_WARN),0)
ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y) ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN) KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
endif endif
endif endif
@@ -1003,34 +1036,58 @@ endif
ifdef CONFIG_CFI_CLANG ifdef CONFIG_CFI_CLANG
CC_FLAGS_CFI := -fsanitize=kcfi CC_FLAGS_CFI := -fsanitize=kcfi
ifdef CONFIG_RUST
# If Rust is enabled, this flag is required to support cross-language
# integer types.
# This addresses the problem that on e.g. i686, int != long, and Rust
# maps both to i32.
# See https://rcvalle.com/docs/rust-cfi-design-doc.pdf for details.
$(error "Enabling Rust and CFI silently changes the KMI.")
CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers
RS_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
KBUILD_RUSTFLAGS += $(RS_FLAGS_CFI)
export RS_FLAGS_CFI
endif
KBUILD_CFLAGS += $(CC_FLAGS_CFI) KBUILD_CFLAGS += $(CC_FLAGS_CFI)
export CC_FLAGS_CFI export CC_FLAGS_CFI
endif endif
ifneq ($(CONFIG_FUNCTION_ALIGNMENT),0) ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B
KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT) KBUILD_CFLAGS += -falign-functions=64
endif endif
# arch Makefile may override CC so keep this after arch Makefile is included # arch Makefile may override CC so keep this after arch Makefile is included
NOSTDINC_FLAGS += -nostdinc NOSTDINC_FLAGS += -nostdinc
# To gain proper coverage for CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE, # warn about C99 declaration after statement
# the kernel uses only C99 flexible arrays for dynamically sized trailing KBUILD_CFLAGS += -Wdeclaration-after-statement
# arrays. Enforce this for everything that may examine structure sizes and
# perform bounds checking. # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) KBUILD_CFLAGS += -Wvla
# disable pointer signed / unsigned warnings in gcc 4.0
KBUILD_CFLAGS += -Wno-pointer-sign
# In order to make sure new function cast mismatches are not introduced
# in the kernel (to avoid tripping CFI checking), the kernel should be
# globally built with -Wcast-function-type.
KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
# disable stringop warnings in gcc 8+
KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
# We'll want to enable this eventually, but it's not going away for 5.7 at least
KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
# Another good warning that we'll want to enable eventually
KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
# Enabled with W=2, disabled by default as noisy
ifdef CONFIG_CC_IS_GCC
KBUILD_CFLAGS += -Wno-maybe-uninitialized
endif
# The allocators already balk at large sizes, so silence the compiler
# warnings for bounds checks involving those possible values. While
# -Wno-alloc-size-larger-than would normally be used here, earlier versions
# of gcc (<9.1) weirdly don't handle the option correctly when _other_
# warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX
# doesn't work (as it is documented to), silently resolving to "0" prior to
# version 9.1 (and producing an error more recently). Numeric values larger
# than PTRDIFF_MAX also don't work prior to version 9.1, which are silently
# ignored, continuing to default to PTRDIFF_MAX. So, left with no other
# choice, we must perform a versioned check to disable this warning.
# https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au
KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
# disable invalid "can't wrap" optimizations for signed / pointers # disable invalid "can't wrap" optimizations for signed / pointers
KBUILD_CFLAGS += -fno-strict-overflow KBUILD_CFLAGS += -fno-strict-overflow
@@ -1043,6 +1100,15 @@ ifdef CONFIG_CC_IS_GCC
KBUILD_CFLAGS += -fconserve-stack KBUILD_CFLAGS += -fconserve-stack
endif endif
# Prohibit date/time macros, which would make the build non-deterministic
KBUILD_CFLAGS += -Werror=date-time
# enforce correct pointer usage
KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
# Require designated initializers for all marked structures
KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
# change __FILE__ to the relative path from the srctree # change __FILE__ to the relative path from the srctree
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
@@ -1082,14 +1148,13 @@ LDFLAGS_vmlinux += -X
endif endif
ifeq ($(CONFIG_RELR),y) ifeq ($(CONFIG_RELR),y)
# ld.lld before 15 did not support -z pack-relative-relocs. LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs)
endif endif
# We never want expected sections to be placed heuristically by the # We never want expected sections to be placed heuristically by the
# linker. All sections should be explicitly named in the linker script. # linker. All sections should be explicitly named in the linker script.
ifdef CONFIG_LD_ORPHAN_WARN ifdef CONFIG_LD_ORPHAN_WARN
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) LDFLAGS_vmlinux += --orphan-handling=warn
endif endif
# Align the bit size of userspace programs with the kernel # Align the bit size of userspace programs with the kernel
@@ -1144,6 +1209,10 @@ export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
PHONY += headers PHONY += headers
ext-mod-dir := ../sm8650-modules
ext-mod-dirs := $(ext-mod-dir)/qcom/opensource/audio-kernel $(ext-mod-dir)/qcom/opensource/dataipa/drivers/platform/msm $(ext-mod-dir)/qcom/opensource/display-drivers $(ext-mod-dir)/qcom/opensource/video-kernel $(ext-mod-dir)/nxp/opensource/driver
ext-mod-dirs := $(subst $(srctree)/,,$(ext-mod-dirs))
#Default location for installed headers #Default location for installed headers
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
PHONY += archheaders archscripts PHONY += archheaders archscripts
@@ -1172,6 +1241,9 @@ ifeq ($(KBUILD_EXTMOD),)
endif endif
$(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi
$(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi
$(Q)for d in $(ext-mod-dirs); do \
$(MAKE) $(hdr-inst)=$$d/include/uapi; \
done
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Devicetree files # Devicetree files
@@ -1251,12 +1323,28 @@ endif
export KBUILD_VMLINUX_LIBS export KBUILD_VMLINUX_LIBS
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
# Recurse until adjust_autoksyms.sh is satisfied
PHONY += autoksyms_recursive
ifdef CONFIG_TRIM_UNUSED_KSYMS ifdef CONFIG_TRIM_UNUSED_KSYMS
# For the kernel to actually contain only the needed exported symbols, # For the kernel to actually contain only the needed exported symbols,
# we have to build modules as well to determine what those symbols are. # we have to build modules as well to determine what those symbols are.
# (this can be evaluated only once include/config/auto.conf has been included)
KBUILD_MODULES := 1 KBUILD_MODULES := 1
autoksyms_recursive: $(build-dir) modules.order
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
"$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
endif endif
autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
quiet_cmd_autoksyms_h = GEN $@
cmd_autoksyms_h = mkdir -p $(dir $@); \
$(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@
$(autoksyms_h):
$(call cmd,autoksyms_h)
# '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
quiet_cmd_ar_vmlinux.a = AR $@ quiet_cmd_ar_vmlinux.a = AR $@
cmd_ar_vmlinux.a = \ cmd_ar_vmlinux.a = \
@@ -1265,7 +1353,7 @@ quiet_cmd_ar_vmlinux.a = AR $@
$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt) $(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
targets += vmlinux.a targets += vmlinux.a
vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE
$(call if_changed,ar_vmlinux.a) $(call if_changed,ar_vmlinux.a)
ifndef KBUILD_MIXED_TREE ifndef KBUILD_MIXED_TREE
@@ -1297,13 +1385,9 @@ endif
# make sure no implicit rule kicks in # make sure no implicit rule kicks in
$(sort $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)): . ; $(sort $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)): . ;
-include $(srctree)/scripts/sec_env.mk filechk_kernel.release = \
echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion \
ifeq ($(origin KERNELRELEASE),file) $(srctree) $(BRANCH) $(KMI_GENERATION))"
filechk_kernel.release = $(srctree)/scripts/setlocalversion $(srctree)
else
filechk_kernel.release = echo $(KERNELRELEASE)
endif
# Store (new) KERNELRELEASE string in include/config/kernel.release # Store (new) KERNELRELEASE string in include/config/kernel.release
include/config/kernel.release: FORCE include/config/kernel.release: FORCE
@@ -1325,7 +1409,7 @@ scripts: scripts_basic scripts_dtc
PHONY += prepare archprepare PHONY += prepare archprepare
archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
asm-generic $(version_h) include/generated/utsrelease.h \ asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
include/generated/compile.h include/generated/autoconf.h remove-stale-files include/generated/compile.h include/generated/autoconf.h remove-stale-files
prepare0: archprepare prepare0: archprepare
@@ -1504,10 +1588,7 @@ dtbs_prepare: include/config/kernel.release scripts_dtc
ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
export CHECK_DTBS=y export CHECK_DTBS=y
endif dtbs: dt_binding_check
ifneq ($(CHECK_DTBS),)
dtbs_prepare: dt_binding_check
endif endif
dtbs_check: dtbs dtbs_check: dtbs
@@ -1556,7 +1637,7 @@ endif
# Build modules # Build modules
# #
# *.ko are usually independent of vmlinux, but CONFIG_DEBUG_INFO_BTF_MODULES # *.ko are usually independent of vmlinux, but CONFIG_DEBUG_INFOBTF_MODULES
# is an exception. # is an exception.
ifdef CONFIG_DEBUG_INFO_BTF_MODULES ifdef CONFIG_DEBUG_INFO_BTF_MODULES
KBUILD_BUILTIN := 1 KBUILD_BUILTIN := 1
@@ -1569,6 +1650,40 @@ modules: modules_prepare
modules_prepare: prepare modules_prepare: prepare
$(Q)$(MAKE) $(build)=scripts scripts/module.lds $(Q)$(MAKE) $(build)=scripts scripts/module.lds
export modules_sign_only :=
ifeq ($(CONFIG_MODULE_SIG),y)
PHONY += modules_sign
modules_sign: modules_install
@:
# modules_sign is a subset of modules_install.
# 'make modules_install modules_sign' is equivalent to 'make modules_install'.
ifeq ($(filter modules_install,$(MAKECMDGOALS)),)
modules_sign_only := y
endif
endif
modinst_pre :=
ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
modinst_pre := __modinst_pre
endif
modules_install: $(modinst_pre)
PHONY += __modinst_pre
__modinst_pre:
@rm -rf $(MODLIB)/kernel
@rm -f $(MODLIB)/source
@mkdir -p $(MODLIB)/kernel
@ln -s $(abspath $(srctree)) $(MODLIB)/source
@if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
rm -f $(MODLIB)/build ; \
ln -s $(CURDIR) $(MODLIB)/build ; \
fi
@sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
@cp -f $(mixed-build-prefix)modules.builtin $(MODLIB)/
@cp -f $(or $(mixed-build-prefix),$(objtree)/)modules.builtin.modinfo $(MODLIB)/
endif # CONFIG_MODULES endif # CONFIG_MODULES
### ###
@@ -1579,10 +1694,10 @@ endif # CONFIG_MODULES
# make distclean Remove editor backup files, patch leftover files and the like # make distclean Remove editor backup files, patch leftover files and the like
# Directories & files removed with 'make clean' # Directories & files removed with 'make clean'
CLEAN_FILES += vmlinux.symvers modules-only.symvers \ CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
modules.builtin modules.builtin.modinfo modules.nsdeps \ modules.builtin modules.builtin.modinfo modules.nsdeps \
compile_commands.json .thinlto-cache rust/test \ compile_commands.json .thinlto-cache rust/test rust/doc \
rust-project.json .vmlinux.objs .vmlinux.export.c .vmlinux.objs .vmlinux.export.c
# Directories & files removed with 'make mrproper' # Directories & files removed with 'make mrproper'
MRPROPER_FILES += include/config include/generated \ MRPROPER_FILES += include/config include/generated \
@@ -1593,8 +1708,8 @@ MRPROPER_FILES += include/config include/generated \
certs/signing_key.pem \ certs/signing_key.pem \
certs/x509.genkey \ certs/x509.genkey \
vmlinux-gdb.py \ vmlinux-gdb.py \
kernel.spec rpmbuild \ *.spec \
rust/libmacros.so rust/target.json rust/libmacros.so
# clean - Delete most, but leave enough to build external modules # clean - Delete most, but leave enough to build external modules
# #
@@ -1606,9 +1721,6 @@ vmlinuxclean:
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
$(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
legoclean:
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/lego/kclean.sh $(srctree)/.legofile
clean: archclean vmlinuxclean resolve_btfids_clean clean: archclean vmlinuxclean resolve_btfids_clean
# mrproper - Delete all generated files, including .config # mrproper - Delete all generated files, including .config
@@ -1663,6 +1775,7 @@ help:
@echo ' mrproper - Remove all generated files + config + various backup files' @echo ' mrproper - Remove all generated files + config + various backup files'
@echo ' distclean - mrproper + remove editor backup and patch files' @echo ' distclean - mrproper + remove editor backup and patch files'
@echo '' @echo ''
@echo 'Configuration targets:'
@$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
@echo '' @echo ''
@echo 'Other generic targets:' @echo 'Other generic targets:'
@@ -1761,9 +1874,8 @@ help:
printf " %-16s - Show all of the above\\n" help-boards; \ printf " %-16s - Show all of the above\\n" help-boards; \
echo '') echo '')
@echo ' make V=n [targets] 1: verbose build' @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
@echo ' 2: give reason for rebuild of target' @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
@echo ' V=1 and V=2 can be combined with V=12'
@echo ' make O=dir [targets] Locate all output files in "dir", including .config' @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
@echo ' make C=1 [targets] Check re-compiled c source with $$CHECK' @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
@echo ' (sparse by default)' @echo ' (sparse by default)'
@@ -1775,10 +1887,6 @@ help:
@echo ' 3: more obscure warnings, can most likely be ignored' @echo ' 3: more obscure warnings, can most likely be ignored'
@echo ' e: warnings are being treated as errors' @echo ' e: warnings are being treated as errors'
@echo ' Multiple levels can be combined with W=12 or W=123' @echo ' Multiple levels can be combined with W=12 or W=123'
@$(if $(dtstree), \
echo ' make CHECK_DTBS=1 [targets] Check all generated dtb files against schema'; \
echo ' This can be applied both to "dtbs" and to individual "foo.dtb" targets' ; \
)
@echo '' @echo ''
@echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'Execute "make" or "make all" to build all targets marked with [*] '
@echo 'For further info see the ./README file' @echo 'For further info see the ./README file'
@@ -1801,7 +1909,7 @@ $(help-board-dirs): help-%:
# Documentation targets # Documentation targets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \ DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
linkcheckdocs dochelp refcheckdocs texinfodocs infodocs linkcheckdocs dochelp refcheckdocs
PHONY += $(DOC_TARGETS) PHONY += $(DOC_TARGETS)
$(DOC_TARGETS): $(DOC_TARGETS):
$(Q)$(MAKE) $(build)=Documentation $@ $(Q)$(MAKE) $(build)=Documentation $@
@@ -1847,15 +1955,14 @@ rustfmt:
rustfmtcheck: rustfmt_flags = --check rustfmtcheck: rustfmt_flags = --check
rustfmtcheck: rustfmt rustfmtcheck: rustfmt
# IDE support targets
PHONY += rust-analyzer
rust-analyzer:
$(Q)$(MAKE) $(build)=rust $@
# Misc # Misc
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
PHONY += misc-check
misc-check:
$(Q)$(srctree)/scripts/misc-check
all: misc-check
PHONY += scripts_gdb PHONY += scripts_gdb
scripts_gdb: prepare0 scripts_gdb: prepare0
$(Q)$(MAKE) $(build)=scripts/gdb $(Q)$(MAKE) $(build)=scripts/gdb
@@ -1867,8 +1974,6 @@ endif
else # KBUILD_EXTMOD else # KBUILD_EXTMOD
filechk_kernel.release = echo $(KERNELRELEASE)
### ###
# External module support. # External module support.
# When building external modules the kernel used as basis is considered # When building external modules the kernel used as basis is considered
@@ -1909,42 +2014,14 @@ help:
@echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH' @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'
@echo ' (default: $(abspath $(INSTALL_HDR_PATH)))' @echo ' (default: $(abspath $(INSTALL_HDR_PATH)))'
@echo ' clean - remove generated files in module directory only' @echo ' clean - remove generated files in module directory only'
@echo ' rust-analyzer - generate rust-project.json rust-analyzer support file'
@echo '' @echo ''
ifndef CONFIG_MODULES
modules modules_install: __external_modules_error
__external_modules_error:
@echo >&2 '***'
@echo >&2 '*** The present kernel disabled CONFIG_MODULES.'
@echo >&2 '*** You cannot build or install external modules.'
@echo >&2 '***'
@false
endif
endif # KBUILD_EXTMOD endif # KBUILD_EXTMOD
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Modules # Modules
PHONY += modules modules_install modules_sign modules_prepare PHONY += modules modules_install modules_prepare
modules_install:
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
ifeq ($(CONFIG_MODULE_SIG),y)
# modules_sign is a subset of modules_install.
# 'make modules_install modules_sign' is equivalent to 'make modules_install'.
modules_sign: modules_install
@:
else
modules_sign:
@echo >&2 '***'
@echo >&2 '*** CONFIG_MODULE_SIG is disabled. You cannot sign modules.'
@echo >&2 '***'
@false
endif
ifdef CONFIG_MODULES ifdef CONFIG_MODULES
@@ -1962,10 +2039,28 @@ PHONY += modules_check
modules_check: $(MODORDER) modules_check: $(MODORDER)
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
quiet_cmd_depmod = DEPMOD $(MODLIB)
cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
$(KERNELRELEASE) $(mixed-build-prefix)
modules_install:
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
ifndef modules_sign_only
$(call cmd,depmod)
endif
else # CONFIG_MODULES else # CONFIG_MODULES
modules: # Modules not configured
@: # ---------------------------------------------------------------------------
modules modules_install:
@echo >&2 '***'
@echo >&2 '*** The present kernel configuration has modules disabled.'
@echo >&2 '*** To use the module feature, please run "make menuconfig" etc.'
@echo >&2 '*** to enable CONFIG_MODULES.'
@echo >&2 '***'
@exit 1
KBUILD_MODULES := KBUILD_MODULES :=
@@ -2003,7 +2098,7 @@ $(single-no-ko): $(build-dir)
# Remove MODORDER when done because it is not the real one. # Remove MODORDER when done because it is not the real one.
PHONY += single_modules PHONY += single_modules
single_modules: $(single-no-ko) modules_prepare single_modules: $(single-no-ko) modules_prepare
$(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$(m:%.ko=%.o);) } > $(MODORDER) $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
ifneq ($(KBUILD_MODPOST_NOFINAL),1) ifneq ($(KBUILD_MODPOST_NOFINAL),1)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
@@ -2036,21 +2131,18 @@ clean: $(clean-dirs)
$(RCS_FIND_IGNORE) \ $(RCS_FIND_IGNORE) \
\( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \ \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '*.ko.*' \ -o -name '*.ko.*' \
-o -name '*.dtb' -o -name '*.dtbo' \ -o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
-o -name '*.dtb.S' -o -name '*.dtbo.S' \
-o -name '*.dt.yaml' \
-o -name '*.dwo' -o -name '*.lst' \ -o -name '*.dwo' -o -name '*.lst' \
-o -name '*.su' -o -name '*.mod' \ -o -name '*.su' -o -name '*.mod' -o -name '*.usyms' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-o -name '*.lex.c' -o -name '*.tab.[ch]' \ -o -name '*.lex.c' -o -name '*.tab.[ch]' \
-o -name '*.asn1.[ch]' \ -o -name '*.asn1.[ch]' \
-o -name '*.symtypes' -o -name 'modules.order' \ -o -name '*.symtypes' -o -name 'modules.order' \
-o -name '.tmp_*' \
-o -name '*.c.[012]*.*' \ -o -name '*.c.[012]*.*' \
-o -name '*.ll' \ -o -name '*.ll' \
-o -name '*.gcno' \ -o -name '*.gcno' \
-o -name '*.*.symversions' \) -type f -print \ -o -name '*.*.symversions' \) -type f -print | xargs rm -f
-o -name '.tmp_*' -print \
| xargs rm -rf
# Generate tags for editors # Generate tags for editors
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -2060,11 +2152,6 @@ quiet_cmd_tags = GEN $@
tags TAGS cscope gtags: FORCE tags TAGS cscope gtags: FORCE
$(call cmd,tags) $(call cmd,tags)
# IDE support targets
PHONY += rust-analyzer
rust-analyzer:
$(Q)$(MAKE) $(build)=rust $@
# Script to generate missing namespace dependencies # Script to generate missing namespace dependencies
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -2137,7 +2224,8 @@ checkstack:
$(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH) $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
kernelrelease: kernelrelease:
@$(filechk_kernel.release) @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion \
$(srctree) $(BRANCH) $(KMI_GENERATION))"
kernelversion: kernelversion:
@echo $(KERNELVERSION) @echo $(KERNELVERSION)
@@ -2145,10 +2233,6 @@ kernelversion:
image_name: image_name:
@echo $(KBUILD_IMAGE) @echo $(KBUILD_IMAGE)
PHONY += run-command
run-command:
$(Q)$(KBUILD_RUN_COMMAND)
quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
cmd_rmfiles = rm -rf $(rm-files) cmd_rmfiles = rm -rf $(rm-files)

View File

@@ -63,8 +63,8 @@ CONFIG_USB_INTERFACE_LPM_LIST=y
CONFIG_USB_NOTIFY_PROC_LOG=y CONFIG_USB_NOTIFY_PROC_LOG=y
CONFIG_USB_USING_ADVANCED_USBLOG=y CONFIG_USB_USING_ADVANCED_USBLOG=y
CONFIG_CIRRUS_FIRMWARE_CL_DSP=m CONFIG_CIRRUS_FIRMWARE_CL_DSP=m
CONFIG_KPERFMON=y # CONFIG_KPERFMON is not set
CONFIG_KPERFMON_BUILD=m # CONFIG_KPERFMON_BUILD is not set
CONFIG_ANDROID_SWITCH=m CONFIG_ANDROID_SWITCH=m
# CONFIG_ANDROID_SWITCH_GPIO is not set # CONFIG_ANDROID_SWITCH_GPIO is not set
CONFIG_HDM=m CONFIG_HDM=m

File diff suppressed because it is too large Load Diff

88
include/linux/olog.pb.h Normal file
View File

@@ -0,0 +1,88 @@
// Generated by the protocol buffer compiler for perflog!! DO NOT EDIT!
#ifndef _OLOG_PROTOCOL_BUFFER_H_
#define _OLOG_PROTOCOL_BUFFER_H_
//EnumGenerator::GenerateDefinition in perflog_enum.cc
enum OlogTestEnum_Type {
PERFLOG_DEF = 0,
PERFLOG_LOG = 1,
PERFLOG_EVT = 2,
PERFLOG_WRN = 3,
PERFLOG_CRI = 4
};
#if defined(KPERFMON_KERNEL)
int OlogTestEnum_Type_maxnum = 5;
char * OlogTestEnum_Type_strings[5] = {
"DEF",
"LOG",
"EVT",
"WRN",
"CRI"
};
#endif //KPERFMON_KERNEL
//EnumGenerator::GenerateDefinition in perflog_enum.cc
enum OlogTestEnum_ID {
PERFLOG_UNKNOWN = 0,
PERFLOG_LCDV = 2,
PERFLOG_ARGOS = 3,
PERFLOG_APPLAUNCH = 4,
PERFLOG_LOADAPK = 5,
PERFLOG_MAINLOOPER = 6,
PERFLOG_EXCESSIVECPUUSAGE = 7,
PERFLOG_ACTIVITYSLOW = 8,
PERFLOG_BROADCAST = 9,
PERFLOG_STORE = 10,
PERFLOG_CPUTOP = 11,
PERFLOG_LCD = 12,
PERFLOG_CPU = 13,
PERFLOG_LOCKCONTENTION = 14,
PERFLOG_CPUFREQ = 15,
PERFLOG_MEMPRESSURE = 16,
PERFLOG_INPUTD = 17,
PERFLOG_AMPSS = 18,
PERFLOG_SERVICEMANAGERSLOW = 19,
PERFLOG_IPCSTARVE = 20,
PERFLOG_SCREENSHOT = 21,
PERFLOG_MUTEX = 22,
PERFLOG_SYSTEMSERVER = 23,
PERFLOG_PERFETTOLOGGINGENABLED = 24,
PERFLOG_BIGDATA = 25,
PERFLOG_PSI = 26,
PERFLOG_JANK = 27
};
#if defined(KPERFMON_KERNEL)
int OlogTestEnum_ID_maxnum = 28;
char * OlogTestEnum_ID_strings[28] = {
"UNKNOWN",
" ",
"LCDV",
"ARGOS",
"APPLAUNCH",
"LOADAPK",
"MAINLOOPER",
"EXCESSIVECPUUSAGE",
"ACTIVITYSLOW",
"BROADCAST",
"STORE",
"CPUTOP",
"LCD",
"CPU",
"LOCKCONTENTION",
"CPUFREQ",
"MEMPRESSURE",
"INPUTD",
"AMPSS",
"SERVICEMANAGERSLOW",
"IPCSTARVE",
"SCREENSHOT",
"MUTEX",
"SYSTEMSERVER",
"PERFETTOLOGGINGENABLED",
"BIGDATA",
"PSI",
"JANK"
};
#endif //KPERFMON_KERNEL
#endif //_OLOG_PROTOCOL_BUFFER_H_

15
include/linux/ologk.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef _OLOG_KERNEL_H_
#define _OLOG_KERNEL_H_
#include <linux/unistd.h>
#include "olog.pb.h"
#define OLOG_CPU_FREQ_FILTER 1500000
#define PERFLOG_MUTEX_THRESHOLD 20
#define ologk(...) _perflog(PERFLOG_LOG, PERFLOG_UNKNOWN, __VA_ARGS__)
#define perflog(...) _perflog(PERFLOG_LOG, __VA_ARGS__)
extern void _perflog(int type, int logid, const char *fmt, ...);
extern void perflog_evt(int logid, int arg1);
#endif