bug 1318370 - stop using -Z7 for MSVC compilation with sccache. r?glandium draft
authorTed Mielczarek <ted@mielczarek.org>
Wed, 14 Dec 2016 14:58:26 -0500
changeset 466714 f7ceac89121bd39c86d575ad552644dccbcbab0b
parent 466713 9074f717fa0528b65ecf42914b958466ace2c4bb
child 466715 b434f0d46118dcd43b809e5db7fc2cd3542a0ee8
push id42972
push userbmo:ted@mielczarek.org
push dateThu, 26 Jan 2017 11:20:45 +0000
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
         # 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"
--- 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
+# We remove the PDB file before compilation so that sccache knows it's safe to cache.
+RM_PDB_FILE = -$(RM) $(basename $(@F)).pdb
 LINK_PDBFILE ?= $(basename $(@F)).pdb
 ifdef MOZ_DEBUG
 CODFILE=$(basename $(@F)).cod
 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))))
 # Rules for building native targets must come first because of the host_ prefix
 	$(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
@@ -965,24 +974,27 @@ endif # MOZ_RUST
 	$(AS) -o $@ $(DEFINES) $(ASFLAGS) $($(notdir $<)_FLAGS) $(LOCAL_INCLUDES) -c $<
 	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
 	$(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
 	$(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
 $(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
 	$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
 $(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))