Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'kbuild-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux

Pull Kbuild/Kconfig updates from Nicolas Schier:
"Kbuild:
- reject unexpected values for LLVM=
- uapi: remove usage of toolchain headers
- switch from '-fms-extensions' to '-fms-anonymous-structs' when
available (currently: clang >= 23.0.0)
- reduce the number of compiler-generated suffixes for clang thin-lto
build
- reduce output spam ("GEN Makefile") when building out of tree
- improve portability for testing headers
- also test UAPI headers against C++ compilers
- drop build ID architecture allow-list in vdso_install
- only run checksyscalls when necessary
- update the debug information notes in reproducible-builds.rst
- expand inlining hints with -fdiagnostics-show-inlining-chain

Kconfig:
- forbid multiple entries with the same symbol in a choice
- error out on duplicated kconfig inclusion"

* tag 'kbuild-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux: (35 commits)
kbuild: expand inlining hints with -fdiagnostics-show-inlining-chain
kconfig: forbid multiple entries with the same symbol in a choice
Documentation: kbuild: Update the debug information notes in reproducible-builds.rst
checksyscalls: move instance functionality into generic code
checksyscalls: only run when necessary
checksyscalls: fail on all intermediate errors
checksyscalls: move path to reference table to a variable
kbuild: vdso_install: drop build ID architecture allow-list
kbuild: vdso_install: gracefully handle images without build ID
kbuild: vdso_install: hide readelf warnings
kbuild: vdso_install: split out the readelf invocation
kbuild: uapi: also test UAPI headers against C++ compilers
kbuild: uapi: provide a C++ compatible dummy definition of NULL
kbuild: uapi: handle UML in architecture-specific exclusion lists
kbuild: uapi: move all include path flags together
kbuild: uapi: move some compiler arguments out of the command definition
check-uapi: use dummy libc includes
check-uapi: honor ${CROSS_COMPILE} setting
check-uapi: link into shared objects
kbuild: reduce output spam when building out of tree
...

+252 -118
-4
Documentation/kbuild/llvm.rst
··· 71 71 72 72 PATH=/path/to/llvm/:$PATH make LLVM=-14 73 73 74 - ``LLVM=0`` is not the same as omitting ``LLVM`` altogether, it will behave like 75 - ``LLVM=1``. If you only wish to use certain LLVM utilities, use their 76 - respective make variables. 77 - 78 74 The same value used for ``LLVM=`` should be set for each invocation of ``make`` 79 75 if configuring and building via distinct commands. ``LLVM=`` should also be set 80 76 as an environment variable when running scripts that will eventually run
+5 -2
Documentation/kbuild/reproducible-builds.rst
··· 50 50 ------------------ 51 51 52 52 When the kernel is built out-of-tree, debug information may include 53 - absolute filenames for the source files. This must be overridden by 54 - including the ``-fdebug-prefix-map`` option in the `KCFLAGS`_ variable. 53 + absolute filenames for the source files and build directory. These must 54 + be overridden by including a ``-fdebug-prefix-map`` option for each in 55 + the `KCFLAGS`_ and `KAFLAGS`_ variables to cover both ``.c`` and ``.S`` 56 + files. 55 57 56 58 Depending on the compiler used, the ``__FILE__`` macro may also expand 57 59 to an absolute filename in an out-of-tree build. Kbuild automatically ··· 137 135 .. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp 138 136 .. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host 139 137 .. _KCFLAGS: kbuild.html#kcflags 138 + .. _KAFLAGS: kbuild.html#kaflags 140 139 .. _prefix-map options: https://reproducible-builds.org/docs/build-path/ 141 140 .. _Reproducible Builds project: https://reproducible-builds.org/ 142 141 .. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/
+10 -4
Kbuild
··· 47 47 48 48 # Check for missing system calls 49 49 50 - quiet_cmd_syscalls = CALL $< 51 - cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) 50 + missing-syscalls-file := .tmp_missing-syscalls$(missing_syscalls_instance) 51 + 52 + targets += $(missing-syscalls-file) 53 + 54 + quiet_cmd_syscalls = CALL $< $(addprefix for ,$(missing_syscalls_instance)) 55 + cmd_syscalls = DEPFILE=$(depfile) $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags); touch $@ 56 + 57 + $(missing-syscalls-file): scripts/checksyscalls.sh $(rq-offsets-file) FORCE 58 + $(call if_changed_dep,syscalls) 52 59 53 60 PHONY += missing-syscalls 54 - missing-syscalls: scripts/checksyscalls.sh $(rq-offsets-file) 55 - $(call cmd,syscalls) 61 + missing-syscalls: $(missing-syscalls-file) 56 62 57 63 # Check the manual modification of atomic headers 58 64
+26 -9
Makefile
··· 591 591 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE 592 592 593 593 KBUILD_CFLAGS := 594 - KBUILD_CFLAGS += -std=gnu11 595 594 KBUILD_CFLAGS += -fshort-wchar 596 595 KBUILD_CFLAGS += -funsigned-char 597 596 KBUILD_CFLAGS += -fno-common ··· 679 680 echo "export KBUILD_OUTPUT = $(CURDIR)" 680 681 endif 681 682 682 - quiet_cmd_makefile = GEN Makefile 683 - cmd_makefile = { \ 683 + filechk_makefile = { \ 684 684 echo "\# Automatically generated by $(abs_srctree)/Makefile: don't edit"; \ 685 685 $(print_env_for_makefile); \ 686 686 echo "include $(abs_srctree)/Makefile"; \ 687 - } > Makefile 687 + } 688 688 689 - outputmakefile: 689 + $(objtree)/Makefile: FORCE 690 + $(call filechk,makefile) 691 + 692 + # Prevent $(srcroot)/Makefile from inhibiting the rule to run. 693 + PHONY += $(objtree)/Makefile 694 + 695 + outputmakefile: $(objtree)/Makefile 690 696 ifeq ($(KBUILD_EXTMOD),) 691 697 @if [ -f $(srctree)/.config -o \ 692 698 -d $(srctree)/include/config -o \ ··· 712 708 fi 713 709 endif 714 710 $(Q)ln -fsn $(srcroot) source 715 - $(call cmd,makefile) 716 711 $(Q)test -e .gitignore || \ 717 712 { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore 718 713 endif ··· 796 793 ifdef need-config 797 794 include $(objtree)/include/config/auto.conf 798 795 endif 796 + 797 + CC_FLAGS_DIALECT := -std=gnu11 798 + # Allow including a tagged struct or union anonymously in another struct/union. 799 + CC_FLAGS_DIALECT += $(CONFIG_CC_MS_EXTENSIONS) 800 + # Clang enables warnings about GNU and Microsoft extensions by default, disable 801 + # them because this is expected with the above options. 802 + ifdef CONFIG_CC_IS_CLANG 803 + CC_FLAGS_DIALECT += -Wno-gnu 804 + CC_FLAGS_DIALECT += -Wno-microsoft-anon-tag 805 + endif 806 + export CC_FLAGS_DIALECT 807 + KBUILD_CFLAGS += $(CC_FLAGS_DIALECT) 799 808 800 809 ifeq ($(KBUILD_EXTMOD),) 801 810 # Objects we will link into vmlinux / subdirs we need to visit ··· 1005 990 # Get details on warnings generated due to GCC value tracking. 1006 991 KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-context=2) 1007 992 993 + # Show inlining notes for __attribute__((warning/error)) call chains. 994 + # GCC supports this unconditionally while Clang 23+ provides a flag. 995 + KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-inlining-chain) 996 + 1008 997 # Clear used registers at func exit (to reduce data lifetime and ROP gadgets). 1009 998 ifdef CONFIG_ZERO_CALL_USED_REGS 1010 999 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr ··· 1071 1052 ifdef CONFIG_LTO_CLANG 1072 1053 ifdef CONFIG_LTO_CLANG_THIN 1073 1054 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit 1055 + KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm -always-rename-promoted-locals=false) 1074 1056 else 1075 1057 CC_FLAGS_LTO := -flto 1076 1058 endif ··· 1130 1110 # arrays. Enforce this for everything that may examine structure sizes and 1131 1111 # perform bounds checking. 1132 1112 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) 1133 - 1134 - # Allow including a tagged struct or union anonymously in another struct/union. 1135 - KBUILD_CFLAGS += -fms-extensions 1136 1113 1137 1114 # disable invalid "can't wrap" optimizations for signed / pointers 1138 1115 KBUILD_CFLAGS += -fno-strict-overflow
+1 -2
arch/arm64/kernel/vdso32/Makefile
··· 63 63 $(filter -Werror,$(KBUILD_CPPFLAGS)) \ 64 64 -Werror-implicit-function-declaration \ 65 65 -Wno-format-security \ 66 - -std=gnu11 -fms-extensions 66 + $(CC_FLAGS_DIALECT) 67 67 VDSO_CFLAGS += -O2 68 68 # Some useful compiler-dependent flags from top-level Makefile 69 69 VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign) ··· 71 71 VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes) 72 72 VDSO_CFLAGS += -Werror=date-time 73 73 VDSO_CFLAGS += $(call cc32-option,-Werror=incompatible-pointer-types) 74 - VDSO_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) 75 74 76 75 # Compile as THUMB2 or ARM. Unwinding via frame-pointers in THUMB2 is 77 76 # unreliable.
+1 -1
arch/hexagon/include/uapi/asm/sigcontext.h
··· 29 29 */ 30 30 struct sigcontext { 31 31 struct user_regs_struct sc_regs; 32 - } __aligned(8); 32 + } __attribute__((aligned(8))); 33 33 34 34 #endif
+1 -1
arch/loongarch/vdso/Makefile
··· 24 24 cflags-vdso := $(ccflags-vdso) \ 25 25 -isystem $(shell $(CC) -print-file-name=include) \ 26 26 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 27 - -std=gnu11 -fms-extensions -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ 27 + $(CC_FLAGS_DIALECT) -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ 28 28 -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ 29 29 $(call cc-option, -fasynchronous-unwind-tables) \ 30 30 $(call cc-option, -fno-stack-protector)
+2 -4
arch/mips/Makefile
··· 421 421 422 422 archprepare: 423 423 ifdef CONFIG_MIPS32_N32 424 - @$(kecho) ' Checking missing-syscalls for N32' 425 - $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=n32" 424 + $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_instance="N32" missing_syscalls_flags="-mabi=n32" 426 425 endif 427 426 ifdef CONFIG_MIPS32_O32 428 - @$(kecho) ' Checking missing-syscalls for O32' 429 - $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32" 427 + $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_instance="O32" missing_syscalls_flags="-mabi=32" 430 428 endif 431 429 432 430 install:
+1 -1
arch/parisc/boot/compressed/Makefile
··· 18 18 ifndef CONFIG_64BIT 19 19 KBUILD_CFLAGS += -mfast-indirect-calls 20 20 endif 21 - KBUILD_CFLAGS += -std=gnu11 -fms-extensions 21 + KBUILD_CFLAGS += $(CC_FLAGS_DIALECT) 22 22 23 23 LDFLAGS_vmlinux := -X -e startup --as-needed -T 24 24 $(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBGCC) FORCE
+1 -2
arch/powerpc/boot/Makefile
··· 70 70 BOOTCPPFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include) 71 71 72 72 BOOTCFLAGS := $(BOOTTARGETFLAGS) \ 73 - -std=gnu11 -fms-extensions \ 73 + $(CC_FLAGS_DIALECT) \ 74 74 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 75 75 -fno-strict-aliasing -O2 \ 76 76 -msoft-float -mno-altivec -mno-vsx \ ··· 86 86 87 87 ifdef CONFIG_CC_IS_CLANG 88 88 BOOTCFLAGS += $(CLANG_FLAGS) 89 - BOOTCFLAGS += -Wno-microsoft-anon-tag 90 89 BOOTAFLAGS += $(CLANG_FLAGS) 91 90 endif 92 91
+1 -2
arch/s390/Makefile
··· 22 22 ifndef CONFIG_AS_IS_LLVM 23 23 KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) 24 24 endif 25 - KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack -std=gnu11 -fms-extensions 25 + KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack $(CC_FLAGS_DIALECT) 26 26 KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY 27 27 KBUILD_CFLAGS_DECOMPRESSOR += -D__DECOMPRESSOR 28 28 KBUILD_CFLAGS_DECOMPRESSOR += -Wno-pointer-sign ··· 35 35 KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g) 36 36 KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,)) 37 37 KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds) 38 - KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) 39 38 40 39 UTS_MACHINE := s390x 41 40 STACK_SIZE := $(if $(CONFIG_KASAN),65536,$(if $(CONFIG_KMSAN),65536,16384))
+1 -2
arch/s390/purgatory/Makefile
··· 13 13 $(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE 14 14 $(call if_changed_rule,as_o_S) 15 15 16 - KBUILD_CFLAGS := -std=gnu11 -fms-extensions -fno-strict-aliasing -Wall -Wstrict-prototypes 16 + KBUILD_CFLAGS := $(CC_FLAGS_DIALECT) -fno-strict-aliasing -Wall -Wstrict-prototypes 17 17 KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare 18 18 KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding 19 19 KBUILD_CFLAGS += -Os -m64 -msoft-float -fno-common ··· 21 21 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 22 22 KBUILD_CFLAGS += -D__DISABLE_EXPORTS 23 23 KBUILD_CFLAGS += $(CLANG_FLAGS) 24 - KBUILD_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) 25 24 KBUILD_CFLAGS += $(call cc-option,-fno-PIE) 26 25 KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe) 27 26 KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
+1 -5
arch/x86/Makefile
··· 48 48 49 49 # How to compile the 16-bit code. Note we always compile for -march=i386; 50 50 # that way we can complain to the user if the CPU is insufficient. 51 - REALMODE_CFLAGS := -std=gnu11 -fms-extensions -m16 -g -Os \ 51 + REALMODE_CFLAGS := $(CC_FLAGS_DIALECT) -m16 -g -Os \ 52 52 -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \ 53 53 -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \ 54 54 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ ··· 59 59 REALMODE_CFLAGS += -Wno-address-of-packed-member 60 60 REALMODE_CFLAGS += $(cc_stack_align4) 61 61 REALMODE_CFLAGS += $(CLANG_FLAGS) 62 - ifdef CONFIG_CC_IS_CLANG 63 - REALMODE_CFLAGS += -Wno-gnu 64 - REALMODE_CFLAGS += -Wno-microsoft-anon-tag 65 - endif 66 62 export REALMODE_CFLAGS 67 63 68 64 # BITS is used as extension for files which are available in a 32 bit
+1 -5
arch/x86/boot/compressed/Makefile
··· 25 25 # avoid errors with '-march=i386', and future flags may depend on the target to 26 26 # be valid. 27 27 KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS) 28 - KBUILD_CFLAGS += -std=gnu11 -fms-extensions 28 + KBUILD_CFLAGS += $(CC_FLAGS_DIALECT) 29 29 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE 30 30 KBUILD_CFLAGS += -Wundef 31 31 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING ··· 36 36 KBUILD_CFLAGS += -ffreestanding -fshort-wchar 37 37 KBUILD_CFLAGS += -fno-stack-protector 38 38 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 39 - ifdef CONFIG_CC_IS_CLANG 40 - KBUILD_CFLAGS += -Wno-gnu 41 - KBUILD_CFLAGS += -Wno-microsoft-anon-tag 42 - endif 43 39 KBUILD_CFLAGS += -Wno-pointer-sign 44 40 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables 45 41 KBUILD_CFLAGS += -D__DISABLE_EXPORTS
+1 -2
drivers/firmware/efi/libstub/Makefile
··· 11 11 12 12 cflags-$(CONFIG_X86_32) := -march=i386 13 13 cflags-$(CONFIG_X86_64) := -mcmodel=small 14 - cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -std=gnu11 -fms-extensions \ 14 + cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ $(CC_FLAGS_DIALECT) \ 15 15 -fPIC -fno-strict-aliasing -mno-red-zone \ 16 16 -mno-mmx -mno-sse -fshort-wchar \ 17 17 -Wno-pointer-sign \ 18 18 $(call cc-disable-warning, address-of-packed-member) \ 19 - $(if $(CONFIG_CC_IS_CLANG),-Wno-gnu -Wno-microsoft-anon-tag) \ 20 19 -fno-asynchronous-unwind-tables \ 21 20 $(CLANG_FLAGS) 22 21
+5
init/Kconfig
··· 969 969 default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5) 970 970 default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough) 971 971 972 + config CC_MS_EXTENSIONS 973 + string 974 + default "-fms-anonymous-structs" if $(cc-option,-fms-anonymous-structs) 975 + default "-fms-extensions" 976 + 972 977 # Currently, disable gcc-10+ array-bounds globally. 973 978 # It's still broken in gcc-13, so no upper bound yet. 974 979 config GCC10_NO_ARRAY_BOUNDS
+4 -3
scripts/Makefile.vdsoinst
··· 19 19 $$(dest): $(1) FORCE 20 20 $$(call cmd,install) 21 21 22 - # Some architectures create .build-id symlinks 23 - ifneq ($(filter arm s390 sparc x86, $(SRCARCH)),) 24 - link := $(install-dir)/.build-id/$$(shell $(READELF) -n $(1) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p').debug 22 + build-id-file := $$(shell $(READELF) -n $(1) 2>/dev/null | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') 23 + 24 + ifneq ($$(build-id-file),) 25 + link := $(install-dir)/.build-id/$$(build-id-file).debug 25 26 26 27 __default: $$(link) 27 28 $$(link): $$(dest) FORCE
-5
scripts/Makefile.warn
··· 28 28 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds 29 29 30 30 ifdef CONFIG_CC_IS_CLANG 31 - # The kernel builds with '-std=gnu11' and '-fms-extensions' so use of GNU and 32 - # Microsoft extensions is acceptable. 33 - KBUILD_CFLAGS += -Wno-gnu 34 - KBUILD_CFLAGS += -Wno-microsoft-anon-tag 35 - 36 31 # Clang checks for overflow/truncation with '%p', while GCC does not: 37 32 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219 38 33 KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow-non-kprintf)
+12 -7
scripts/check-uapi.sh
··· 33 33 -v Verbose operation (print more information about each header being checked). 34 34 35 35 Environmental args: 36 - ABIDIFF Custom path to abidiff binary 37 - CC C compiler (default is "gcc") 38 - ARCH Target architecture for the UAPI check (default is host arch) 36 + ABIDIFF Custom path to abidiff binary 37 + CROSS_COMPILE Toolchain prefix for compiler 38 + CC C compiler (default is "\${CROSS_COMPILE}gcc") 39 + ARCH Target architecture for the UAPI check (default is host arch) 39 40 40 41 Exit codes: 41 42 $SUCCESS) Success ··· 179 178 local -r inc_dir="$1" 180 179 local -r header="$2" 181 180 local -r out="$3" 182 - printf "int main(void) { return 0; }\n" | \ 183 - "$CC" -c \ 181 + printf "int f(void) { return 0; }\n" | \ 182 + "$CC" \ 183 + -shared \ 184 + -nostdlib \ 185 + -fPIC \ 184 186 -o "$out" \ 185 187 -x c \ 186 188 -O0 \ ··· 191 187 -fno-eliminate-unused-debug-types \ 192 188 -g \ 193 189 "-I${inc_dir}" \ 190 + "-Iusr/dummy-include" \ 194 191 -include "$header" \ 195 192 - 196 193 } ··· 200 195 run_make_headers_install() { 201 196 local -r ref="$1" 202 197 local -r install_dir="$(get_header_tree "$ref")" 203 - make -j "$MAX_THREADS" ARCH="$ARCH" INSTALL_HDR_PATH="$install_dir" \ 198 + make -j "$MAX_THREADS" CROSS_COMPILE="${CROSS_COMPILE}" ARCH="$ARCH" INSTALL_HDR_PATH="$install_dir" \ 204 199 headers_install > /dev/null 205 200 } 206 201 ··· 409 404 # Make sure we have the tools we need and the arguments make sense 410 405 check_deps() { 411 406 ABIDIFF="${ABIDIFF:-abidiff}" 412 - CC="${CC:-gcc}" 407 + CC="${CC:-${CROSS_COMPILE}gcc}" 413 408 ARCH="${ARCH:-$(uname -m)}" 414 409 if [ "$ARCH" = "x86_64" ]; then 415 410 ARCH="x86"
+10 -1
scripts/checksyscalls.sh
··· 10 10 # checksyscalls.sh gcc gcc-options 11 11 # 12 12 13 + set -e 14 + 15 + reference_table="$(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl" 16 + 13 17 ignore_list() { 14 18 cat << EOF 15 19 #include <asm/types.h> ··· 273 269 done 274 270 } 275 271 276 - (ignore_list && syscall_list $(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl) | \ 272 + (ignore_list && syscall_list ${reference_table}) | \ 277 273 $* -Wno-error -Wno-unused-macros -E -x c - > /dev/null 274 + 275 + # For fixdep 276 + if [ -n "${DEPFILE}" ]; then 277 + echo "${0}: ${0} ${reference_table}" >> "${DEPFILE}" 278 + fi
+2 -2
scripts/kconfig/lexer.l
··· 402 402 exit(1); 403 403 } 404 404 405 - cur_filename = file_lookup(name); 405 + cur_filename = file_lookup(name, NULL, 0); 406 406 yylineno = 1; 407 407 } 408 408 ··· 443 443 } 444 444 445 445 yylineno = 1; 446 - cur_filename = file_lookup(name); 446 + cur_filename = file_lookup(name, cur_filename, cur_lineno); 447 447 } 448 448 449 449 static void zconf_endfile(void)
+2 -1
scripts/kconfig/lkc.h
··· 51 51 } 52 52 53 53 /* util.c */ 54 - const char *file_lookup(const char *name); 54 + const char *file_lookup(const char *name, 55 + const char *parent_name, int parent_lineno); 55 56 56 57 /* lexer.l */ 57 58 int yylex(void);
+4 -11
scripts/kconfig/parser.y
··· 159 159 yynerrs++; 160 160 } 161 161 162 - /* 163 - * If the same symbol appears twice in a choice block, the list 164 - * node would be added twice, leading to a broken linked list. 165 - * list_empty() ensures that this symbol has not yet added. 166 - */ 167 - if (list_empty(&current_entry->sym->choice_link)) 168 - list_add_tail(&current_entry->sym->choice_link, 169 - &current_choice->choice_members); 162 + list_add_tail(&current_entry->sym->choice_link, 163 + &current_choice->choice_members); 170 164 } 171 165 172 166 printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno); ··· 540 546 ret = -1; 541 547 } 542 548 543 - if (prop->menu != menu && prop->type == P_PROMPT && 544 - prop->menu->parent != menu->parent) { 549 + if (prop->menu != menu && prop->type == P_PROMPT) { 545 550 fprintf(stderr, "%s:%d: error: %s", 546 551 prop->filename, prop->lineno, 547 - "choice value has a prompt outside its choice group\n"); 552 + "choice value must not have a prompt in another entry\n"); 548 553 ret = -1; 549 554 } 550 555 }
+3
scripts/kconfig/tests/err_repeated_inc/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + source "Kconfig.inc1"
+4
scripts/kconfig/tests/err_repeated_inc/Kconfig.inc1
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + source "Kconfig.inc2" 4 + source "Kconfig.inc3"
+3
scripts/kconfig/tests/err_repeated_inc/Kconfig.inc2
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + source "Kconfig.inc3"
+1
scripts/kconfig/tests/err_repeated_inc/Kconfig.inc3
··· 1 + # SPDX-License-Identifier: GPL-2.0-only
+10
scripts/kconfig/tests/err_repeated_inc/__init__.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + """ 3 + Detect repeated inclusion error. 4 + 5 + If repeated inclusion is detected, it should fail with error message. 6 + """ 7 + 8 + def test(conf): 9 + assert conf.oldaskconfig() != 0 10 + assert conf.stderr_contains('expected_stderr')
+2
scripts/kconfig/tests/err_repeated_inc/expected_stderr
··· 1 + Kconfig.inc1:4: error: Repeated inclusion of Kconfig.inc3 2 + Kconfig.inc2:3: note: Location of first inclusion of Kconfig.inc3
+29 -4
scripts/kconfig/util.c
··· 18 18 19 19 struct file { 20 20 struct hlist_node node; 21 + struct { 22 + const char *name; 23 + int lineno; 24 + } parent; 21 25 char name[]; 22 26 }; 23 27 24 - /* file already present in list? If not add it */ 25 - const char *file_lookup(const char *name) 28 + static void die_duplicated_include(struct file *file, 29 + const char *parent, int lineno) 26 30 { 31 + fprintf(stderr, 32 + "%s:%d: error: repeated inclusion of %s\n" 33 + "%s:%d: note: location of first inclusion of %s\n", 34 + parent, lineno, file->name, 35 + file->parent.name, file->parent.lineno, file->name); 36 + exit(1); 37 + } 38 + 39 + /* file already present in list? If not add it */ 40 + const char *file_lookup(const char *name, 41 + const char *parent_name, int parent_lineno) 42 + { 43 + const char *parent = NULL; 27 44 struct file *file; 28 45 size_t len; 29 46 int hash = hash_str(name); 30 47 48 + if (parent_name) 49 + parent = file_lookup(parent_name, NULL, 0); 50 + 31 51 hash_for_each_possible(file_hashtable, file, node, hash) 32 - if (!strcmp(name, file->name)) 33 - return file->name; 52 + if (!strcmp(name, file->name)) { 53 + if (!parent_name) 54 + return file->name; 55 + die_duplicated_include(file, parent, parent_lineno); 56 + } 34 57 35 58 len = strlen(name); 36 59 file = xmalloc(sizeof(*file) + len + 1); 37 60 memset(file, 0, sizeof(*file)); 38 61 memcpy(file->name, name, len); 39 62 file->name[len] = '\0'; 63 + file->parent.name = parent; 64 + file->parent.lineno = parent_lineno; 40 65 41 66 hash_add(file_hashtable, &file->node, hash); 42 67
+2
tools/scripts/Makefile.include
··· 56 56 LLVM_PREFIX := $(LLVM) 57 57 else ifneq ($(filter -%,$(LLVM)),) 58 58 LLVM_SUFFIX := $(LLVM) 59 + else ifneq ($(LLVM),1) 60 + $(error Invalid value for LLVM, see Documentation/kbuild/llvm.rst) 59 61 endif 60 62 61 63 $(call allow-override,CC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX))
usr/dummy-include/endian.h
+8
usr/dummy-include/limits.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef _DUMMY_LIMITS_H 3 + #define _DUMMY_LIMITS_H 4 + 5 + #define INT_MAX ((int)(~0U >> 1)) 6 + #define INT_MIN (-INT_MAX - 1) 7 + 8 + #endif /* _DUMMY_LIMITS_H */
usr/dummy-include/netinet/if_ether.h
usr/dummy-include/netinet/in.h
-7
usr/dummy-include/stdbool.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - #ifndef _STDBOOL_H 3 - #define _STDBOOL_H 4 - 5 - #error "Please do not include <stdbool.h> from exported headers" 6 - 7 - #endif /* _STDBOOL_H */
+13
usr/dummy-include/stddef.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef _DUMMY_STDDEF_H 3 + #define _DUMMY_STDDEF_H 4 + 5 + #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) 6 + 7 + #ifdef __cplusplus 8 + #define NULL 0 9 + #else 10 + #define NULL ((void *)0) 11 + #endif 12 + 13 + #endif /* _DUMMY_STDDEF_H */
+17
usr/dummy-include/stdint.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef _DUMMY_STDINT_H 3 + #define _DUMMY_STDINT_H 4 + 5 + #include <linux/types.h> 6 + 7 + typedef __u64 uint64_t; 8 + typedef __u32 uint32_t; 9 + typedef __u16 uint16_t; 10 + typedef __u8 uint8_t; 11 + 12 + typedef __s64 int64_t; 13 + typedef __s32 int32_t; 14 + typedef __s16 int16_t; 15 + typedef __s8 int8_t; 16 + 17 + #endif /* _DUMMY_STDINT_H */
-7
usr/dummy-include/stdlib.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - #ifndef _STDLIB_H 3 - #define _STDLIB_H 4 - 5 - #error "Please do not include <stdlib.h> from exported headers" 6 - 7 - #endif /* _STDLIB_H */
+12
usr/dummy-include/string.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef _DUMMY_STRING_H 3 + #define _DUMMY_STRING_H 4 + 5 + #include <stddef.h> 6 + 7 + #define memset(_s, _c, _n) __builtin_memset(_s, _c, _n) 8 + #define memcpy(_dest, _src, _n) __builtin_memcpy(_dest, _src, _n) 9 + 10 + #define strlen(_s) __builtin_strlen(_s) 11 + 12 + #endif /* _DUMMY_STRING_H */
usr/dummy-include/sys/ioctl.h
+12
usr/dummy-include/sys/socket.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef _DUMMY_SYS_SOCKET_H 3 + #define _DUMMY_SYS_SOCKET_H 4 + 5 + #include <linux/socket.h> 6 + 7 + struct sockaddr { 8 + __kernel_sa_family_t sa_family; /* address family, AF_xxx */ 9 + char sa_data[14]; /* 14 bytes of protocol address */ 10 + }; 11 + 12 + #endif /* _DUMMY_SYS_SOCKET_H */
+3
usr/dummy-include/sys/time.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + 3 + #include <linux/time.h>
usr/dummy-include/sys/types.h
usr/dummy-include/time.h
usr/dummy-include/unistd.h
+41 -24
usr/include/Makefile
··· 7 7 # -std=c90 (equivalent to -ansi) catches the violation of those. 8 8 # We cannot go as far as adding -Wpedantic since it emits too many warnings. 9 9 UAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration 10 + UAPI_ARCH := $(or $(HEADER_ARCH),$(SRCARCH)) 10 11 11 - override c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include 12 + override c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) 13 + cxx_flags = $(filter-out -Wmissing-prototypes -Wstrict-prototypes -std=%, $(KBUILD_USERCFLAGS)) -std=c++98 12 14 13 15 # The following are excluded for now because they fail to build. 14 16 # ··· 50 48 51 49 # More headers are broken in some architectures 52 50 53 - ifeq ($(SRCARCH),arc) 51 + ifneq ($(filter arc openrisc xtensa nios2, $(UAPI_ARCH)),) 54 52 no-header-test += linux/bpf_perf_event.h 55 53 endif 56 54 57 - ifeq ($(SRCARCH),openrisc) 58 - no-header-test += linux/bpf_perf_event.h 59 - endif 60 - 61 - ifeq ($(SRCARCH),powerpc) 62 - no-header-test += linux/bpf_perf_event.h 63 - endif 64 - 65 - ifeq ($(SRCARCH),sparc) 55 + ifeq ($(UAPI_ARCH),sparc) 66 56 no-header-test += asm/uctx.h 67 57 no-header-test += asm/fbio.h 68 58 endif 69 59 70 - ifeq ($(SRCARCH),xtensa) 71 - no-header-test += linux/bpf_perf_event.h 72 - endif 73 - 74 60 # asm-generic/*.h is used by asm/*.h, and should not be included directly 75 61 no-header-test += asm-generic/% 62 + 63 + # The following are not compatible with C++. 64 + # 65 + # Do not add a new header to the list without legitimate reason. 66 + # Please consider to fix the header first. 67 + # 68 + # Sorted alphabetically. 69 + no-header-test-cxx += linux/auto_dev-ioctl.h 70 + no-header-test-cxx += linux/map_to_14segment.h 71 + no-header-test-cxx += linux/map_to_7segment.h 72 + no-header-test-cxx += linux/netfilter/xt_sctp.h 73 + no-header-test-cxx += linux/target_core_user.h 74 + no-header-test-cxx += linux/vhost.h 75 + no-header-test-cxx += linux/vhost_types.h 76 + no-header-test-cxx += linux/virtio_net.h 77 + no-header-test-cxx += linux/virtio_ring.h 78 + no-header-test-cxx += scsi/fc/fc_els.h 79 + 80 + ifeq ($(UAPI_ARCH),x86) 81 + no-header-test-cxx += asm/elf.h 82 + endif 76 83 77 84 # The following are using libc header and types. 78 85 # ··· 145 134 uses-libc += regulator/regulator.h 146 135 uses-libc += scsi/fc/fc_els.h 147 136 148 - ifeq ($(SRCARCH),hexagon) 137 + ifeq ($(UAPI_ARCH),hexagon) 149 138 uses-libc += asm/sigcontext.h 150 139 endif 151 140 152 - ifeq ($(SRCARCH),nios2) 141 + ifeq ($(UAPI_ARCH),nios2) 153 142 uses-libc += asm/ptrace.h 154 - uses-libc += linux/bpf_perf_event.h 155 143 endif 156 144 157 - ifeq ($(SRCARCH),s390) 145 + ifeq ($(UAPI_ARCH),s390) 158 146 uses-libc += asm/chpid.h 159 147 uses-libc += asm/chsc.h 160 148 endif 161 149 162 150 always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) 163 151 164 - target-no-libc = $(filter-out $(uses-libc), $*.h) 165 - target-can-compile = $(and $(filter-out $(no-header-test), $*.h), \ 166 - $(or $(CONFIG_CC_CAN_LINK), $(target-no-libc))) 152 + # $(cc-option) forces '-x c' which breaks '-x c++' detection. 153 + cc-can-compile-cxx := $(call try-run,$(CC) $(CLANG_FLAGS) -c -x c++ /dev/null -o "$$TMP", 1) 154 + 155 + target-libc = $(filter $(uses-libc), $*.h) 156 + target-can-compile = $(filter-out $(no-header-test), $*.h) 157 + target-can-compile-cxx = $(and $(cc-can-compile-cxx), $(target-can-compile), $(filter-out $(no-header-test-cxx), $*.h)) 158 + 159 + hdrtest-flags = -fsyntax-only -Werror \ 160 + -nostdinc -I $(obj) $(if $(target-libc), -I $(srctree)/usr/dummy-include) 167 161 168 162 # Include the header twice to detect missing include guard. 169 163 quiet_cmd_hdrtest = HDRTEST $< 170 164 cmd_hdrtest = \ 171 - $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ 172 - $(if $(target-no-libc), -nostdinc) \ 165 + $(CC) $(c_flags) $(hdrtest-flags) -x c /dev/null \ 173 166 $(if $(target-can-compile), -include $< -include $<); \ 167 + $(if $(target-can-compile-cxx), \ 168 + $(CC) $(cxx_flags) $(hdrtest-flags) -x c++ /dev/null -include $<;) \ 174 169 $(PERL) $(src)/headers_check.pl $(obj) $<; \ 175 170 touch $@ 176 171