GeezerVison is showing github.com — build: enabling lto at configure · nodejs/node@c02fb88
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: common.gypi +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 176 | 176 | ['OS!="mac" and OS!="win"', { | 177 | 177 | 'cflags': [ '-fno-omit-frame-pointer' ], | 178 | 178 | }], | | 179 | + ['OS=="linux"', { | | 180 | + 'variables': { | | 181 | + 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', | | 182 | + }, | | 183 | + 'conditions': [ | | 184 | + ['enable_lto=="true"', { | | 185 | + 'cflags': ['<(lto)'], | | 186 | + 'ldflags': ['<(lto)'], | | 187 | + },], | | 188 | + ], | | 189 | + },], | 179 | 190 | ['OS == "android"', { | 180 | 191 | 'cflags': [ '-fPIE' ], | 181 | 192 | 'ldflags': [ '-fPIE', '-pie' ] | |
Collapse file Copy file name to clipboardExpand all lines: configure +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -157,6 +157,11 @@ parser.add_option("--enable-vtune-profiling", | 157 | 157 | "JavaScript code executed in nodejs. This feature is only available " | 158 | 158 | "for x32, x86, and x64 architectures.") | 159 | 159 |
| | 160 | +parser.add_option("--enable-lto", | | 161 | + action="store_true", | | 162 | + dest="enable_lto", | | 163 | + help="Enable compiling with lto of a binary. This feature is only available " | | 164 | + "on linux with gcc and g++.") | 160 | 165 |
| 161 | 166 | parser.add_option("--link-module", | 162 | 167 | action="append", | @@ -932,6 +937,25 @@ def configure_node(o): | 932 | 937 | else: | 933 | 938 | o['variables']['node_enable_v8_vtunejit'] = 'false' | 934 | 939 |
| | 940 | + if flavor != 'linux' and (options.enable_lto): | | 941 | + raise Exception( | | 942 | + 'The lto option is supported only on linux.') | | 943 | + | | 944 | + if flavor == 'linux': | | 945 | + if options.enable_lto: | | 946 | + version_checked = (5, 4, 1) | | 947 | + for compiler in [(CC, 'c'), (CXX, 'c++')]: | | 948 | + ok, is_clang, clang_version, compiler_version = \ | | 949 | + try_check_compiler(compiler[0], compiler[1]) | | 950 | + compiler_version_num = tuple(map(int, compiler_version)) | | 951 | + if is_clang or compiler_version_num < version_checked: | | 952 | + version_checked_str = ".".join(map(str, version_checked)) | | 953 | + raise Exception( | | 954 | + 'The option --enable-lto is supported for gcc and gxx %s' | | 955 | + ' or newer only.' % (version_checked_str)) | | 956 | + | | 957 | + o['variables']['enable_lto'] = b(options.enable_lto) | | 958 | + | 935 | 959 | if flavor in ('solaris', 'mac', 'linux', 'freebsd'): | 936 | 960 | use_dtrace = not options.without_dtrace | 937 | 961 | # Don't enable by default on linux and freebsd | |
|