Date: Mon, 21 Jun 2021 15:14:30 GMT From: Alex Richardson <arichardson@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: ab0c68ba4ae3 - main - Emit an error when we seen absolute paths to .o files Message-ID: <202106211514.15LFEUUo026227@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=ab0c68ba4ae37cb83d15e64ce2a33375135ae750 commit ab0c68ba4ae37cb83d15e64ce2a33375135ae750 Author: Alex Richardson <arichardson@FreeBSD.org> AuthorDate: 2021-06-21 13:58:01 +0000 Commit: Alex Richardson <arichardson@FreeBSD.org> 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}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106211514.15LFEUUo026227>