Skip to content

Commit adc3e8a

Browse files
rvaggjasnell
authored andcommitted
build: require --openssl-no-asm if old assembler
PR-URL: #20226 Fixes: #19944 Refs: #20217 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 160d2d5 commit adc3e8a

File tree

1 file changed

+38
-29
lines changed

1 file changed

+38
-29
lines changed

configure

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ def get_version_helper(cc, regexp):
650650
if match:
651651
return match.group(2)
652652
else:
653-
return 0
653+
return '0'
654654

655655
def get_nasm_version(asm):
656656
try:
@@ -661,15 +661,15 @@ def get_nasm_version(asm):
661661
warn('''No acceptable ASM compiler found!
662662
Please make sure you have installed NASM from http://www.nasm.us
663663
and refer BUILDING.md.''')
664-
return 0
664+
return '0'
665665

666666
match = re.match(r"NASM version ([2-9]\.[0-9][0-9]+)",
667667
proc.communicate()[0])
668668

669669
if match:
670670
return match.group(1)
671671
else:
672-
return 0
672+
return '0'
673673

674674
def get_llvm_version(cc):
675675
return get_version_helper(
@@ -699,7 +699,7 @@ def get_gas_version(cc):
699699
if match:
700700
return match.group(1)
701701
else:
702-
return 0
702+
return '0'
703703

704704
# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
705705
# the version check more by accident than anything else but a more rigorous
@@ -1084,6 +1084,19 @@ def configure_openssl(o):
10841084
variables['node_use_openssl'] = b(not options.without_ssl)
10851085
variables['node_shared_openssl'] = b(options.shared_openssl)
10861086
variables['openssl_no_asm'] = 1 if options.openssl_no_asm else 0
1087+
variables['openssl_fips'] = ''
1088+
1089+
if options.without_ssl:
1090+
def without_ssl_error(option):
1091+
error('--without-ssl is incompatible with %s' % option)
1092+
if options.shared_openssl:
1093+
without_ssl_error('--shared-openssl')
1094+
if options.openssl_no_asm:
1095+
without_ssl_error('--openssl-no-asm')
1096+
if options.openssl_fips:
1097+
without_ssl_error('--openssl-fips')
1098+
return
1099+
10871100
if options.use_openssl_ca_store:
10881101
o['defines'] += ['NODE_OPENSSL_CERT_STORE']
10891102
if options.openssl_system_ca_path:
@@ -1092,35 +1105,31 @@ def configure_openssl(o):
10921105
if options.without_node_options:
10931106
o['defines'] += ['NODE_WITHOUT_NODE_OPTIONS']
10941107

1095-
# supported asm compiler for AVX2. See https://github.com/openssl/openssl/
1096-
# blob/OpenSSL_1_1_0-stable/crypto/modes/asm/aesni-gcm-x86_64.pl#L52-L69
1097-
openssl110_asm_supported = \
1098-
('gas_version' in variables and variables['gas_version'] >= '2.23') or \
1099-
('xcode_version' in variables and variables['xcode_version'] >= '5.0') or \
1100-
('llvm_version' in variables and variables['llvm_version'] >= '3.3') or \
1101-
('nasm_version' in variables and variables['nasm_version'] >= '2.10')
1108+
if not options.shared_openssl and not options.openssl_no_asm:
1109+
# supported asm compiler for AVX2. See https://github.com/openssl/openssl/
1110+
# blob/OpenSSL_1_1_0-stable/crypto/modes/asm/aesni-gcm-x86_64.pl#L52-L69
1111+
openssl110_asm_supported = \
1112+
('gas_version' in variables and float(variables['gas_version']) >= 2.23) or \
1113+
('xcode_version' in variables and float(variables['xcode_version']) >= 5.0) or \
1114+
('llvm_version' in variables and float(variables['llvm_version']) >= 3.3) or \
1115+
('nasm_version' in variables and float(variables['nasm_version']) >= 2.10)
11021116

1103-
if not options.without_ssl and not openssl110_asm_supported and \
1104-
variables['openssl_no_asm'] == 0:
1105-
warn('''openssl_no_asm is enabled due to missed or old assembler.
1106-
Please refer BUILDING.md''')
1107-
variables['openssl_no_asm'] = 1
1117+
if not openssl110_asm_supported:
1118+
error('''Did not find a new enough assembler, install one or build with
1119+
--openssl-no-asm.
1120+
Please refer to BUILDING.md''')
1121+
1122+
elif options.openssl_no_asm:
1123+
warn('''--openssl-no-asm will result in binaries that do not take advantage
1124+
of modern CPU cryptographic instructions and will therefore be slower.
1125+
Please refer to BUILDING.md''')
1126+
1127+
if options.openssl_no_asm and options.shared_openssl:
1128+
error('--openssl-no-asm is incompatible with --shared-openssl')
11081129

11091130
if options.openssl_fips:
1110-
error('FIPS is not supported in this version')
1111-
variables['openssl_fips'] = ''
1131+
error('FIPS is not supported in this version of Node.js')
11121132

1113-
if options.without_ssl:
1114-
def without_ssl_error(option):
1115-
print('Error: --without-ssl is incompatible with %s' % option)
1116-
exit(1)
1117-
if options.shared_openssl:
1118-
without_ssl_error('--shared-openssl')
1119-
if options.openssl_no_asm:
1120-
without_ssl_error('--openssl-no-asm')
1121-
if options.openssl_fips:
1122-
without_ssl_error('--openssl-fips')
1123-
return
11241133
configure_library('openssl', o)
11251134

11261135

0 commit comments

Comments
 (0)