4 # Our current make(1)-based approach to dependency tracking cannot cope with
5 # certain source tree changes, including:
6 # - removing source files
7 # - replacing generated files with files committed to the tree
8 # - changing file extensions (e.g. a C source file rewritten in C++)
10 # We handle those cases here in an ad-hoc fashion by looking for the known-
11 # bad case in the main .depend file, and if found deleting all of the related
12 # .depend files (including for example the lib32 version).
14 # These tests increase the build time (albeit by a small amount), so they
15 # should be removed once enough time has passed and it is extremely unlikely
16 # anyone would try a NO_CLEAN build against an object tree from before the
17 # related change. One year should be sufficient.
24 echo "$(basename "$0"):" "$@" >&2
35 echo "usage: $(basename $0) [-v] [-n] objtop" >&2
40 while getopts vn o; do
63 if [ ! -d "$OBJTOP" ]; then
64 err "$OBJTOP: Not a directory"
67 if [ -z "${MACHINE+set}" ]; then
71 if [ -z "${MACHINE_ARCH+set}" ]; then
72 err "MACHINE_ARCH not set"
75 if [ -z "${ALL_libcompats+set}" ]; then
76 err "ALL_libcompats not set"
81 if [ "$VERBOSE" ]; then
84 if ! [ "$PRETEND" ]; then
90 # $2 source filename w/o extension
94 for libcompat in "" $ALL_libcompats; do
95 dirprfx=${libcompat:+obj-lib${libcompat}/}
96 if egrep -qw "$2\.$3" "$OBJTOP"/$dirprfx$1/.depend.$2.*o 2>/dev/null; then
97 echo "Removing stale ${libcompat:+lib${libcompat} }dependencies and objects for $2.$3"
99 "$OBJTOP"/$dirprfx$1/.depend.$2.* \
100 "$OBJTOP"/$dirprfx$1/$2.*o
105 # Date Rev Description
106 # 20200310 r358851 rename of openmp's ittnotify_static.c to .cpp
107 clean_dep lib/libomp ittnotify_static c
108 # 20200414 r359930 closefrom
109 clean_dep lib/libc closefrom S
111 # 20200826 r364746 OpenZFS merge, apply a big hammer (remove whole tree)
112 if [ -e "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o ] && \
113 egrep -qw "cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c" \
114 "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o; then
115 echo "Removing old ZFS tree"
116 for libcompat in "" $ALL_libcompats; do
117 dirprfx=${libcompat:+obj-lib${libcompat}/}
118 run rm -rf "$OBJTOP"/${dirprfx}cddl
122 # 20200916 WARNS bumped, need bootstrapped crunchgen stubs
123 if [ -e "$OBJTOP"/rescue/rescue/rescue.c ] && \
124 ! grep -q 'crunched_stub_t' "$OBJTOP"/rescue/rescue/rescue.c; then
125 echo "Removing old rescue(8) tree"
126 run rm -rf "$OBJTOP"/rescue/rescue
129 # 20210105 fda7daf06301 pfctl gained its own version of pf_ruleset.c
130 if [ -e "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o ] && \
131 egrep -qw "sys/netpfil/pf/pf_ruleset.c" \
132 "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o; then
133 echo "Removing old pf_ruleset dependecy file"
134 run rm -rf "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o
137 # 20210108 821aa63a0940 non-widechar version of ncurses removed
138 if [ -e "$OBJTOP"/lib/ncurses/ncursesw ]; then
139 echo "Removing stale ncurses objects"
140 for libcompat in "" $ALL_libcompats; do
141 dirprfx=${libcompat:+obj-lib${libcompat}/}
142 run rm -rf "$OBJTOP"/${dirprfx}lib/ncurses
146 # 20210608 f20893853e8e move from atomic.S to atomic.c
147 clean_dep cddl/lib/libspl atomic S
148 # 20211207 cbdec8db18b5 switch to libthr-friendly pdfork
149 clean_dep lib/libc pdfork S
151 # 20211230 5e6a2d6eb220 libc++.so.1 path changed in ldscript
152 if [ -e "$OBJTOP"/lib/libc++/libc++.ld ] && \
153 fgrep -q "/usr/lib/libc++.so" "$OBJTOP"/lib/libc++/libc++.ld; then
154 echo "Removing old libc++ linker script"
155 run rm -f "$OBJTOP"/lib/libc++/libc++.ld
158 # 20220326 fbc002cb72d2 move from bcmp.c to bcmp.S
159 if [ "$MACHINE_ARCH" = "amd64" ]; then
160 clean_dep lib/libc bcmp c
163 # 20220524 68fe988a40ca kqueue_test binary replaced shell script
164 if stat "$OBJTOP"/tests/sys/kqueue/libkqueue/*kqtest* \
165 "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.kqtest* >/dev/null 2>&1; then
166 echo "Removing old kqtest"
167 run rm -f "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.* \
168 "$OBJTOP"/tests/sys/kqueue/libkqueue/*
171 # 20221115 42d10b1b56f2 move from rs.c to rs.cc
172 clean_dep usr.bin/rs rs c
174 # 20230110 bc42155199b5 usr.sbin/zic/zic -> usr.sbin/zic
175 if [ -d "$OBJTOP"/usr.sbin/zic/zic ] ; then
176 echo "Removing old zic directory"
177 run rm -rf "$OBJTOP"/usr.sbin/zic/zic
180 # 20230208 29c5f8bf9a01 move from mkmakefile.c to mkmakefile.cc
181 clean_dep usr.sbin/config mkmakefile c
182 # 20230209 83d7ed8af3d9 convert to main.cc and mkoptions.cc
183 clean_dep usr.sbin/config main c
184 clean_dep usr.sbin/config mkoptions c
186 # 20230401 54579376c05e kqueue1 from syscall to C wrapper
187 clean_dep lib/libc kqueue1 S
189 # 20230623 b077aed33b7b OpenSSL 3.0 update
190 if [ -f "$OBJTOP"/secure/lib/libcrypto/aria.o ]; then
191 echo "Removing old OpenSSL 1.1.1 tree"
192 for libcompat in "" $ALL_libcompats; do
193 dirprfx=${libcompat:+obj-lib${libcompat}/}
194 run rm -rf "$OBJTOP"/${dirprfx}secure/lib/libcrypto \
195 "$OBJTOP"/${dirprfx}secure/lib/libssl
199 # 20230714 ee8b0c436d72 replace ffs/fls implementations with clang builtins
200 clean_dep lib/libc ffs S
201 clean_dep lib/libc ffsl S
202 clean_dep lib/libc ffsll S
203 clean_dep lib/libc fls S
204 clean_dep lib/libc flsl S
205 clean_dep lib/libc flsll S
207 # 20230815 28f6c2f29280 GoogleTest update
208 if [ -e "$OBJTOP"/tests/sys/fs/fusefs/mockfs.o ] && \
209 grep -q '_ZN7testing8internal18g_linked_ptr_mutexE' "$OBJTOP"/tests/sys/fs/fusefs/mockfs.o; then
210 echo "Removing stale fusefs GoogleTest objects"
211 run rm -rf "$OBJTOP"/tests/sys/fs/fusefs
214 # 20231031 0527c9bdc718 Remove forward compat ino64 stuff
215 clean_dep lib/libc fstat c
216 clean_dep lib/libc fstatat c
217 clean_dep lib/libc fstatfs c
218 clean_dep lib/libc getdirentries c
219 clean_dep lib/libc getfsstat c
220 clean_dep lib/libc statfs c