Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
build: adding LTO support to configure script
Browse files Browse the repository at this point in the history
There is now a --chakracore-lto-build flag which will attempt to
build node-chakracore using link time optimisations. This is not
guaranteed to work without providing the correct build environment,
which includes using compatible versions of `ar`, `ranlib`, and `ld`.

PR-URL: #341
Reviewed-By: Kyle Farnung <[email protected]>
  • Loading branch information
MSLaguana authored and kfarnung committed Jul 19, 2017
1 parent eb638cc commit 6c4e305
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions deps/chakrashim/chakracore.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
'--without=Simdjs',
'--static',
'<@(chakracore_parallel_build_flags)',
'<@(chakracore_lto_build_flags)',
'<@(chakra_build_flags)',
'<@(icu_args)',
'--libs-only'
Expand Down
16 changes: 15 additions & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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': [
Expand Down

0 comments on commit 6c4e305

Please sign in to comment.