Skip to content

Commit

Permalink
kbuild: make scripts/adjust_autoksyms.sh robust against timestamp races
Browse files Browse the repository at this point in the history
Some filesystems have timestamps with coarse precision that may allow
for a recently built object file to have the same timestamp as the
updated time on one of its dependency files. When that happens, the
object file doesn't get rebuilt as it should.

This is especially the case on filesystems that don't have sub-second
time precision, such as ext3 or Ext4 with 128B inodes.

Let's prevent that by making sure updated dependency files have a newer
timestamp than the first file we created (i.e. autoksyms.h.tmpnew).

Reported-by: Thomas Lindroth <thomas.lindroth@gmail.com>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Thomas Lindroth <thomas.lindroth@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
  • Loading branch information
Nicolas Pitre authored and Masahiro Yamada committed Mar 21, 2018
1 parent 0c8efd6 commit 825d487
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/adjust_autoksyms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ while read sympath; do
depfile="include/config/ksym/${sympath}.h"
mkdir -p "$(dirname "$depfile")"
touch "$depfile"
# Filesystems with coarse time precision may create timestamps
# equal to the one from a file that was very recently built and that
# needs to be rebuild. Let's guard against that by making sure our
# dep files are always newer than the first file we created here.
while [ ! "$depfile" -nt "$new_ksyms_file" ]; do
touch "$depfile"
done
echo $((count += 1))
done | tail -1 )
changed=${changed:-0}
Expand Down

0 comments on commit 825d487

Please sign in to comment.