Bug 1605537 - override optimization settings for wasm compilation; r=firefox-build-system-reviewers,rstewart
authorNathan Froyd <froydnj@mozilla.com>
Mon, 23 Dec 2019 16:49:32 +0000
changeset 508307 d971af5f00b7a8d01eb5b93ca463af8c81287f7c
parent 508306 aa8ef4f721768ae09143dc6cfb932f1f67c6476e
child 508308 4aadedbaab27fc047157d7f71697383dbeffa5f6
push id103885
push usernfroyd@mozilla.com
push dateMon, 23 Dec 2019 18:33:44 +0000
treeherderautoland@4aadedbaab27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, rstewart
bugs1605537
milestone73.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 1605537 - override optimization settings for wasm compilation; r=firefox-build-system-reviewers,rstewart The optimization flags that may have been chosen for our target compiler are not necessarily appropriate for our wasm compiler. Differential Revision: https://phabricator.services.mozilla.com/D58070
python/mozbuild/mozbuild/frontend/context.py
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -606,16 +606,26 @@ class WasmFlags(TargetCompileFlags):
              ('WASM_LDFLAGS',)),
             ('WASM_DEFINES', None, ('WASM_CFLAGS', 'WASM_CXXFLAGS')),
             ('MOZBUILD_WASM_CFLAGS', None, ('WASM_CFLAGS',)),
             ('MOZBUILD_WASM_CXXFLAGS', None, ('WASM_CXXFLAGS',)),
         )
 
         TargetCompileFlags.__init__(self, context)
 
+    def _optimize_flags(self):
+        if not self._context.config.substs.get('MOZ_OPTIMIZE'):
+            return []
+
+        # We don't want `MOZ_{PGO_,}OPTIMIZE_FLAGS here because they may contain
+        # optimization flags that aren't suitable for wasm (e.g. -freorder-blocks).
+        # Just optimize for size in all cases; we may want to make this
+        # configurable.
+        return ['-Os']
+
 
 class FinalTargetValue(ContextDerivedValue, six.text_type):
     def __new__(cls, context, value=""):
         if not value:
             value = 'dist/'
             if context['XPI_NAME']:
                 value += 'xpi-stage/' + context['XPI_NAME']
             else: