|
173 | 173 | dest="enable_lto", |
174 | 174 | default=None, |
175 | 175 | help="Enable compiling with lto of a binary. This feature is only available " |
176 | | - "on linux with gcc and g++ 5.4.1 or newer.") |
| 176 | + "with gcc 5.4.1+ or clang 3.9.1+.") |
177 | 177 |
|
178 | 178 | parser.add_argument("--link-module", |
179 | 179 | action="append", |
@@ -952,6 +952,7 @@ def get_gas_version(cc): |
952 | 952 | # quite prepared to go that far yet. |
953 | 953 | def check_compiler(o): |
954 | 954 | if sys.platform == 'win32': |
| 955 | + o['variables']['llvm_version'] = '0.0' |
955 | 956 | if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'): |
956 | 957 | nasm_version = get_nasm_version('nasm') |
957 | 958 | o['variables']['nasm_version'] = nasm_version |
@@ -1131,12 +1132,19 @@ def configure_mips(o, target_arch): |
1131 | 1132 | host_byteorder = 'little' if target_arch in ('mipsel', 'mips64el') else 'big' |
1132 | 1133 | o['variables']['v8_host_byteorder'] = host_byteorder |
1133 | 1134 |
|
| 1135 | +def clang_version_ge(version_checked): |
| 1136 | + for compiler in [(CC, 'c'), (CXX, 'c++')]: |
| 1137 | + ok, is_clang, clang_version, gcc_version = \ |
| 1138 | + try_check_compiler(compiler[0], compiler[1]) |
| 1139 | + if is_clang and clang_version >= version_checked: |
| 1140 | + return True |
| 1141 | + return False |
1134 | 1142 |
|
1135 | 1143 | def gcc_version_ge(version_checked): |
1136 | 1144 | for compiler in [(CC, 'c'), (CXX, 'c++')]: |
1137 | | - ok, is_clang, clang_version, compiler_version = \ |
| 1145 | + ok, is_clang, clang_version, gcc_version = \ |
1138 | 1146 | try_check_compiler(compiler[0], compiler[1]) |
1139 | | - if is_clang or compiler_version < version_checked: |
| 1147 | + if is_clang or gcc_version < version_checked: |
1140 | 1148 | return False |
1141 | 1149 | return True |
1142 | 1150 |
|
@@ -1217,18 +1225,19 @@ def configure_node(o): |
1217 | 1225 | o['variables']['enable_pgo_generate'] = b(options.enable_pgo_generate) |
1218 | 1226 | o['variables']['enable_pgo_use'] = b(options.enable_pgo_use) |
1219 | 1227 |
|
1220 | | - if flavor != 'linux' and (options.enable_lto): |
| 1228 | + if flavor == 'win' and (options.enable_lto): |
1221 | 1229 | raise Exception( |
1222 | | - 'The lto option is supported only on linux.') |
1223 | | - |
1224 | | - if flavor == 'linux': |
1225 | | - if options.enable_lto: |
1226 | | - version_checked = (5, 4, 1) |
1227 | | - if not gcc_version_ge(version_checked): |
1228 | | - version_checked_str = ".".join(map(str, version_checked)) |
1229 | | - raise Exception( |
1230 | | - 'The option --enable-lto is supported for gcc and gxx %s' |
1231 | | - ' or newer only.' % (version_checked_str)) |
| 1230 | + 'Use Link Time Code Generation instead.') |
| 1231 | + |
| 1232 | + if options.enable_lto: |
| 1233 | + gcc_version_checked = (5, 4, 1) |
| 1234 | + clang_version_checked = (3, 9, 1) |
| 1235 | + if not gcc_version_ge(gcc_version_checked) and not clang_version_ge(clang_version_checked): |
| 1236 | + gcc_version_checked_str = ".".join(map(str, gcc_version_checked)) |
| 1237 | + clang_version_checked_str = ".".join(map(str, clang_version_checked)) |
| 1238 | + raise Exception( |
| 1239 | + 'The option --enable-lto is supported for gcc %s+' |
| 1240 | + 'or clang %s+ only.' % (gcc_version_checked_str, clang_version_checked_str)) |
1232 | 1241 |
|
1233 | 1242 | o['variables']['enable_lto'] = b(options.enable_lto) |
1234 | 1243 |
|
|
0 commit comments