8221764: Reduce make Init.gmk logging overhead

Reviewed-by: tbell
This commit is contained in:
Erik Joelsson 2019-04-03 12:52:37 -07:00
parent 004b3ee748
commit 18146afe7f
2 changed files with 10 additions and 5 deletions

View File

@ -238,11 +238,13 @@ else # HAS_SPEC=true
ifeq ($(LOG_NOFILE), true)
# Disable build log if LOG=[level,]nofile was given
override BUILD_LOG_PIPE :=
override BUILD_LOG_PIPE_SIMPLE :=
endif
ifeq ($(filter dist-clean, $(SEQUENTIAL_TARGETS)), dist-clean)
# We can't have a log file if we're about to remove it.
override BUILD_LOG_PIPE :=
override BUILD_LOG_PIPE_SIMPLE :=
endif
ifeq ($(OUTPUT_SYNC_SUPPORTED), true)
@ -303,7 +305,7 @@ else # HAS_SPEC=true
main: $(INIT_TARGETS)
ifneq ($(SEQUENTIAL_TARGETS)$(PARALLEL_TARGETS), )
$(call RotateLogFiles)
$(PRINTF) "Building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE)
$(PRINTF) "Building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE_SIMPLE)
ifneq ($(SEQUENTIAL_TARGETS), )
# Don't touch build output dir since we might be cleaning. That
# means no log pipe.
@ -325,7 +327,7 @@ else # HAS_SPEC=true
$(PARALLEL_TARGETS) $(COMPARE_BUILD_MAKE) $(BUILD_LOG_PIPE) || \
( exitcode=$$? && \
$(PRINTF) "\nERROR: Build failed for $(TARGET_DESCRIPTION) (exit code $$exitcode) \n" \
$(BUILD_LOG_PIPE) && \
$(BUILD_LOG_PIPE_SIMPLE) && \
cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -j 1 -f make/Init.gmk \
HAS_SPEC=true on-failure ; \
exit $$exitcode ) )
@ -336,7 +338,7 @@ else # HAS_SPEC=true
if test -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error ; then \
exit 1 ; \
fi
$(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE)
$(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE_SIMPLE)
$(call ReportProfileTimes)
endif

View File

@ -296,6 +296,9 @@ else # $(HAS_SPEC)=true
BUILD_PROFILE_LOG := $(OUTPUTDIR)/build-profile.log
BUILD_LOG_PIPE := > >($(TEE) -a $(BUILD_LOG)) 2> >($(TEE) -a $(BUILD_LOG) >&2) && wait
# Use this for simple echo/printf commands that are never expected to print
# to stderr.
BUILD_LOG_PIPE_SIMPLE := | $(TEE) -a $(BUILD_LOG)
ifneq ($(CUSTOM_ROOT), )
topdir=$(CUSTOM_ROOT)
@ -514,7 +517,7 @@ else # $(HAS_SPEC)=true
"`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | \
$(XARGS) $(CAT) | $(SORT) -k 2`" \
"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" \
$(BUILD_LOG_PIPE)
$(BUILD_LOG_PIPE_SIMPLE)
endef
define ReportProfileTimes
@ -524,7 +527,7 @@ else # $(HAS_SPEC)=true
$(CAT) $(BUILD_PROFILE_LOG) && \
$(ECHO) End $(notdir $(BUILD_PROFILE_LOG)); \
} \
$(BUILD_LOG_PIPE)
$(BUILD_LOG_PIPE_SIMPLE)
)
endef