Skip to content

Commit 208e06a

Browse files
author
Shigeki Ohtsu
committed
deps, build: add support older asm compiler
Asm files for OpenSSL depends on the version of asm compiler. 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 asm compiler on Windows because the path to ml64.exe was set after configure in vcbuild.bat and executing ml64.exe was failed in configure.
1 parent f2327d0 commit 208e06a

File tree

5 files changed

+651
-20
lines changed

5 files changed

+651
-20
lines changed

configure

+70-10
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,63 @@ def try_check_compiler(cc, lang):
349349
return (True, is_clang, clang_version, gcc_version)
350350

351351

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

@@ -372,6 +424,14 @@ def check_compiler():
372424
# to a version that is not completely ancient.
373425
warn('C compiler too old, need gcc 4.2 or clang 3.2 (CC=%s)' % CC)
374426

427+
# Need llvm_version or gas_version when openssl asm files are compiled
428+
if options.without_ssl or options.openssl_no_asm or options.shared_openssl:
429+
return
430+
431+
if is_clang:
432+
o['variables']['llvm_version'] = get_llvm_version(CC)
433+
else:
434+
o['variables']['gas_version'] = get_gas_version(CC)
375435

376436
def cc_macros():
377437
"""Checks predefined macros using the CC command."""
@@ -945,8 +1005,16 @@ def configure_intl(o):
9451005
pprint.pformat(icu_config, indent=2) + '\n')
9461006
return # end of configure_intl
9471007

1008+
output = {
1009+
'variables': { 'python': sys.executable },
1010+
'include_dirs': [],
1011+
'libraries': [],
1012+
'defines': [],
1013+
'cflags': [],
1014+
}
1015+
9481016
# Print a warning when the compiler is too old.
949-
check_compiler()
1017+
check_compiler(output)
9501018

9511019
# determine the "flavor" (operating system) we're building for,
9521020
# leveraging gyp's GetFlavor function
@@ -955,14 +1023,6 @@ if (options.dest_os):
9551023
flavor_params['flavor'] = options.dest_os
9561024
flavor = GetFlavor(flavor_params)
9571025

958-
output = {
959-
'variables': { 'python': sys.executable },
960-
'include_dirs': [],
961-
'libraries': [],
962-
'defines': [],
963-
'cflags': [],
964-
}
965-
9661026
configure_node(output)
9671027
configure_libz(output)
9681028
configure_http_parser(output)

0 commit comments

Comments
 (0)