From owner-dev-commits-src-all@freebsd.org Mon Jun 21 15:14:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D47FD64A6A3; Mon, 21 Jun 2021 15:14:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G7tNk5PRsz3pj7; Mon, 21 Jun 2021 15:14:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A17BF1F4D7; Mon, 21 Jun 2021 15:14:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15LFEUvJ026228; Mon, 21 Jun 2021 15:14:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15LFEUUo026227; Mon, 21 Jun 2021 15:14:30 GMT (envelope-from git) Date: Mon, 21 Jun 2021 15:14:30 GMT Message-Id: <202106211514.15LFEUUo026227@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: ab0c68ba4ae3 - main - Emit an error when we seen absolute paths to .o files MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ab0c68ba4ae37cb83d15e64ce2a33375135ae750 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2021 15:14:30 -0000 The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=ab0c68ba4ae37cb83d15e64ce2a33375135ae750 commit ab0c68ba4ae37cb83d15e64ce2a33375135ae750 Author: Alex Richardson AuthorDate: 2021-06-21 13:58:01 +0000 Commit: Alex Richardson CommitDate: 2021-06-21 15:13:54 +0000 Emit an error when we seen absolute paths to .o files This is usually an error caused by using an absolute path in SRCS. This happened to me in 83c20b8a2da0 due to changing LDADD to SRCS. I did not notice that this had created a .o file inside the source tree since .gitignore contains "*.o" and therefore git did not report any changes. Adding this warning message to bsd.lib.mk/bsd.prog.mk should prevent issues like this in the future. There was exactly one case of an absolute OBJS path in the current source tree but that was removed in e713d3a013882893fceb84dd14569052271497a9. Reviewed By: emaste (earlier version), imp Differential Revision: https://reviews.freebsd.org/D28467 --- share/mk/bsd.dep.mk | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index a63b9e46deca..b8dc59d52543 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -192,6 +192,17 @@ DEPEND_MP?= -MP # avoid collisions. DEPEND_FILTER= C,/,_,g .if !empty(OBJS) +.if !defined(_ALLOW_ABSOLUTE_OBJ_PATH) && ${OBJS:M/*} +# Absolute paths to OBJS should be an error inside ${SRCTOP}, but some users +# might be relying on this feature, so add an opt-out mechanism. +.if defined(SRCTOP) && ${OBJS:M${SRCTOP}*} +.error "$$OBJS inside $$SRCTOP not allowed: ${OBJS:M${SRCTOP}*}" +.elif ${OBJS:N${_ABSOLUTE_PATH_OBJS}:M/*} +.error "$$OBJS absolute path not allowed: ${OBJS:N${_ABSOLUTE_PATH_OBJS}:M/*}. \ + If this is intended, add them to _ABSOLUTE_PATH_OBJS to silence this error\ + or define _ALLOW_ABSOLUTE_OBJ_PATH to disable this diagnostic." +.endif +.endif DEPENDOBJS+= ${OBJS} .else DEPENDSRCS+= ${SRCS:M*.[cSC]} ${SRCS:M*.cxx} ${SRCS:M*.cpp} ${SRCS:M*.cc}