Skip to content

Commit

Permalink
build: introduce ./configure --with-lto
Browse files Browse the repository at this point in the history
Introduce `--with-lto` configure option to use Link Time Optimization
compiler pass in gcc/clang compilers.

This flag slightly improves performance of C/C++ heavy code:

    tls/throughput.js dur="5" type="buf" size="2": ./out/Release/node-flto: 6.1295 ./out/Release/node: 5.6876 ....... 7.77%
    tls/throughput.js dur="5" type="buf" size="1024": ./out/Release/node-flto: 1567 ./out/Release/node: 1455 ........ 7.70%
    tls/throughput.js dur="5" type="buf" size="1048576": ./out/Release/node-flto: 4167.8 ./out/Release/node: 4026.7 . 3.50%
    tls/throughput.js dur="5" type="asc" size="2": ./out/Release/node-flto: 5.5664 ./out/Release/node: 5.0363 ...... 10.52%
    tls/throughput.js dur="5" type="asc" size="1024": ./out/Release/node-flto: 1462.2 ./out/Release/node: 1336.8 .... 9.38%
    tls/throughput.js dur="5" type="asc" size="1048576": ./out/Release/node-flto: 3947.5 ./out/Release/node: 3847.4 . 2.60%
    tls/throughput.js dur="5" type="utf" size="2": ./out/Release/node-flto: 5.5544 ./out/Release/node: 5.0786 ....... 9.37%
    tls/throughput.js dur="5" type="utf" size="1024": ./out/Release/node-flto: 1328.5 ./out/Release/node: 1255.7 .... 5.80%
    tls/throughput.js dur="5" type="utf" size="1048576": ./out/Release/node-flto: 3051.1 ./out/Release/node: 2985.1 . 2.21%

Fixes: nodejs#7400
  • Loading branch information
indutny authored and addaleax committed Feb 3, 2017
1 parent 4e259b2 commit d6b510c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'node_module_version%': '',

'node_tag%': '',
'node_use_lto%': '',
'uv_library%': 'static_library',

'openssl_fips%': '',
Expand Down Expand Up @@ -333,6 +334,13 @@
[ 'node_shared=="true"', {
'cflags': [ '-fPIC' ],
}],
['node_use_lto=="true"', {
'conditions': [ [ 'clang==1', {
'cflags': [ '-flto' ],
}, {
'cflags': [ '-flto=16' ],
} ] ],
}],
],
}],
['OS=="android"', {
Expand Down Expand Up @@ -391,6 +399,13 @@
'CLANG_CXX_LIBRARY': 'libc++',
},
}],
['node_use_lto=="true"', {
'xcode_settings': {
'OTHER_CFLAGS': [
'-flto',
],
},
}],
],
}],
['OS=="freebsd" and node_use_dtrace=="true"', {
Expand Down
7 changes: 7 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ parser.add_option('--with-lttng',
dest='with_lttng',
help='build with Lttng (Only available to Linux)')

parser.add_option('--with-lto',
action='store_true',
dest='use_lto',
help='build with -flto flag (Link Time Optimization)')

parser.add_option('--with-etw',
action='store_true',
dest='with_etw',
Expand Down Expand Up @@ -838,6 +843,8 @@ def configure_node(o):
else:
o['variables']['node_use_lttng'] = 'false'

o['variables']['node_use_lto'] = b(options.use_lto)

if options.no_ifaddrs:
o['defines'] += ['SUNOS_NO_IFADDRS']

Expand Down

0 comments on commit d6b510c

Please sign in to comment.