Bug 1340588 - enable clang-cl to generate depfiles directly, rather than using a wrapper; r=build-peer
authorNathan Froyd <froydnj@mozilla.com>
Tue, 13 Mar 2018 09:06:00 -0500
changeset 407918 30dc6c484d42504bb586b7b02cf6561dbd50136e
parent 407917 fe9325224b5fa0e1ab902a602b0c3bbd84a47ba3
child 407919 deb7714a7bcd3448952440e92d0209abec6b886d
child 407957 4ffbf8c00b30a9015a6fc77784ef7e7f1e2355d9
push id33621
push userapavel@mozilla.com
push dateTue, 13 Mar 2018 17:12:05 +0000
treeherdermozilla-central@deb7714a7bcd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbuild-peer
bugs1340588
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1340588 - enable clang-cl to generate depfiles directly, rather than using a wrapper; r=build-peer We use a wrapper script when compiling with MSVC to parse the /showIncludes output and thereby generate a Makefile dependency fragment. This fragment enables us to do correct and faster incremental builds. But the cost of invoking the wrapper script can be significant; it's an extra process or two to launch for every single compilation. Instead, let's have clang-cl generate the dependencies directly, which should be somewhat faster.
config/config.mk
js/src/old-configure.in
old-configure.in
--- a/config/config.mk
+++ b/config/config.mk
@@ -115,18 +115,21 @@ else
   win_srcdir := $(srcdir)
   BUILD_TOOLS = $(MOZILLA_DIR)/build/unix
 endif
 
 CONFIG_TOOLS	= $(MOZ_BUILD_ROOT)/config
 AUTOCONF_TOOLS	= $(MOZILLA_DIR)/build/autoconf
 
 ifdef _MSC_VER
+# clang-cl is smart enough to generate dependencies directly.
+ifndef CLANG_CL
 CC_WRAPPER ?= $(call py_action,cl)
 CXX_WRAPPER ?= $(call py_action,cl)
+endif # CLANG_CL
 endif # _MSC_VER
 
 CC := $(CC_WRAPPER) $(CC)
 CXX := $(CXX_WRAPPER) $(CXX)
 MKDIR ?= mkdir
 SLEEP ?= sleep
 TOUCH ?= touch
 
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -1598,16 +1598,23 @@ dnl =
 dnl = Build depencency options
 dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(Build dependencies)
 
 if test "$GNU_CC" -a "$GNU_CXX"; then
   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
 else
+  # clang-cl doesn't accept the normal -MD -MP -MF options that clang does, but
+  # the underlying cc1 binary understands how to generate dependency files.
+  # These options are based on analyzing what the normal clang driver sends to
+  # cc1 when given the "correct" dependency options.
+  if test -n "$CLANG_CL"; then
+   _DEPEND_CFLAGS='-Xclang -MP -Xclang -MG -Xclang -dependency-file -Xclang $(MDDEPDIR)/$(@F).pp -Xclang -MT -Xclang $@'
+  fi
   dnl Don't override this for MSVC
   if test -z "$_WIN32_MSVC"; then
     _USE_CPP_INCLUDE_FLAG=
     _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
   else
     echo '#include <stdio.h>' > dummy-hello.c
     changequote(,)
--- a/old-configure.in
+++ b/old-configure.in
@@ -3851,16 +3851,23 @@ dnl = Build depencency options
 dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(Build dependencies)
 
 if test "$COMPILE_ENVIRONMENT"; then
 if test "$GNU_CC" -a "$GNU_CXX"; then
   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
 else
+  # clang-cl doesn't accept the normal -MD -MP -MF options that clang does, but
+  # the underlying cc1 binary understands how to generate dependency files.
+  # These options are based on analyzing what the normal clang driver sends to
+  # cc1 when given the "correct" dependency options.
+  if test -n "$CLANG_CL"; then
+   _DEPEND_CFLAGS='-Xclang -MP -Xclang -MG -Xclang -dependency-file -Xclang $(MDDEPDIR)/$(@F).pp -Xclang -MT -Xclang $@'
+  fi
   dnl Don't override this for MSVC
   if test -z "$_WIN32_MSVC"; then
     _USE_CPP_INCLUDE_FLAG=
     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
   else
     echo '#include <stdio.h>' > dummy-hello.c
     changequote(,)