From 4dad87a498feba0148054bebe83d0f4f1213b10a Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Mon, 30 Mar 2020 20:20:15 +0000 Subject: [PATCH] add shell script for stale dependency hack It's rather awkward to debug issues with the dependency cleanup hacks when implemented via make. Add a cleanup shell script and move the libomp hack there as an initial example. Reviewed by: brooks MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24228 --- Makefile.inc1 | 11 +---------- tools/build/depend-cleanup.sh | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 10 deletions(-) create mode 100755 tools/build/depend-cleanup.sh diff --git a/Makefile.inc1 b/Makefile.inc1 index 4761c138a7e9..102949333ada 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -924,17 +924,8 @@ _sanity_check: .PHONY .MAKE # replacing generated files. Handle these cases here in an ad-hoc fashion. _cleanobj_fast_depend_hack: .PHONY @echo ">>> Deleting stale dependencies..."; + sh ${.CURDIR}/tools/build/depend-cleanup.sh ${OBJTOP} # Date SVN Rev Syscalls/Changes -# 20200310 r358851 rename of openmp's ittnotify_static.c to .cpp -.for f in ittnotify_static - @if [ -e "${OBJTOP}/lib/libomp/.depend.${f}.pico" ] && \ - egrep -qw '${f}\.c' ${OBJTOP}/lib/libomp/.depend.${f}.pico; then \ - echo "Removing stale dependencies for ${f}"; \ - rm -f ${OBJTOP}/lib/libomp/.depend.${f}.* \ - ${OBJTOP}/obj-lib32/lib/libomp/.depend.${f}.* \ - ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libomp/.depend.${f}.*}; \ - fi -.endfor # Syscall stubs rewritten in C and obsolete MD assembly implementations # 20191009 r353340 removal of opensolaris_atomic.S (also r353381) .if ${MACHINE} != i386 diff --git a/tools/build/depend-cleanup.sh b/tools/build/depend-cleanup.sh new file mode 100755 index 000000000000..58a7eb74175b --- /dev/null +++ b/tools/build/depend-cleanup.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# +# $FreeBSD$ +# +# Our current make(1)-based approach to dependency tracking cannot cope with +# certain source tree changes, including: +# - removing source files +# - replacing generated files with files committed to the tree +# - changing file extensions (e.g. a C source file rewritten in C++) +# +# We handle those cases here in an ad-hoc fashion by looking for the known- +# bad case in the main .depend file, and if found deleting all of the related +# .depend files (including for example the lib32 version). + +OBJTOP=$1 +if [ ! -d "$OBJTOP" ]; then + echo "usage: $(basename $0) objtop" >&2 + exit 1 +fi + +# $1 directory +# $2 source filename w/o extension +# $3 source extension +clean_dep() +{ + if [ -e "$OBJTOP"/$1/.depend.$2.pico ] && \ + egrep -qw "$2\.$3" "$OBJTOP"/$1/.depend.$2.pico; then \ + echo "Removing stale dependencies for $2.$3"; \ + rm -f "$OBJTOP"/$1/.depend.$2.* \ + "$OBJTOP"/obj-lib32/$1/.depend.$2.* + fi +} + +# Date Rev Description +# 20200310 r358851 rename of openmp's ittnotify_static.c to .cpp +clean_dep lib/libomp ittnotify_static c