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.

kbuild: check sha1sum just once for each atomic header

It is unneeded to check the sha1sum every time.

Create the timestamp files to manage it.

Add '.' to clean-dirs because 'make clean' must visit ./Kbuild to
clean up the timestamp files.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+23 -41
+22 -7
Kbuild
··· 43 43 missing-syscalls: scripts/checksyscalls.sh $(offsets-file) 44 44 $(call cmd,syscalls) 45 45 46 - # Check atomic headers are up-to-date 46 + # Check the manual modification of atomic headers 47 47 48 - quiet_cmd_atomics = CALL $< 49 - cmd_atomics = $(CONFIG_SHELL) $< 48 + quiet_cmd_check_sha1 = CHKSHA1 $< 49 + cmd_check_sha1 = \ 50 + if ! command -v sha1sum >/dev/null; then \ 51 + echo "warning: cannot check the header due to sha1sum missing"; \ 52 + exit 0; \ 53 + fi; \ 54 + if [ "$$(sed -n '$$s:// ::p' $<)" != \ 55 + "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \ 56 + echo "error: $< has been modified." >&2; \ 57 + exit 1; \ 58 + fi; \ 59 + touch $@ 50 60 51 - PHONY += old-atomics 52 - old-atomics: scripts/atomic/check-atomics.sh 53 - $(call cmd,atomics) 61 + atomic-checks += $(addprefix $(obj)/.checked-, \ 62 + atomic-arch-fallback.h \ 63 + atomic-instrumented.h \ 64 + atomic-long.h) 65 + 66 + targets += $(atomic-checks) 67 + $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE 68 + $(call if_changed,check_sha1) 54 69 55 70 # A phony target that depends on all the preparation targets 56 71 57 72 PHONY += prepare 58 - prepare: $(offsets-file) missing-syscalls old-atomics 73 + prepare: $(offsets-file) missing-syscalls $(atomic-checks) 59 74 @:
+1 -1
Makefile
··· 1110 1110 $(libs-y) $(libs-m))) 1111 1111 1112 1112 build-dirs := $(vmlinux-dirs) 1113 - clean-dirs := $(sort $(vmlinux-dirs) Documentation \ 1113 + clean-dirs := $(sort $(vmlinux-dirs) Documentation . \ 1114 1114 $(patsubst %/,%,$(filter %/, $(core-) \ 1115 1115 $(drivers-) $(libs-)))) 1116 1116
-33
scripts/atomic/check-atomics.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - # 4 - # Check if atomic headers are up-to-date 5 - 6 - ATOMICDIR=$(dirname $0) 7 - ATOMICTBL=${ATOMICDIR}/atomics.tbl 8 - LINUXDIR=${ATOMICDIR}/../.. 9 - 10 - echo '' | sha1sum - > /dev/null 2>&1 11 - if [ $? -ne 0 ]; then 12 - printf "sha1sum not available, skipping atomic header checks.\n" 13 - exit 0 14 - fi 15 - 16 - cat <<EOF | 17 - linux/atomic/atomic-instrumented.h 18 - linux/atomic/atomic-long.h 19 - linux/atomic/atomic-arch-fallback.h 20 - EOF 21 - while read header; do 22 - OLDSUM="$(tail -n 1 ${LINUXDIR}/include/${header})" 23 - OLDSUM="${OLDSUM#// }" 24 - 25 - NEWSUM="$(sed '$d' ${LINUXDIR}/include/${header} | sha1sum)" 26 - NEWSUM="${NEWSUM%% *}" 27 - 28 - if [ "${OLDSUM}" != "${NEWSUM}" ]; then 29 - printf "warning: generated include/${header} has been modified.\n" 30 - fi 31 - done 32 - 33 - exit 0