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.
This commit is contained in:
Ted Mielczarek 2018-09-14 12:12:34 -04:00
Родитель 2bcbde60fe
Коммит 201bd292e7
6 изменённых файлов: 56 добавлений и 96 удалений

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

@ -217,8 +217,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')
@ -1260,6 +1260,32 @@ 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 info.type == 'clang-cl':
# 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.
return [
'-Xclang', '-MP',
'-Xclang', '-dependency-file',
'-Xclang', '$(MDDEPDIR)/$(@F).pp',
'-Xclang', '-MT',
'-Xclang', '$@'
]
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, check_build_environment, target)
@imports('multiprocessing')
@imports(_from='__builtin__', _import='min')

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

@ -484,6 +484,32 @@ 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.
# clang-cl uses a gcc-style dependency scheme, see toolchain.configure.
if info.type == '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)
# Make sure that the build system can handle non-ASCII characters in
# environment variables to prevent silent breakage on non-English systems.
set_config('NONASCII', b'\241\241')

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

@ -78,12 +78,6 @@ if test -n "$bucket"; then
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="

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

@ -124,10 +124,10 @@ AUTOCONF_TOOLS = $(MOZILLA_DIR)/build/autoconf
ifdef _MSC_VER
# clang-cl is smart enough to generate dependencies directly.
ifndef CLANG_CL
ifeq (,$(CLANG_CL)$(MOZ_USING_SCCACHE))
CC_WRAPPER ?= $(call py_action,cl)
CXX_WRAPPER ?= $(call py_action,cl)
endif # CLANG_CL
endif # CLANG_CL/MOZ_USING_SCCACHE
endif # _MSC_VER
CC := $(CC_WRAPPER) $(CC)

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

@ -1624,47 +1624,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
# 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 -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(,)
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
fi
fi
dnl ========================================================
dnl = Link js shell to system readline
dnl ========================================================
@ -1805,7 +1764,6 @@ HOST_CXXFLAGS=`echo \
$_COMPILATION_HOST_CXXFLAGS \
$HOST_CXXFLAGS`
AC_SUBST(_DEPEND_CFLAGS)
AC_SUBST(MOZ_SYSTEM_NSPR)
OS_CFLAGS="$CFLAGS"

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

@ -3748,49 +3748,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
# 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 -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(,)
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
fi
fi
fi # COMPILE_ENVIRONMENT
dnl ========================================================
dnl =
dnl = Static Build Options
@ -4385,7 +4342,6 @@ HOST_CXXFLAGS=`echo \
$_COMPILATION_HOST_CXXFLAGS \
$HOST_CXXFLAGS`
AC_SUBST(_DEPEND_CFLAGS)
AC_SUBST(MOZ_SYSTEM_JPEG)
AC_SUBST(MOZ_SYSTEM_PNG)