# HG changeset patch # User David Major # Date 1531758396 14400 # Node ID a2ae515ee43f5561ab77875d21738a8c8d53999e # Parent 444db96136e5c76738fbae53a1ec4ac3b985d886 Bug 1448980: Make --enable-lto work with clang-cl. r=froydnj diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -1570,37 +1570,45 @@ js_option('--enable-lto', help='Enable LTO') @depends('--enable-lto', c_compiler) @imports('multiprocessing') def lto(value, c_compiler): cflags = [] ldflags = [] - - # clang and clang-cl - if c_compiler.type in ('clang', 'clang-cl'): - if len(value) and value[0].lower() == 'full': + enabled = None + + if value: + enabled = True + 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': + if len(value) and value[0].lower() == 'full': + cflags.append("-flto") + else: + cflags.append("-flto=thin") + # With clang-cl, -flto can only be used with -c or -fuse-ld=lld. + # AC_TRY_LINKs during configure don't have -c, so pass -fuse-ld=lld. + cflags.append("-fuse-ld=lld"); + else: + num_cores = multiprocessing.cpu_count() cflags.append("-flto") - ldflags.append("-flto") - elif value: - cflags.append("-flto=thin") - ldflags.append("-flto=thin") - - # gcc and other compilers - elif value: - num_cores = multiprocessing.cpu_count() - cflags.append("-flto") - cflags.append("-flifetime-dse=1") - - ldflags.append("-flto=%s" % num_cores) - ldflags.append("-flifetime-dse=1") + cflags.append("-flifetime-dse=1") + + ldflags.append("-flto=%s" % num_cores) + ldflags.append("-flifetime-dse=1") return namespace( - enabled="1" if value else None, + enabled=enabled, cflags=cflags, ldflags=ldflags ) add_old_configure_assignment('MOZ_LTO', lto.enabled) set_config('MOZ_LTO', lto.enabled) set_define('MOZ_LTO', lto.enabled)