diff options
author | Octavian Soldea <octavian.soldea@intel.com> | 2018-07-05 11:19:22 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-07-13 19:03:00 +0200 |
commit | 32cad739b12c3f1b24dff9a24e8321927e9b2eb2 (patch) | |
tree | f44f1e2ad97a4ae1e2f769ffcf4002b46ddb3756 /configure | |
parent | 4d42083d1a2a5632589e79aa3b780a7d7c93a2e1 (diff) | |
download | node-new-32cad739b12c3f1b24dff9a24e8321927e9b2eb2.tar.gz |
build: enabling lto at configure
This modification allows for compiling with link time optimization (lto)
using the flag --enable-lto.
Refs: https://github.com/nodejs/node/issues/7400
PR-URL: https://github.com/nodejs/node/pull/21677
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -157,6 +157,11 @@ parser.add_option("--enable-vtune-profiling", "JavaScript code executed in nodejs. This feature is only available " "for x32, x86, and x64 architectures.") +parser.add_option("--enable-lto", + action="store_true", + dest="enable_lto", + help="Enable compiling with lto of a binary. This feature is only available " + "on linux with gcc and g++.") parser.add_option("--link-module", action="append", @@ -932,6 +937,25 @@ def configure_node(o): else: o['variables']['node_enable_v8_vtunejit'] = 'false' + if flavor != 'linux' and (options.enable_lto): + raise Exception( + 'The lto option is supported only on linux.') + + if flavor == 'linux': + if options.enable_lto: + version_checked = (5, 4, 1) + for compiler in [(CC, 'c'), (CXX, 'c++')]: + ok, is_clang, clang_version, compiler_version = \ + try_check_compiler(compiler[0], compiler[1]) + compiler_version_num = tuple(map(int, compiler_version)) + if is_clang or compiler_version_num < version_checked: + version_checked_str = ".".join(map(str, version_checked)) + raise Exception( + 'The option --enable-lto is supported for gcc and gxx %s' + ' or newer only.' % (version_checked_str)) + + o['variables']['enable_lto'] = b(options.enable_lto) + if flavor in ('solaris', 'mac', 'linux', 'freebsd'): use_dtrace = not options.without_dtrace # Don't enable by default on linux and freebsd |