bug 1481614 - detect icecream usage in build telemetry. r=chmanchester,glandium
authorTed Mielczarek <ted@mielczarek.org>
Mon, 25 Feb 2019 19:06:27 +0000
changeset 518842 22436d124e3a4025a0a1497572bc741dfc8350fe
parent 518841 959aa87abd32bbab3b094cf01939e5569ac3245c
child 518843 69598c5631cecd60154f9595a8a207e1e03c7d06
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester, glandium
bugs1481614
milestone67.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 1481614 - detect icecream usage in build telemetry. r=chmanchester,glandium This patch adds detection for when icecream is in use to build telemetry. icecream is commonly enabled in two ways: by either setting CC/CXX to point to icecream's cc/c++ symlinks, or by setting adding mk_add_options 'export CCACHE_PREFIX=icecc' to a mozconfig when also using ccache. For the former, this patch adds a simple configure check to see if CXX is a symlink to a file named 'icecc'. For the latter this patch adds CCACHE_PREFIX as a configure subst to capture the value. We don't currently have a facility for writing telemetry tests that depend on configure values. Local manual testing shows that it does work as expected. Differential Revision: https://phabricator.services.mozilla.com/D18138
build/moz.configure/toolchain.configure
config/config.mk
python/mozbuild/mozbuild/telemetry.py
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -317,16 +317,22 @@ def ccache(value):
         return value
     # If --with-ccache was given without an explicit value, we default to
     # 'ccache'.
     return 'ccache'
 
 
 ccache = check_prog('CCACHE', progs=(), input=ccache)
 
+js_option(env='CCACHE_PREFIX',
+          nargs=1,
+          help='Compiler prefix to use when using ccache')
+
+set_config('CCACHE_PREFIX', depends_if('CCACHE_PREFIX')(lambda prefix: prefix[0]))
+
 # Distinguish ccache from sccache.
 
 
 @depends_if(ccache)
 def ccache_is_sccache(ccache):
     return check_cmd_output(ccache, '--version').startswith('sccache')
 
 
@@ -1216,16 +1222,25 @@ host_c_compiler = compiler('C', host, ot
 host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler,
                              other_compiler=cxx_compiler,
                              other_c_compiler=c_compiler)
 
 # Generic compiler-based conditions.
 building_with_gcc = depends(c_compiler)(lambda info: info.type == 'gcc')
 
 
+@depends(cxx_compiler)
+@imports('os')
+def cxx_is_icecream(info):
+    if (os.path.islink(info.compiler) and os.path.basename(
+            os.readlink(info.compiler)) == 'icecc'):
+        return True
+set_config('CXX_IS_ICECREAM', cxx_is_icecream)
+
+
 @depends(c_compiler)
 def msvs_version(info):
     # clang-cl emulates the same version scheme as cl. And MSVS_VERSION needs to
     # be set for GYP on Windows.
     if info.type == 'clang-cl':
         return '2017'
 
     return ''
--- a/config/config.mk
+++ b/config/config.mk
@@ -266,16 +266,20 @@ export LIB
 endif
 
 ifdef MOZ_USING_CCACHE
 ifdef CLANG_CXX
 export CCACHE_CPP2=1
 endif
 endif
 
+ifdef CCACHE_PREFIX
+export CCACHE_PREFIX
+endif
+
 # Set link flags according to whether we want a console.
 ifeq ($(OS_ARCH),WINNT)
 ifdef MOZ_WINCONSOLE
 ifeq ($(MOZ_WINCONSOLE),1)
 WIN32_EXE_LDFLAGS	+= $(WIN32_CONSOLE_EXE_LDFLAGS)
 else # MOZ_WINCONSOLE
 WIN32_EXE_LDFLAGS	+= $(WIN32_GUI_EXE_LDFLAGS)
 endif
--- a/python/mozbuild/mozbuild/telemetry.py
+++ b/python/mozbuild/mozbuild/telemetry.py
@@ -204,22 +204,26 @@ def get_build_opts(substs):
         opts = {
             k: ty(substs.get(s, None)) for (k, s, ty) in (
                 # Selected substitutions.
                 ('artifact', 'MOZ_ARTIFACT_BUILDS', bool),
                 ('debug', 'MOZ_DEBUG', bool),
                 ('opt', 'MOZ_OPTIMIZE', bool),
                 ('ccache', 'CCACHE', bool),
                 ('sccache', 'MOZ_USING_SCCACHE', bool),
-                # TODO: detect icecream: https://bugzilla.mozilla.org/show_bug.cgi?id=1481614
             )
         }
         compiler = substs.get('CC_TYPE', None)
         if compiler:
             opts['compiler'] = str(compiler)
+        # icecream may be enabled by setting CC/CXX to symlinks to icecc,
+        # or if using it together with ccache by setting CCACHE_PREFIX=icecc.
+        prefix = os.path.basename(substs.get('CCACHE_PREFIX', ''))
+        if substs.get('CXX_IS_ICECREAM', None) or prefix == 'icecc':
+            opts['icecream'] = True
         return opts
     except BuildEnvironmentNotFoundException:
         return {}
 
 
 def filter_args(command, argv, paths):
     '''
     Given the full list of command-line arguments, remove anything up to and including `command`,