bug 1318370 - stop using -Z7 for MSVC compilation with sccache. r?glandium
We've been using -Z7 to make MSVC emit CodeView debug info directly in
the object files instead of in PDB files because sccache can't cache
PDB files if the same one is written to by multiple compiles, which
was previously happening in our build system, and was hard to override
in the NSS build. Now that those are fixed this should work fine.
This adds a bit to the compile rule to remove the PDB file before
compilation, since sccache won't cache a compilation if the PDB file
it is supposed to generate already exists (for the aforementioned reason).
MozReview-Commit-ID: rFlX0XfTGw
--- a/build/mozconfig.cache
+++ b/build/mozconfig.cache
@@ -126,18 +126,13 @@ else
case "$platform" in
win*)
# sccache supports a special flag to create depfiles.
#TODO: bug 1318370 - move this all into toolchain.configure
export _DEPEND_CFLAGS='-deps$(MDDEPDIR)/$(@F).pp'
# Windows builds have a default wrapper that needs to be overridden
mk_add_options "export CC_WRAPPER="
mk_add_options "export CXX_WRAPPER="
- # For now, sccache doesn't support separate PDBs so force debug info to be
- # in object files.
- mk_add_options "export COMPILE_PDB_FLAG="
- mk_add_options "export HOST_PDB_FLAG="
- mk_add_options "export MOZ_DEBUG_FLAGS=-Z7"
;;
esac
fi
fi
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -151,16 +151,20 @@ endif # FORCE_SHARED_LIB
endif # LIBRARY
ifeq ($(OS_ARCH),WINNT)
ifndef GNU_CC
COMPILE_PDB_FLAG ?= -Fd$(basename $(@F)).pdb
COMPILE_CFLAGS += $(COMPILE_PDB_FLAG)
COMPILE_CXXFLAGS += $(COMPILE_PDB_FLAG)
+ifdef MOZ_USING_SCCACHE
+# We remove the PDB file before compilation so that sccache knows it's safe to cache.
+RM_PDB_FILE = -$(RM) $(basename $(@F)).pdb
+endif
LINK_PDBFILE ?= $(basename $(@F)).pdb
ifdef MOZ_DEBUG
CODFILE=$(basename $(@F)).cod
endif
ifdef DEFFILE
OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE))
@@ -843,33 +847,38 @@ crate_src_libdep = $(call mk_global_crat
$(foreach f,$(RSSRCS),$(eval $(call src_libdep,$(f))))
$(foreach f,$(RS_STATICLIB_CRATE_SRC),$(eval $(call crate_src_libdep,$(f))))
$(OBJS) $(HOST_OBJS) $(PROGOBJS) $(HOST_PROGOBJS): $(GLOBAL_DEPS)
# Rules for building native targets must come first because of the host_ prefix
$(HOST_COBJS):
$(REPORT_BUILD_VERBOSE)
+ $(RM_PDB_FILE)
$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(HOST_CPPOBJS):
$(REPORT_BUILD_VERBOSE)
$(call BUILDSTATUS,OBJECT_FILE $@)
+ $(RM_PDB_FILE)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(HOST_CMOBJS):
$(REPORT_BUILD_VERBOSE)
+ $(RM_PDB_FILE)
$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(HOST_CMMOBJS):
$(REPORT_BUILD_VERBOSE)
+ $(RM_PDB_FILE)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
$(COBJS):
$(REPORT_BUILD_VERBOSE)
+ $(RM_PDB_FILE)
$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
# DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs:
# 'moc' only knows about #defines it gets on the command line (-D...), not in
# included headers like mozilla-config.h
$(filter moc_%.cpp,$(CPPSRCS)): moc_%.cpp: %.h
$(REPORT_BUILD_VERBOSE)
$(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
@@ -965,24 +974,27 @@ endif # MOZ_RUST
$(SOBJS):
$(REPORT_BUILD)
$(AS) -o $@ $(DEFINES) $(ASFLAGS) $($(notdir $<)_FLAGS) $(LOCAL_INCLUDES) -c $<
$(CPPOBJS):
$(REPORT_BUILD_VERBOSE)
$(call BUILDSTATUS,OBJECT_FILE $@)
+ $(RM_PDB_FILE)
$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CMMOBJS):
$(REPORT_BUILD_VERBOSE)
+ $(RM_PDB_FILE)
$(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(CMOBJS):
$(REPORT_BUILD_VERBOSE)
+ $(RM_PDB_FILE)
$(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
$(REPORT_BUILD_VERBOSE)
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
$(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))
$(REPORT_BUILD_VERBOSE)