bug 1384557 - move _DEPEND_CFLAGS+CL_INCLUDES_PREFIX to toolchain.configure, ignore {CC,CXX}_WRAPPER when using sccache r=glandium

Currently mozconfig.cache overrides a few build options for sccache. This
patch moves them into toolchain.configure so that the build system will
set them properly when sccache is in use. Additionally, {CC,CXX}_WRAPPER
are set in config.mk, so just avoid setting them when sccache is in use.

MozReview-Commit-ID: FYlVKRI8OiN

--HG--
extra : rebase_source : 00715beb5fbd2c11311dec43809bd1febab56a11
extra : intermediate-source : 0f2b1b75b83737378d882a3c3e0d8dfb4efecd1f
extra : source : a8032ae9cb2ad1c4574c6ac6f5c2778863cd71e0
This commit is contained in:
Ted Mielczarek 2017-01-10 16:52:27 -05:00
Родитель 74722701b4
Коммит 54b6236e29
6 изменённых файлов: 37 добавлений и 92 удалений

Просмотреть файл

@ -187,8 +187,8 @@ set_config('XCODE_PATH', xcode_path)
option('--with-compiler-wrapper', env='COMPILER_WRAPPER', nargs=1,
help='Enable compiling with wrappers such as distcc and ccache')
option('--with-ccache', env='CCACHE', nargs='?',
help='Enable compiling with ccache')
js_option('--with-ccache', env='CCACHE', nargs='?',
help='Enable compiling with ccache')
@depends_if('--with-ccache')
@ -1211,6 +1211,17 @@ set_define('HAVE_VISIBILITY_ATTRIBUTE',
set_config('WRAP_SYSTEM_INCLUDES', wrap_system_includes)
set_config('VISIBILITY_FLAGS', visibility_flags)
@depends(c_compiler, using_sccache)
def depend_cflags(info, using_sccache):
if info.type not in ('clang-cl', 'msvc'):
return '-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
elif using_sccache:
# sccache supports a special flag to create depfiles
# by parsing MSVC's -showIncludes output.
return '-deps$(MDDEPDIR)/$(@F).pp'
set_config('_DEPEND_CFLAGS', depend_cflags)
@depends(c_compiler)
@imports('multiprocessing')

Просмотреть файл

@ -447,3 +447,25 @@ def alter_path(sdk_bin_path):
set_config('PATH', alter_path)
check_prog('MAKECAB', ('makecab.exe',))
@depends(c_compiler, using_sccache)
def need_showincludes_prefix(info, using_sccache):
# sccache does its own -showIncludes prefix checking.
if info.type in ('clang-cl', 'msvc') and not using_sccache:
return True
@depends(c_compiler, when=need_showincludes_prefix)
@imports(_from='re', _import='compile', _as='re_compile')
def msvc_showincludes_prefix(c_compiler):
pattern = re_compile(br'^([^:]*:.*[ :] )(.*\\stdio.h)$')
output = try_invoke_compiler([c_compiler.compiler], 'C', '#include <stdio.h>\n',
['-nologo', '-c', '-Fonul', '-showIncludes'])
for line in output.splitlines():
if line.endswith(b'\\stdio.h'):
m = pattern.match(line)
if m:
return m.group(1)
# We should have found the prefix and returned earlier
die('Cannot find cl -showIncludes prefix.')
set_config('CL_INCLUDES_PREFIX', msvc_showincludes_prefix)

Просмотреть файл

@ -124,12 +124,6 @@ else
mk_add_options "UPLOAD_EXTRA_FILES+=sccache.log.gz"
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="

Просмотреть файл

@ -120,8 +120,10 @@ CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
AUTOCONF_TOOLS = $(MOZILLA_DIR)/build/autoconf
ifdef _MSC_VER
ifndef MOZ_USING_SCCACHE
CC_WRAPPER ?= $(call py_action,cl)
CXX_WRAPPER ?= $(call py_action,cl)
endif
endif # _MSC_VER
CC := $(CC_WRAPPER) $(CC)

Просмотреть файл

@ -1836,46 +1836,6 @@ AC_LANG_C
MOZ_EXPAND_LIBS
dnl ========================================================
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
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(,)
dnl This output is localized, split at the first double space or colon and space.
_CL_PREFIX_REGEX="^\([^:]*:.*[ :] \)\(.*\\\stdio.h\)$"
CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\1/p'`
_CL_STDIO_PATH=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\2/p'`
changequote([,])
if ! test -e "$_CL_STDIO_PATH"; then
AC_MSG_ERROR([Unable to parse cl -showIncludes prefix. This compiler's locale has an unsupported formatting.])
fi
if test -z "$CL_INCLUDES_PREFIX"; then
AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
fi
AC_SUBST(CL_INCLUDES_PREFIX)
rm -f dummy-hello.c
dnl Make sure that the build system can handle non-ASCII characters
dnl in environment variables to prevent it from breaking silently on
dnl non-English systems.
NONASCII=$'\241\241'
AC_SUBST(NONASCII)
fi
fi
dnl ========================================================
dnl = Link js shell to system readline
dnl ========================================================
@ -2010,7 +1970,6 @@ HOST_CFLAGS=`echo \
HOST_CXXFLAGS=`echo \
$HOST_CXXFLAGS`
AC_SUBST(_DEPEND_CFLAGS)
AC_SUBST(MOZ_SYSTEM_NSPR)
OS_CFLAGS="$CFLAGS"

Просмотреть файл

@ -4128,48 +4128,6 @@ if test "$COMPILE_ENVIRONMENT"; then
MOZ_EXPAND_LIBS
fi # COMPILE_ENVIRONMENT
dnl ========================================================
dnl =
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
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(,)
dnl This output is localized, split at the first double space or colon and space.
_CL_PREFIX_REGEX="^\([^:]*:.*[ :] \)\(.*\\\stdio.h\)$"
CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\1/p'`
_CL_STDIO_PATH=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\2/p'`
changequote([,])
if ! test -e "$_CL_STDIO_PATH"; then
AC_MSG_ERROR([Unable to parse cl -showIncludes prefix. This compiler's locale has an unsupported formatting.])
fi
if test -z "$CL_INCLUDES_PREFIX"; then
AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
fi
AC_SUBST(CL_INCLUDES_PREFIX)
rm -f dummy-hello.c
dnl Make sure that the build system can handle non-ASCII characters
dnl in environment variables to prevent it from breaking silently on
dnl non-English systems.
NONASCII=$'\241\241'
AC_SUBST(NONASCII)
fi
fi
fi # COMPILE_ENVIRONMENT
dnl ========================================================
dnl =
dnl = Static Build Options
@ -4779,7 +4737,6 @@ HOST_CFLAGS=`echo \
HOST_CXXFLAGS=`echo \
$HOST_CXXFLAGS`
AC_SUBST(_DEPEND_CFLAGS)
AC_SUBST(MOZ_SYSTEM_JPEG)
AC_SUBST(MOZ_SYSTEM_PNG)
AC_SUBST(MOZ_SYSTEM_BZ2)