git: aea2a658ef8b - main - Don't delete hack.c - causes perpetual 'out of date' kernel

From: David E. O'Brien <>
Date: Thu, 17 Feb 2022 04:03:32 UTC
The branch main has been updated by obrien:


commit aea2a658ef8b75a2246bf0d44f80ba8d6c6d344e
Author:     David E. O'Brien <>
AuthorDate: 2022-02-14 02:24:36 +0000
Commit:     David E. O'Brien <>
CommitDate: 2022-02-17 04:02:50 +0000

    Don't delete hack.c - causes perpetual 'out of date' kernel
    Deleting hack.c cause the kernel to always be out of date:
       $ make kernel
       make: /usr/src/sys/amd64/compile/GENERIC/.depend.hack.pico, 1:
                 ignoring stale .depend for hack.c
       :> hack.c
       cc -shared -O2 -pipe ... -nostdlib hack.c -o hack.pico
       rm -f hack.c
       MAKE="make" sh ../../../conf/ "-R" GENERIC
       cc -c -O2 -pipe ...  -std=iso9899:1999 -Werror  vers.c
       ctfconvert -L VERSION -g vers.o
       linking kernel.full
    Keeping hack.c in the compile directory causes no harm,
    so there's no reason to delete it.
    Also rename the file to "force-dyamic-hack.c" so it is
    clear what the hack is aboug.
    Reviewed by: sjg
    Differential Revision:
 sys/conf/ | 12 +++++++-----
 sys/conf/  |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/sys/conf/ b/sys/conf/
index 087beb73f9ae..4fcae712e974 100644
--- a/sys/conf/
+++ b/sys/conf/
@@ -230,10 +230,12 @@ kernel-clean:
 # This is a hack.  BFD "optimizes" away dynamic mode if there are no
 # dynamic references.  We could probably do a '-Bforcedynamic' mode like
 # in the a.out ld.  For now, this works.
-hack.pico: Makefile
-	:> hack.c
-	${CC} ${CCLDFLAGS} -shared ${CFLAGS} -nostdlib hack.c -o hack.pico
-	rm -f hack.c
+	:> ${.TARGET}
+force-dynamic-hack.pico: force-dynamic-hack.c Makefile
+	${CC} ${CCLDFLAGS} -shared ${CFLAGS} -nostdlib \
+	    force-dynamic-hack.c -o ${.TARGET} $S/kern/ genoffset.o
 	NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/ genoffset.o > ${.TARGET}
@@ -444,7 +446,7 @@ config.o env.o hints.o vers.o vnode_if.o:
-vers.c: $S/conf/ $S/sys/param.h ${SYSTEM_DEP}
+vers.c: .NOMETA_CMP $S/conf/ $S/sys/param.h ${SYSTEM_DEP:Nvers.*}
 	MAKE="${MAKE}" sh $S/conf/ ${REPRO_FLAG} ${KERN_IDENT}
 vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
diff --git a/sys/conf/ b/sys/conf/
index 8c753783b527..5a786c81324d 100644
--- a/sys/conf/
+++ b/sys/conf/
@@ -314,7 +314,7 @@ SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
-SYSTEM_OBJS+= hack.pico
+SYSTEM_OBJS+= force-dynamic-hack.pico
 KEYMAP=kbdcontrol -P ${SRCTOP}/share/vt/keymaps -P ${SRCTOP}/share/syscons/keymaps
 KEYMAP_FIX=sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /'