Bug 1412267 - Fix the inclusion of MOZ_DEBUG_FLAGS in the compile command line to depend on MOZ_DEBUG_SYMBOLS and MOZ_DEBUG. r=gps
authorChris Manchester <cmanchester@mozilla.com>
Fri, 27 Oct 2017 09:39:44 -0700
changeset 389062 3db37adcebadc88984a15aa0770acbe79bf8fa5a
parent 389061 7130acf44fbc7f636b68aebef78c731eabf5a084
child 389063 a7237ae63929a90ccfbb11cc5bb625710a2eec9b
push id32777
push userarchaeopteryx@coole-files.de
push dateMon, 30 Oct 2017 22:44:45 +0000
treeherdermozilla-central@dd0f265a1300 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1412267
milestone58.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 1412267 - Fix the inclusion of MOZ_DEBUG_FLAGS in the compile command line to depend on MOZ_DEBUG_SYMBOLS and MOZ_DEBUG. r=gps MozReview-Commit-ID: 4MgzRQCX5iW
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/test/frontend/test_emitter.py
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -330,18 +330,17 @@ class CompileFlags(ContextDerivedValue, 
             ('OS_COMPILE_CXXFLAGS', context.config.substs.get('OS_COMPILE_CXXFLAGS'),
              ('CXXFLAGS',)),
             ('OS_CPPFLAGS', context.config.substs.get('OS_CPPFLAGS'),
              ('CXXFLAGS', 'CFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
             ('OS_CFLAGS', context.config.substs.get('OS_CFLAGS'),
              ('CFLAGS', 'C_LDFLAGS')),
             ('OS_CXXFLAGS', context.config.substs.get('OS_CXXFLAGS'),
              ('CXXFLAGS', 'CXX_LDFLAGS')),
-            ('DEBUG', (context.config.substs['MOZ_DEBUG_FLAGS'].split() if
-                       'MOZ_DEBUG_FLAGS' in context.config.substs else []),
+            ('DEBUG', self._debug_flags(),
              ('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
             ('CLANG_PLUGIN', context.config.substs.get('CLANG_PLUGIN_FLAGS'),
              ('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
             ('OPTIMIZE', self._optimize_flags(),
              ('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
             ('FRAMEPTR', context.config.substs.get('MOZ_FRAMEPTR_FLAGS'),
              ('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
             ('WARNINGS_AS_ERRORS', self._warnings_as_errors(),
@@ -355,16 +354,22 @@ class CompileFlags(ContextDerivedValue, 
         # a template were set and which were provided as defaults.
         template_name = getattr(context, 'template', None)
         if template_name in (None, 'Gyp'):
             dict.__init__(self, ((k, v if v is None else TypedList(unicode)(v))
                                  for k, v, _ in self.flag_variables))
         else:
             dict.__init__(self)
 
+    def _debug_flags(self):
+        if (self._context.config.substs.get('MOZ_DEBUG') or
+            self._context.config.substs.get('MOZ_DEBUG_SYMBOLS')):
+            return self._context.config.substs.get('MOZ_DEBUG_FLAGS', '').split()
+        return []
+
     def _warnings_as_errors(self):
         warnings_as_errors = self._context.config.substs.get('WARNINGS_AS_ERRORS')
         if self._context.config.substs.get('MOZ_PGO'):
             # Don't use warnings-as-errors in Windows PGO builds because it is suspected of
             # causing problems in that situation. (See bug 437002.)
             if self._context.config.substs['OS_ARCH'] == 'WINNT':
                 warnings_as_errors = None
 
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -209,16 +209,34 @@ class TestEmitterBasic(unittest.TestCase
             'WARNINGS_AS_ERRORS': '-Werror',
         })
         sources, lib, flags = self.read_topsrcdir(reader)
         self.assertIsInstance(flags, ComputedFlags)
         self.assertEqual(flags.flags['STL'], reader.config.substs['STL_FLAGS'])
         self.assertEqual(flags.flags['VISIBILITY'], reader.config.substs['VISIBILITY_FLAGS'])
         self.assertEqual(flags.flags['WARNINGS_AS_ERRORS'], ['-Werror'])
 
+    def test_debug_flags(self):
+        reader = self.reader('compile-flags', extra_substs={
+            'MOZ_DEBUG_FLAGS': '-g',
+            'MOZ_DEBUG_SYMBOLS': '1',
+        })
+        sources, lib, flags = self.read_topsrcdir(reader)
+        self.assertIsInstance(flags, ComputedFlags)
+        self.assertEqual(flags.flags['DEBUG'], ['-g'])
+
+    def test_disable_debug_flags(self):
+        reader = self.reader('compile-flags', extra_substs={
+            'MOZ_DEBUG_FLAGS': '-g',
+            'MOZ_DEBUG_SYMBOLS': '',
+        })
+        sources, lib, flags = self.read_topsrcdir(reader)
+        self.assertIsInstance(flags, ComputedFlags)
+        self.assertEqual(flags.flags['DEBUG'], [])
+
     def test_compile_flags_validation(self):
         reader = self.reader('compile-flags-field-validation')
 
         with self.assertRaisesRegexp(BuildReaderError, 'Invalid value.'):
             self.read_topsrcdir(reader)
 
         reader = self.reader('compile-flags-type-validation')
         with self.assertRaisesRegexp(BuildReaderError,