|
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 |
|
|
0 commit comments