git: 336b6d11922a - main - build: Use -f when copying sources

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Thu, 13 Aug 2026 12:36:34 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=336b6d11922ac3d080de50f789d40ff95b540cdf

commit 336b6d11922ac3d080de50f789d40ff95b540cdf
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-08-13 12:28:09 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-08-13 12:31:54 +0000

    build: Use -f when copying sources
    
    If one of the source files we copy is non-writeable, cp will create a
    non-writeable copy.  If the original is later modified, cp will fail to
    overwrite the copy since it is not writeable.  Using cp -f ensures the
    copy always succeeds, as long as the object directory is writeable.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Sponsored by:   NetApp, Inc.
---
 tools/build/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/build/Makefile b/tools/build/Makefile
index d71cc710be87..e7af3129730b 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -110,7 +110,7 @@ _WITH_EXPLICIT_BZERO!= cat ${HOST_INCLUDE_ROOT}/strings.h ${HOST_INCLUDE_ROOT}/s
 # cause it to pick the file from libkern instead (which won't compile).
 # Avoid modifying .PATH by creating a copy in the build directory instead.
 explicit_bzero.c: ${SRCTOP}/sys/libkern/explicit_bzero.c
-	cp ${.ALLSRC} ${.TARGET}
+	cp -f ${.ALLSRC} ${.TARGET}
 CLEANFILES+=	explicit_bzero.c
 INCS+=		strings.h
 SRCS+=		explicit_bzero.c
@@ -277,7 +277,7 @@ SRCS+=	capsicum_stubs.c
 # XXX: we can't add ${SRCTOP}/sys/kern to .PATH since that will causes
 # conflicts with other files. Instead copy subr_capability to the build dir.
 subr_capability.c: ${SRCTOP}/sys/kern/subr_capability.c
-	cp ${.ALLSRC} ${.TARGET}
+	cp -f ${.ALLSRC} ${.TARGET}
 SRCS+=	subr_capability.c
 CLEANFILES+=	subr_capability.c