Bug 1546438 - add a `cross` option to `MOZ_LTO` for cross-language LTO; r=mshal
authorNathan Froyd <froydnj@mozilla.com>
Fri, 10 May 2019 20:16:36 +0000
changeset 532278 dac8d01ef94e4c5948f73a3f49a15f8125c88c7d
parent 532277 2a59e1221617628b0399e2d51d5e3442a63be51b
child 532279 d41f800069310e11f51add4796f3443100e3cb50
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1546438
milestone68.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 1546438 - add a `cross` option to `MOZ_LTO` for cross-language LTO; r=mshal This option is for performing LTO between C++ code and Rust code. The actual build pieces for Rust code are coming in the next patch. Differential Revision: https://phabricator.services.mozilla.com/D28508
build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1491,33 +1491,43 @@ option('--with-pgo-jarlog',
 set_config('PGO_JARLOG_PATH', depends_if('--with-pgo-jarlog')(lambda p: p))
 
 # LTO
 # ==============================================================
 
 js_option('--enable-lto',
           env='MOZ_LTO',
           nargs='?',
-          choices=('full', 'thin'),
+          choices=('full', 'thin', 'cross'),
           help='Enable LTO')
 
 
 @depends('--enable-lto', 'MOZ_PGO', c_compiler)
 @imports('multiprocessing')
 def lto(value, pgo, c_compiler):
     cflags = []
     ldflags = []
     enabled = None
+    rust_lto = False
 
     # MSVC's implementation of PGO implies LTO. Make clang-cl match this.
     if c_compiler.type == 'clang-cl' and pgo and value.origin == 'default':
         value = ['thin']
 
     if value:
         enabled = True
+        # `cross` implies `thin`, but with Rust code participating in LTO
+        # as well.  Make that a little more explicit.
+        if len(value) and value[0].lower() == 'cross':
+            if c_compiler.type == 'gcc':
+                die('Cross-language LTO is not supported with GCC.')
+
+            rust_lto = True
+            value = ['thin']
+
         if c_compiler.type == 'clang':
             if len(value) and value[0].lower() == 'full':
                 cflags.append("-flto")
                 ldflags.append("-flto")
             else:
                 cflags.append("-flto=thin")
                 ldflags.append("-flto=thin")
         elif c_compiler.type == 'clang-cl':
@@ -1534,25 +1544,27 @@ def lto(value, pgo, c_compiler):
             cflags.append("-flifetime-dse=1")
 
             ldflags.append("-flto=%s" % num_cores)
             ldflags.append("-flifetime-dse=1")
 
     return namespace(
         enabled=enabled,
         cflags=cflags,
-        ldflags=ldflags
+        ldflags=ldflags,
+        rust_lto=rust_lto,
     )
 
 
 add_old_configure_assignment('MOZ_LTO', lto.enabled)
 set_config('MOZ_LTO', lto.enabled)
 set_define('MOZ_LTO', lto.enabled)
 set_config('MOZ_LTO_CFLAGS', lto.cflags)
 set_config('MOZ_LTO_LDFLAGS', lto.ldflags)
+set_config('MOZ_LTO_RUST', lto.rust_lto)
 add_old_configure_assignment('MOZ_LTO_CFLAGS', lto.cflags)
 add_old_configure_assignment('MOZ_LTO_LDFLAGS', lto.ldflags)
 
 # ASAN
 # ==============================================================
 
 js_option('--enable-address-sanitizer', help='Enable Address Sanitizer')