Skip to content

Commit a1c9ef3

Browse files
author
Shigeki Ohtsu
committed
deps, build: add support older assembler
Asm files for OpenSSL depends on the version of assembler. We provide two sets of asm files, one is asm_latest(avx2 and addx supported) and the other asm_obsolute(without avx1/2 and addx) The asm_latest needs the version of gas >= 2.23, llvm >= 3.3 or ml64 >= 12 as defined in https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/sha/asm/sha512-x86_64.pl#L112-L129 , otherwise asm_obsolute are used. We take MSVS_VERSION in gyp as a version check of assembler on Windows because the path to ml64.exe was set after configure in vcbuild.bat and executing ml64.exe was failed in configure. Fixes: #589 PR-URL: #1389 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 53924d8 commit a1c9ef3

File tree

5 files changed

+652
-20
lines changed

5 files changed

+652
-20
lines changed

configure

+71-10
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,63 @@ def try_check_compiler(cc, lang):
357357
return (True, is_clang, clang_version, gcc_version)
358358

359359

360+
#
361+
# The version of asm compiler is needed for building openssl asm files.
362+
# See deps/openssl/openssl.gypi for detail.
363+
# Commands and reglar expressions to obtain its version number is taken from
364+
# https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/sha/asm/sha512-x86_64.pl#L112-L129
365+
#
366+
def get_llvm_version(cc):
367+
try:
368+
proc = subprocess.Popen(shlex.split(cc) + ['-v'], stdin=subprocess.PIPE,
369+
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
370+
except OSError:
371+
print '''Node.js configure error: No acceptable C compiler found!
372+
373+
Please make sure you have a C compiler installed on your system and/or
374+
consider adjusting the CC environment variable if you installed
375+
it in a non-standard prefix.
376+
'''
377+
sys.exit()
378+
379+
match = re.search(r"(^clang version|based on LLVM) ([3-9]\.[0-9]+)",
380+
proc.communicate()[1])
381+
382+
if match:
383+
return match.group(2)
384+
else:
385+
return 0
386+
387+
388+
def get_gas_version(cc):
389+
try:
390+
proc = subprocess.Popen(shlex.split(cc) + ['-Wa,-v', '-c', '-o',
391+
'/dev/null', '-x',
392+
'assembler', '/dev/null'],
393+
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
394+
stdout=subprocess.PIPE)
395+
except OSError:
396+
print '''Node.js configure error: No acceptable C compiler found!
397+
398+
Please make sure you have a C compiler installed on your system and/or
399+
consider adjusting the CC environment variable if you installed
400+
it in a non-standard prefix.
401+
'''
402+
sys.exit()
403+
404+
match = re.match(r"GNU assembler version ([2-9]\.[0-9]+)",
405+
proc.communicate()[1])
406+
407+
if match:
408+
return match.group(1)
409+
else:
410+
return 0
411+
360412
# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
361413
# the version check more by accident than anything else but a more rigorous
362414
# check involves checking the build number against a whitelist. I'm not
363415
# quite prepared to go that far yet.
364-
def check_compiler():
416+
def check_compiler(o):
365417
if sys.platform == 'win32':
366418
return
367419

@@ -380,6 +432,15 @@ def check_compiler():
380432
# to a version that is not completely ancient.
381433
warn('C compiler too old, need gcc 4.2 or clang 3.2 (CC=%s)' % CC)
382434

435+
# Need llvm_version or gas_version when openssl asm files are compiled
436+
if options.without_ssl or options.openssl_no_asm or options.shared_openssl:
437+
return
438+
439+
if is_clang:
440+
o['variables']['llvm_version'] = get_llvm_version(CC)
441+
else:
442+
o['variables']['gas_version'] = get_gas_version(CC)
443+
383444

384445
def cc_macros():
385446
"""Checks predefined macros using the CC command."""
@@ -935,8 +996,16 @@ def configure_intl(o):
935996
pprint.pformat(icu_config, indent=2) + '\n')
936997
return # end of configure_intl
937998

999+
output = {
1000+
'variables': { 'python': sys.executable },
1001+
'include_dirs': [],
1002+
'libraries': [],
1003+
'defines': [],
1004+
'cflags': [],
1005+
}
1006+
9381007
# Print a warning when the compiler is too old.
939-
check_compiler()
1008+
check_compiler(output)
9401009

9411010
# determine the "flavor" (operating system) we're building for,
9421011
# leveraging gyp's GetFlavor function
@@ -945,14 +1014,6 @@ if (options.dest_os):
9451014
flavor_params['flavor'] = options.dest_os
9461015
flavor = GetFlavor(flavor_params)
9471016

948-
output = {
949-
'variables': { 'python': sys.executable },
950-
'include_dirs': [],
951-
'libraries': [],
952-
'defines': [],
953-
'cflags': [],
954-
}
955-
9561017
configure_node(output)
9571018
configure_libz(output)
9581019
configure_http_parser(output)

0 commit comments

Comments
 (0)