@@ -157,6 +157,11 @@ parser.add_option("--enable-vtune-profiling",
157157 " JavaScript code executed in nodejs. This feature is only available "
158158 " for x32, x86, and x64 architectures." )
159159
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++." )
160165
161166parser.add_option(" --link-module" ,
162167 action=" append" ,
@@ -932,6 +937,23 @@ def configure_node(o):
932937 else:
933938 o[' variables' ][' node_enable_v8_vtunejit' ] = ' false'
934939
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+ if is_clang or compiler_version < version_checked:
951+ raise Exception(
952+ ' The option --enable-lto is supported for '
953+ ' gcc and gxx 5.4.1 or newer only.' )
954+
955+ o[' variables' ][' enable_lto' ] = b(options.enable_lto)
956+
935957 if flavor in (' solaris' , ' mac' , ' linux' , ' freebsd' ):
936958 use_dtrace = not options.without_dtrace
937959 # Don't enable by default on linux and freebsd
0 commit comments