diff --git a/configure b/configure index 0e0e5135369..b3fab328cb6 100755 --- a/configure +++ b/configure @@ -487,6 +487,13 @@ parser.add_option('--chakracore-ninja-build', default=False, help='Enable build of ChakraCore using ninja (requires engine to be ChakraCore)') +parser.add_option('--chakracore-lto-build', + action='store_true', + dest='chakracore_lto_build', + default=False, + help='Enable build of ChakraCore using LTO (requires engine to be ChakraCore)') + + parser.add_option('--shared', action='store_true', dest='shared', @@ -1340,6 +1347,13 @@ def configure_engine(o): o['variables']['chakracore_parallel_build_flags'] = [ "--ninja" ] else: o['variables']['chakracore_parallel_build_flags'] = [] + if options.chakracore_lto_build: + o['variables']['chakracore_use_lto'] = "true" + o['variables']['chakracore_lto_build_flags'] = [ "--lto" ] + else: + o['variables']['chakracore_use_lto'] = "false" + o['variables']['chakracore_lto_build_flags'] = [ ] + output = { diff --git a/deps/chakrashim/chakracore.gyp b/deps/chakrashim/chakracore.gyp index a684a941c15..3c59e66918c 100644 --- a/deps/chakrashim/chakracore.gyp +++ b/deps/chakrashim/chakracore.gyp @@ -122,6 +122,7 @@ '--without=Simdjs', '--static', '<@(chakracore_parallel_build_flags)', + '<@(chakracore_lto_build_flags)', '<@(chakra_build_flags)', '<@(icu_args)', '--libs-only' diff --git a/node.gyp b/node.gyp index f9add198bc3..f0bd5bd0ced 100644 --- a/node.gyp +++ b/node.gyp @@ -271,6 +271,13 @@ 'sources': [ 'src/node_api_jsrt.cc', ], + 'conditions': [ + [ 'OS!="win" and chakracore_use_lto=="true"', { + 'ldflags': [ + '-flto', + ], + }], + ], }, { 'sources': [ 'src/node_api.cc', @@ -698,7 +705,14 @@ ], 'sources!': [ 'test/cctest/test_environment.cc', # TODO: Enable these test for node-chakracore - ] + ], + 'conditions': [ + [ 'OS!="win" and chakracore_use_lto=="true"', { + 'ldflags': [ + '-flto', + ], + }], + ], }], ['v8_enable_inspector==1', { 'sources': [