diff options
author | Job Bautista <jobbautista9@aol.com> | 2023-04-22 10:39:55 +0800 |
---|---|---|
committer | Job Bautista <jobbautista9@aol.com> | 2023-04-30 21:10:44 +0800 |
commit | 42e0b5db07314ff752e5dbe7cde8d3125a26f2d0 (patch) | |
tree | 610d19d0b9817dc7c5c9e3c6d053fdf31961fcc9 | |
parent | 4d4d8cfc9f73d48208afcfde9216fcddf9aecec3 (diff) | |
download | uxp-42e0b5db07314ff752e5dbe7cde8d3125a26f2d0.tar.gz |
Issue #2221 - Enable link-time optimization for Spidermonkey by default if building it shared.
Currently only Windows can take advantage of this.
The reason why the arrays of deunified sources are named like that in
Spidermonkey's moz.build is to avoid UnsortedErrors in python. There's probably
a better way to handle that, but I just want something that works for now.
And yes, the deunified sources will be reunified if LTO is disabled.
-rw-r--r-- | build/moz.configure/old.configure | 1 | ||||
-rw-r--r-- | config/external/ffi/moz.build | 6 | ||||
-rw-r--r-- | js/src/moz.build | 65 | ||||
-rw-r--r-- | js/src/old-configure.in | 20 | ||||
-rw-r--r-- | modules/fdlibm/src/moz.build | 6 | ||||
-rw-r--r-- | old-configure.in | 20 |
6 files changed, 97 insertions, 21 deletions
diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure index 64e91e1f31..40cc9e89fc 100644 --- a/build/moz.configure/old.configure +++ b/build/moz.configure/old.configure @@ -196,6 +196,7 @@ def old_configure_options(*options): '--enable-ion', '--enable-ios-target', '--enable-jitspew', + '--enable-js-lto', '--enable-libjpeg-turbo', '--enable-libproxy', '--enable-llvm-hacks', diff --git a/config/external/ffi/moz.build b/config/external/ffi/moz.build index 168f28c0bf..8710ebab7a 100644 --- a/config/external/ffi/moz.build +++ b/config/external/ffi/moz.build @@ -128,3 +128,9 @@ else: '/js/src/ctypes/libffi/src/%s/%s' % (CONFIG['FFI_TARGET_DIR'], s) for s in sorted(ffi_srcs) ] + + # Explicitly enable WPO and LTCG in MSVC if we're doing LTO. + if CONFIG['JS_LTO']: + if CONFIG['_MSC_VER'] and not CONFIG['CLANG_CL']: + CFLAGS += [ '-GL' ] + CXXFLAGS += [ '-GL' ] diff --git a/js/src/moz.build b/js/src/moz.build index 115747daaf..3553dc9bf1 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -7,8 +7,6 @@ include('js-config.mozbuild') include('js-cxxflags.mozbuild') include('js-testing.mozbuild') -FILES_PER_UNIFIED_FILE = 6 - if CONFIG['JS_BUNDLED_EDITLINE']: DIRS += ['editline'] @@ -111,7 +109,7 @@ EXPORTS.js += [ '../public/WeakMapPtr.h', ] -UNIFIED_SOURCES += [ +main_deunified_sources = [ 'builtin/AtomicsObject.cpp', 'builtin/Eval.cpp', 'builtin/intl/Collator.cpp', @@ -388,7 +386,7 @@ SOURCES += [ ] if CONFIG['JS_POSIX_NSPR']: - UNIFIED_SOURCES += [ + posix_nspr_deunified_sources = [ 'vm/PosixNSPR.cpp', ] @@ -405,26 +403,24 @@ if CONFIG['ENABLE_TRACE_LOGGING']: ] if not CONFIG['ENABLE_ION']: - UNIFIED_SOURCES += [ + jit_ioncheck1_deunified_sources = [ 'jit/none/Trampoline-none.cpp' ] elif CONFIG['JS_CODEGEN_X86'] or CONFIG['JS_CODEGEN_X64']: - UNIFIED_SOURCES += [ + jit_ioncheck1_deunified_sources = [ 'jit/x86-shared/Architecture-x86-shared.cpp', 'jit/x86-shared/Assembler-x86-shared.cpp', 'jit/x86-shared/AssemblerBuffer-x86-shared.cpp', 'jit/x86-shared/BaselineCompiler-x86-shared.cpp', 'jit/x86-shared/BaselineIC-x86-shared.cpp', 'jit/x86-shared/CodeGenerator-x86-shared.cpp', + 'jit/x86-shared/Disassembler-x86-shared.cpp', # using namespace js::jit::X86Encoding; 'jit/x86-shared/Lowering-x86-shared.cpp', 'jit/x86-shared/MacroAssembler-x86-shared.cpp', 'jit/x86-shared/MoveEmitter-x86-shared.cpp', ] - UNIFIED_SOURCES += [ - 'jit/x86-shared/Disassembler-x86-shared.cpp', # using namespace js::jit::X86Encoding; - ] if CONFIG['JS_CODEGEN_X64']: - UNIFIED_SOURCES += [ + jit_ioncheck2_deunified_sources = [ 'jit/x64/Assembler-x64.cpp', 'jit/x64/Bailouts-x64.cpp', 'jit/x64/BaselineCompiler-x64.cpp', @@ -436,7 +432,7 @@ elif CONFIG['JS_CODEGEN_X86'] or CONFIG['JS_CODEGEN_X64']: 'jit/x64/Trampoline-x64.cpp', ] else: - UNIFIED_SOURCES += [ + jit_ioncheck2_deunified_sources = [ 'jit/x86/Assembler-x86.cpp', 'jit/x86/Bailouts-x86.cpp', 'jit/x86/BaselineCompiler-x86.cpp', @@ -448,7 +444,7 @@ elif CONFIG['JS_CODEGEN_X86'] or CONFIG['JS_CODEGEN_X64']: 'jit/x86/Trampoline-x86.cpp', ] elif CONFIG['JS_CODEGEN_ARM']: - UNIFIED_SOURCES += [ + jit_ioncheck1_deunified_sources = [ 'jit/arm/Architecture-arm.cpp', 'jit/arm/Assembler-arm.cpp', 'jit/arm/Bailouts-arm.cpp', @@ -464,16 +460,16 @@ elif CONFIG['JS_CODEGEN_ARM']: 'jit/arm/Trampoline-arm.cpp', ] if CONFIG['JS_SIMULATOR_ARM']: - UNIFIED_SOURCES += [ + jit_ioncheck2_deunified_sources = [ 'jit/arm/Simulator-arm.cpp' ] elif CONFIG['OS_ARCH'] == 'Darwin': - UNIFIED_SOURCES += [ + jit_ioncheck2_deunified_sources = [ 'jit/arm/llvm-compiler-rt/arm/aeabi_idivmod.S', 'jit/arm/llvm-compiler-rt/arm/aeabi_uidivmod.S', ] elif CONFIG['JS_CODEGEN_ARM64']: - UNIFIED_SOURCES += [ + jit_ioncheck1_deunified_sources = [ 'jit/arm64/Architecture-arm64.cpp', 'jit/arm64/Assembler-arm64.cpp', 'jit/arm64/Bailouts-arm64.cpp', @@ -496,14 +492,14 @@ elif CONFIG['JS_CODEGEN_ARM64']: 'jit/arm64/vixl/Utils-vixl.cpp' ] if CONFIG['JS_SIMULATOR_ARM64']: - UNIFIED_SOURCES += [ + jit_ioncheck2_deunified_sources = [ 'jit/arm64/vixl/Debugger-vixl.cpp', 'jit/arm64/vixl/Logic-vixl.cpp', 'jit/arm64/vixl/MozSimulator-vixl.cpp', 'jit/arm64/vixl/Simulator-vixl.cpp' ] elif CONFIG['JS_CODEGEN_MIPS32'] or CONFIG['JS_CODEGEN_MIPS64']: - UNIFIED_SOURCES += [ + jit_ioncheck1_deunified_sources = [ 'jit/mips-shared/Architecture-mips-shared.cpp', 'jit/mips-shared/Assembler-mips-shared.cpp', 'jit/mips-shared/Bailouts-mips-shared.cpp', @@ -515,7 +511,7 @@ elif CONFIG['JS_CODEGEN_MIPS32'] or CONFIG['JS_CODEGEN_MIPS64']: 'jit/mips-shared/MoveEmitter-mips-shared.cpp', ] if CONFIG['JS_CODEGEN_MIPS32']: - UNIFIED_SOURCES += [ + jit_ioncheck2_deunified_sources = [ 'jit/mips32/Architecture-mips32.cpp', 'jit/mips32/Assembler-mips32.cpp', 'jit/mips32/Bailouts-mips32.cpp', @@ -529,11 +525,11 @@ elif CONFIG['JS_CODEGEN_MIPS32'] or CONFIG['JS_CODEGEN_MIPS64']: 'jit/mips32/Trampoline-mips32.cpp', ] if CONFIG['JS_SIMULATOR_MIPS32']: - UNIFIED_SOURCES += [ + jit_ioncheck3_deunified_sources = [ 'jit/mips32/Simulator-mips32.cpp' ] elif CONFIG['JS_CODEGEN_MIPS64']: - UNIFIED_SOURCES += [ + jit_ioncheck2_deunified_sources = [ 'jit/mips64/Architecture-mips64.cpp', 'jit/mips64/Assembler-mips64.cpp', 'jit/mips64/Bailouts-mips64.cpp', @@ -547,7 +543,7 @@ elif CONFIG['JS_CODEGEN_MIPS32'] or CONFIG['JS_CODEGEN_MIPS64']: 'jit/mips64/Trampoline-mips64.cpp', ] if CONFIG['JS_SIMULATOR_MIPS64']: - UNIFIED_SOURCES += [ + jit_ioncheck3_deunified_sources = [ 'jit/mips64/Simulator-mips64.cpp' ] @@ -627,6 +623,33 @@ else: 'icuuc', ] +# Explicitly enable WPO and LTCG in MSVC, and deunify sources if +# we're doing LTO +if CONFIG['JS_LTO']: + if CONFIG['_MSC_VER'] and not CONFIG['CLANG_CL']: + CFLAGS += [ '-GL' ] + CXXFLAGS += [ '-GL' ] + if CONFIG['JS_SHARED_LIBRARY']: + LDFLAGS += [ '/LTCG' ] + SOURCES += main_deunified_sources + if CONFIG['JS_POSIX_NSPR']: + SOURCES += posix_nspr_deunified_sources + SOURCES += jit_ioncheck1_deunified_sources + if CONFIG['ENABLE_ION']: + SOURCES += jit_ioncheck2_deunified_sources + if CONFIG['JS_CODEGEN_MIPS32'] or CONFIG['JS_CODEGEN_MIPS64']: + SOURCES += jit_ioncheck3_deunified_sources +else: + FILES_PER_UNIFIED_FILE = 6 + UNIFIED_SOURCES += main_deunified_sources + if CONFIG['JS_POSIX_NSPR']: + UNIFIED_SOURCES += posix_nspr_deunified_sources + UNIFIED_SOURCES += jit_ioncheck1_deunified_sources + if CONFIG['ENABLE_ION']: + UNIFIED_SOURCES += jit_ioncheck2_deunified_sources + if CONFIG['JS_CODEGEN_MIPS32'] or CONFIG['JS_CODEGEN_MIPS64']: + UNIFIED_SOURCES += jit_ioncheck3_deunified_sources + USE_LIBS += [ 'nspr', 'zlib', diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 469ea3d272..62a01a9e3b 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -580,6 +580,26 @@ esac MOZ_DOING_LTO(lto_is_enabled) dnl ======================================================== +dnl Spidermonkey link-time optimization support +dnl ======================================================== + +# We want LTO enabled by default in Spidermonkey if we're building it shared. +if test -n "$JS_SHARED_LIBRARY"; then + JS_LTO=1 +fi + +MOZ_ARG_DISABLE_BOOL(js-lto, +[ --disable-js-lto Disable link-time optimization for the Spidermonkey library], + JS_LTO=, + JS_LTO=1) + +if test -n "$JS_LTO"; then + AC_DEFINE(JS_LTO) +fi + +AC_SUBST(JS_LTO) + +dnl ======================================================== dnl System overrides of the defaults for target dnl ======================================================== diff --git a/modules/fdlibm/src/moz.build b/modules/fdlibm/src/moz.build index 541f840399..d1feeb62f9 100644 --- a/modules/fdlibm/src/moz.build +++ b/modules/fdlibm/src/moz.build @@ -38,6 +38,12 @@ if CONFIG['CC_TYPE'] == 'clang-cl': '-Wno-sign-compare', # signed/unsigned mismatch ] +# Explicitly enable WPO and LTCG in MSVC if we're doing LTO. +if CONFIG['JS_LTO']: + if CONFIG['_MSC_VER'] and not CONFIG['CLANG_CL']: + CFLAGS += [ '-GL' ] + CXXFLAGS += [ '-GL' ] + SOURCES += [ 'e_acos.cpp', 'e_acosh.cpp', diff --git a/old-configure.in b/old-configure.in index 6c5768fcde..e2da8b8f6c 100644 --- a/old-configure.in +++ b/old-configure.in @@ -729,6 +729,26 @@ AC_SUBST(MOZILLA_UAVERSION_U) MOZ_DOING_LTO(lto_is_enabled) dnl ======================================================== +dnl Spidermonkey link-time optimization support +dnl ======================================================== + +# We want LTO enabled by default in Spidermonkey if we're building it shared. +if test -n "$JS_SHARED_LIBRARY"; then + JS_LTO=1 +fi + +MOZ_ARG_DISABLE_BOOL(js-lto, +[ --disable-js-lto Disable link-time optimization for the Spidermonkey library], + JS_LTO=, + JS_LTO=1) + +if test -n "$JS_LTO"; then + AC_DEFINE(JS_LTO) +fi + +AC_SUBST(JS_LTO) + +dnl ======================================================== dnl System overrides of the defaults for target dnl ======================================================== |