Don't run cc --version during cleandir/obj stages

This will no work when there is no cc in $PATH (which is the case before the
cross-tools stage once we no longer inherit $PATH in $WMAKE).
The variables set by bsd.compiler.mk/bsd.linker.mk are not needed in these
stages so this avoids a little bit of makefile parsing.

Reviewed By:	emaste
Approved By:	jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D16814
This commit is contained in:
Alex Richardson 2018-10-31 10:45:28 +00:00
parent be7018ffd4
commit d6be9fdde5
2 changed files with 18 additions and 5 deletions

View File

@ -950,7 +950,7 @@ _worldtmp: .PHONY
.else .else
${_+_}@if [ -e "${WORLDTMP}" ]; then \ ${_+_}@if [ -e "${WORLDTMP}" ]; then \
echo ">>> Deleting stale files in build tree..."; \ echo ">>> Deleting stale files in build tree..."; \
cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES _NO_INCLUDE_COMPILERMK=t \
delete-old delete-old-libs >/dev/null; \ delete-old delete-old-libs >/dev/null; \
fi fi
rm -rf ${WORLDTMP}/legacy/usr/include rm -rf ${WORLDTMP}/legacy/usr/include
@ -1003,19 +1003,21 @@ _cleanobj:
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> stage 2.1: cleaning up the object tree" @echo ">>> stage 2.1: cleaning up the object tree"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR} # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
# since the restricted $PATH might not contain a valid cc binary
${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
.if defined(LIBCOMPAT) .if defined(LIBCOMPAT)
${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR} ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
.endif .endif
.else .else
${_+_}cd ${.CURDIR}; ${WMAKE} _cleanobj_fast_depend_hack ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
.endif # !defined(NO_CLEAN) .endif # !defined(NO_CLEAN)
_obj: _obj:
@echo @echo
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> stage 2.2: rebuilding the object tree" @echo ">>> stage 2.2: rebuilding the object tree"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${WMAKE} obj ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
_build-tools: _build-tools:
@echo @echo
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"

View File

@ -33,6 +33,16 @@ __<bsd.compiler.mk>__:
.include <bsd.opts.mk> .include <bsd.opts.mk>
.if defined(_NO_INCLUDE_COMPILERMK)
# If _NO_INCLUDE_COMPILERMK is set we are doing a make obj/cleandir/cleanobj
# and might not have a valid compiler in $PATH yet. In this case just set the
# variables that are expected by the other .mk files and return
COMPILER_TYPE=none
X_COMPILER_TYPE=none
COMPILER_VERSION=0
X_COMPILER_VERSION=0
COMPILER_FEATURES=none
.else
# command = /usr/local/bin/ccache cc ... # command = /usr/local/bin/ccache cc ...
# wrapper = /usr/local/libexec/ccache/cc ... # wrapper = /usr/local/libexec/ccache/cc ...
CCACHE_BUILD_TYPE?= command CCACHE_BUILD_TYPE?= command
@ -220,4 +230,5 @@ ${var}.${${X_}_cc_hash}:= ${${var}}
.if !defined(_NO_INCLUDE_LINKERMK) .if !defined(_NO_INCLUDE_LINKERMK)
.include <bsd.linker.mk> .include <bsd.linker.mk>
.endif .endif
.endif # defined(_NO_INCLUDE_COMPILERMK)
.endif # !target(__<bsd.compiler.mk>__) .endif # !target(__<bsd.compiler.mk>__)