Skip to content

Commit

Permalink
deps, build: add support older assembler
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Shigeki Ohtsu committed Apr 14, 2015
1 parent 53924d8 commit a1c9ef3
Show file tree
Hide file tree
Showing 5 changed files with 652 additions and 20 deletions.
81 changes: 71 additions & 10 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,63 @@ def try_check_compiler(cc, lang):
return (True, is_clang, clang_version, gcc_version)


#
# The version of asm compiler is needed for building openssl asm files.
# See deps/openssl/openssl.gypi for detail.
# Commands and reglar expressions to obtain its version number is taken from
# https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/sha/asm/sha512-x86_64.pl#L112-L129
#
def get_llvm_version(cc):
try:
proc = subprocess.Popen(shlex.split(cc) + ['-v'], stdin=subprocess.PIPE,
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
except OSError:
print '''Node.js configure error: No acceptable C compiler found!
Please make sure you have a C compiler installed on your system and/or
consider adjusting the CC environment variable if you installed
it in a non-standard prefix.
'''
sys.exit()

match = re.search(r"(^clang version|based on LLVM) ([3-9]\.[0-9]+)",
proc.communicate()[1])

if match:
return match.group(2)
else:
return 0


def get_gas_version(cc):
try:
proc = subprocess.Popen(shlex.split(cc) + ['-Wa,-v', '-c', '-o',
'/dev/null', '-x',
'assembler', '/dev/null'],
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
except OSError:
print '''Node.js configure error: No acceptable C compiler found!
Please make sure you have a C compiler installed on your system and/or
consider adjusting the CC environment variable if you installed
it in a non-standard prefix.
'''
sys.exit()

match = re.match(r"GNU assembler version ([2-9]\.[0-9]+)",
proc.communicate()[1])

if match:
return match.group(1)
else:
return 0

# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
# the version check more by accident than anything else but a more rigorous
# check involves checking the build number against a whitelist. I'm not
# quite prepared to go that far yet.
def check_compiler():
def check_compiler(o):
if sys.platform == 'win32':
return

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

# Need llvm_version or gas_version when openssl asm files are compiled
if options.without_ssl or options.openssl_no_asm or options.shared_openssl:
return

if is_clang:
o['variables']['llvm_version'] = get_llvm_version(CC)
else:
o['variables']['gas_version'] = get_gas_version(CC)


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

output = {
'variables': { 'python': sys.executable },
'include_dirs': [],
'libraries': [],
'defines': [],
'cflags': [],
}

# Print a warning when the compiler is too old.
check_compiler()
check_compiler(output)

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

output = {
'variables': { 'python': sys.executable },
'include_dirs': [],
'libraries': [],
'defines': [],
'cflags': [],
}

configure_node(output)
configure_libz(output)
configure_http_parser(output)
Expand Down
Loading

0 comments on commit a1c9ef3

Please sign in to comment.