| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 58154ce commit a6f8ba8
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,17 +164,28 @@ | |||
| 164 | 164 | 'v8_enable_handle_zapping': 0, | |
| 165 | 165 | 'pgo_generate': ' -fprofile-generate ', | |
| 166 | 166 | 'pgo_use': ' -fprofile-use -fprofile-correction ', | |
| 167 | - 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', | ||
| 168 | 167 | 'conditions': [ | |
| 169 | 168 | ['node_shared != "true"', { | |
| 170 | 169 | 'MSVC_runtimeType': 0 # MultiThreaded (/MT) | |
| 171 | 170 | }, { | |
| 172 | 171 | 'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD) | |
| 173 | 172 | }], | |
| 173 | + ['llvm_version=="0.0"', { | ||
| 174 | + 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC | ||
| 175 | + }, { | ||
| 176 | + 'lto': ' -flto ', # Clang | ||
| 177 | + }], | ||
| 174 | 178 | ], | |
| 175 | 179 | }, | |
| 176 | 180 | 'cflags': [ '-O3' ], | |
| 177 | 181 | 'conditions': [ | |
| 182 | + ['enable_lto=="true"', { | ||
| 183 | + 'cflags': ['<(lto)'], | ||
| 184 | + 'ldflags': ['<(lto)'], | ||
| 185 | + 'xcode_settings': { | ||
| 186 | + 'LLVM_LTO': 'YES', | ||
| 187 | + }, | ||
| 188 | + }], | ||
| 178 | 189 | ['OS=="linux"', { | |
| 179 | 190 | 'conditions': [ | |
| 180 | 191 | ['node_section_ordering_info!=""', { | |
@@ -206,10 +217,6 @@ | |||
| 206 | 217 | 'cflags': ['<(pgo_use)'], | |
| 207 | 218 | 'ldflags': ['<(pgo_use)'], | |
| 208 | 219 | },], | |
| 209 | - ['enable_lto=="true"', { | ||
| 210 | - 'cflags': ['<(lto)'], | ||
| 211 | - 'ldflags': ['<(lto)'], | ||
| 212 | - },], | ||
| 213 | 220 | ], | |
| 214 | 221 | },], | |
| 215 | 222 | ['OS == "android"', { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -165,7 +165,7 @@ | |||
| 165 | 165 | action="store_true", | |
| 166 | 166 | dest="enable_lto", | |
| 167 | 167 | help="Enable compiling with lto of a binary. This feature is only available " | |
| 168 | - "on linux with gcc and g++ 5.4.1 or newer.") | ||
| 168 | + "with gcc 5.4.1+ or clang 3.9.1+.") | ||
| 169 | 169 | ||
| 170 | 170 | parser.add_option("--link-module", | |
| 171 | 171 | action="append", | |
@@ -866,6 +866,7 @@ def get_gas_version(cc): | |||
| 866 | 866 | # quite prepared to go that far yet. | |
| 867 | 867 | def check_compiler(o): | |
| 868 | 868 | if sys.platform == 'win32': | |
| 869 | + o['variables']['llvm_version'] = '0.0' | ||
| 869 | 870 | if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'): | |
| 870 | 871 | nasm_version = get_nasm_version('nasm') | |
| 871 | 872 | o['variables']['nasm_version'] = nasm_version | |
@@ -1045,12 +1046,19 @@ def configure_mips(o, target_arch): | |||
| 1045 | 1046 | host_byteorder = 'little' if target_arch in ('mipsel', 'mips64el') else 'big' | |
| 1046 | 1047 | o['variables']['v8_host_byteorder'] = host_byteorder | |
| 1047 | 1048 | ||
| 1049 | + def clang_version_ge(version_checked): | ||
| 1050 | + for compiler in [(CC, 'c'), (CXX, 'c++')]: | ||
| 1051 | + ok, is_clang, clang_version, gcc_version = \ | ||
| 1052 | + try_check_compiler(compiler[0], compiler[1]) | ||
| 1053 | + if is_clang and clang_version >= version_checked: | ||
| 1054 | + return True | ||
| 1055 | + return False | ||
| 1048 | 1056 | ||
| 1049 | 1057 | def gcc_version_ge(version_checked): | |
| 1050 | 1058 | for compiler in [(CC, 'c'), (CXX, 'c++')]: | |
| 1051 | - ok, is_clang, clang_version, compiler_version = \ | ||
| 1059 | + ok, is_clang, clang_version, gcc_version = \ | ||
| 1052 | 1060 | try_check_compiler(compiler[0], compiler[1]) | |
| 1053 | - if is_clang or compiler_version < version_checked: | ||
| 1061 | + if is_clang or gcc_version < version_checked: | ||
| 1054 | 1062 | return False | |
| 1055 | 1063 | return True | |
| 1056 | 1064 | ||
@@ -1131,18 +1139,19 @@ def configure_node(o): | |||
| 1131 | 1139 | o['variables']['enable_pgo_generate'] = b(options.enable_pgo_generate) | |
| 1132 | 1140 | o['variables']['enable_pgo_use'] = b(options.enable_pgo_use) | |
| 1133 | 1141 | ||
| 1134 | - if flavor != 'linux' and (options.enable_lto): | ||
| 1142 | + if flavor == 'win' and (options.enable_lto): | ||
| 1135 | 1143 | raise Exception( | |
| 1136 | - 'The lto option is supported only on linux.') | ||
| 1137 | - | ||
| 1138 | - if flavor == 'linux': | ||
| 1139 | - if options.enable_lto: | ||
| 1140 | - version_checked = (5, 4, 1) | ||
| 1141 | - if not gcc_version_ge(version_checked): | ||
| 1142 | - version_checked_str = ".".join(map(str, version_checked)) | ||
| 1143 | - raise Exception( | ||
| 1144 | - 'The option --enable-lto is supported for gcc and gxx %s' | ||
| 1145 | - ' or newer only.' % (version_checked_str)) | ||
| 1144 | + 'Use Link Time Code Generation instead.') | ||
| 1145 | + | ||
| 1146 | + if options.enable_lto: | ||
| 1147 | + gcc_version_checked = (5, 4, 1) | ||
| 1148 | + clang_version_checked = (3, 9, 1) | ||
| 1149 | + if not gcc_version_ge(gcc_version_checked) and not clang_version_ge(clang_version_checked): | ||
| 1150 | + gcc_version_checked_str = ".".join(map(str, gcc_version_checked)) | ||
| 1151 | + clang_version_checked_str = ".".join(map(str, clang_version_checked)) | ||
| 1152 | + raise Exception( | ||
| 1153 | + 'The option --enable-lto is supported for gcc %s+' | ||
| 1154 | + 'or clang %s+ only.' % (gcc_version_checked_str, clang_version_checked_str)) | ||
| 1146 | 1155 | ||
| 1147 | 1156 | o['variables']['enable_lto'] = b(options.enable_lto) | |
| 1148 | 1157 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments