Skip to content

Commit

Permalink
deps, build: add support older asm compiler
Browse files Browse the repository at this point in the history
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 MSVS_VERSION>='2012' (ml64 >= 12) as defined in
https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/ec/asm/ecp_nistz256-avx2.pl#L45-L67
,otherwise asm_obsolute are used.
  • Loading branch information
Shigeki Ohtsu committed Mar 17, 2015
1 parent 698512d commit eaf44c8
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 20 deletions.
80 changes: 70 additions & 10 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,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/ec/asm/ecp_nistz256-avx2.pl#L45-L67
#
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 is None:
return 0
else:
return int(match.group(2) + match.group(3))


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 is None:
return 0
else:
return int(match.group(1) + match.group(2))

# 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 @@ -390,6 +442,14 @@ 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 @@ -961,8 +1021,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 @@ -971,14 +1039,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
1 change: 1 addition & 0 deletions deps/openssl/openssl-cli.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'defines': [
'MONOLITH'
],
'includes': ['openssl.gypi'],
'sources': ['<@(openssl_cli_sources)'],
'conditions': [
['OS=="solaris"', {
Expand Down
7 changes: 5 additions & 2 deletions deps/openssl/openssl.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
'variables': {
'is_clang': 0,
'gcc_version': 0,
'openssl_no_asm%': 0
'openssl_no_asm%': 0,
'llvm_version%': 0,
'gas_version%': 0,
},
'includes': ['openssl.gypi'],
'targets': [
{
'target_name': 'openssl',
'type': '<(library)',
'includes': ['openssl.gypi'],
'sources': ['<@(openssl_sources)'],
'sources/': [
['exclude', 'md2/.*$'],
Expand Down Expand Up @@ -100,6 +102,7 @@
}
],
'target_defaults': {
'includes': ['openssl.gypi'],
'include_dirs': ['<@(openssl_default_include_dirs)'],
'defines': ['<@(openssl_default_defines_all)'],
'conditions': [
Expand Down
Loading

0 comments on commit eaf44c8

Please sign in to comment.