Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit eff6d37

Browse files
committed
Merge remote-tracking branch 'upstream/v10.x' into v10.x
2 parents 88689b5 + b935e63 commit eff6d37

File tree

2 files changed

+75
-72
lines changed

2 files changed

+75
-72
lines changed

BUILDING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ Depending on host platform, the selection of toolchains may vary.
9494
#### OpenSSL asm support
9595

9696
OpenSSL-1.1.0 requires the following asssembler version for use of asm
97-
support.
97+
support on x86_64 and ia32.
9898

9999
* gas (GNU assembler) version 2.23 or higher
100100
* xcode version 5.0 or higher
101101
* llvm version 3.3 or higher
102102
* nasm version 2.10 or higher in Windows
103103

104-
Otherwise, `--openssl-no-asm` is added with warning in configure.
104+
Otherwise `configure` will fail with an error. This can be avoided by
105+
either providing a newer assembler as per the list above or by
106+
using the `--openssl-no-asm` flag.
105107

106108
*Note:* The forthcoming OpenSSL-1.1.1 will require higher
107109
version. Please refer

configure

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,11 @@ options.prefix = os.path.expanduser(options.prefix or '')
598598
auto_downloads = nodedownload.parse(options.download_list)
599599

600600

601+
def error(msg):
602+
prefix = '\033[1m\033[31mERROR\033[0m' if os.isatty(1) else 'ERROR'
603+
print('%s: %s' % (prefix, msg))
604+
sys.exit(1)
605+
601606
def warn(msg):
602607
warn.warned = True
603608
prefix = '\033[1m\033[93mWARNING\033[0m' if os.isatty(1) else 'WARNING'
@@ -659,20 +664,18 @@ def get_version_helper(cc, regexp):
659664
proc = subprocess.Popen(shlex.split(cc) + ['-v'], stdin=subprocess.PIPE,
660665
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
661666
except OSError:
662-
print('''Node.js configure error: No acceptable C compiler found!
667+
error('''No acceptable C compiler found!
663668
664-
Please make sure you have a C compiler installed on your system and/or
665-
consider adjusting the CC environment variable if you installed
666-
it in a non-standard prefix.
667-
''')
668-
sys.exit()
669+
Please make sure you have a C compiler installed on your system and/or
670+
consider adjusting the CC environment variable if you installed
671+
it in a non-standard prefix.''')
669672

670673
match = re.search(regexp, proc.communicate()[1])
671674

672675
if match:
673676
return match.group(2)
674677
else:
675-
return 0
678+
return '0'
676679

677680
def get_nasm_version(asm):
678681
try:
@@ -681,17 +684,17 @@ def get_nasm_version(asm):
681684
stdout=subprocess.PIPE)
682685
except OSError:
683686
warn('''No acceptable ASM compiler found!
684-
Please make sure you have installed nasm from http://www.nasm.us
687+
Please make sure you have installed NASM from http://www.nasm.us
685688
and refer BUILDING.md.''')
686-
return 0
689+
return '0'
687690

688691
match = re.match(r"NASM version ([2-9]\.[0-9][0-9]+)",
689692
proc.communicate()[0])
690693

691694
if match:
692695
return match.group(1)
693696
else:
694-
return 0
697+
return '0'
695698

696699
def get_llvm_version(cc):
697700
return get_version_helper(
@@ -709,21 +712,19 @@ def get_gas_version(cc):
709712
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
710713
stdout=subprocess.PIPE)
711714
except OSError:
712-
print('''Node.js configure error: No acceptable C compiler found!
715+
error('''No acceptable C compiler found!
713716
714-
Please make sure you have a C compiler installed on your system and/or
715-
consider adjusting the CC environment variable if you installed
716-
it in a non-standard prefix.
717-
''')
718-
sys.exit()
717+
Please make sure you have a C compiler installed on your system and/or
718+
consider adjusting the CC environment variable if you installed
719+
it in a non-standard prefix.''')
719720

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

723724
if match:
724725
return match.group(1)
725726
else:
726-
return 0
727+
return '0'
727728

728729
# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
729730
# the version check more by accident than anything else but a more rigorous
@@ -777,13 +778,11 @@ def cc_macros(cc=None):
777778
stdout=subprocess.PIPE,
778779
stderr=subprocess.PIPE)
779780
except OSError:
780-
print('''Node.js configure error: No acceptable C compiler found!
781+
error('''No acceptable C compiler found!
781782
782-
Please make sure you have a C compiler installed on your system and/or
783-
consider adjusting the CC environment variable if you installed
784-
it in a non-standard prefix.
785-
''')
786-
sys.exit()
783+
Please make sure you have a C compiler installed on your system and/or
784+
consider adjusting the CC environment variable if you installed
785+
it in a non-standard prefix.''')
787786

788787
p.stdin.write('\n')
789788
out = p.communicate()[0]
@@ -1115,6 +1114,19 @@ def configure_openssl(o):
11151114
variables['node_use_openssl'] = b(not options.without_ssl)
11161115
variables['node_shared_openssl'] = b(options.shared_openssl)
11171116
variables['openssl_no_asm'] = 1 if options.openssl_no_asm else 0
1117+
variables['openssl_fips'] = ''
1118+
1119+
if options.without_ssl:
1120+
def without_ssl_error(option):
1121+
error('--without-ssl is incompatible with %s' % option)
1122+
if options.shared_openssl:
1123+
without_ssl_error('--shared-openssl')
1124+
if options.openssl_no_asm:
1125+
without_ssl_error('--openssl-no-asm')
1126+
if options.openssl_fips:
1127+
without_ssl_error('--openssl-fips')
1128+
return
1129+
11181130
if options.use_openssl_ca_store:
11191131
o['defines'] += ['NODE_OPENSSL_CERT_STORE']
11201132
if options.openssl_system_ca_path:
@@ -1123,36 +1135,33 @@ def configure_openssl(o):
11231135
if options.without_node_options:
11241136
o['defines'] += ['NODE_WITHOUT_NODE_OPTIONS']
11251137

1126-
# supported asm compiler for AVX2. See https://github.com/openssl/openssl/
1127-
# blob/OpenSSL_1_1_0-stable/crypto/modes/asm/aesni-gcm-x86_64.pl#L52-L69
1128-
openssl110_asm_supported = \
1129-
('gas_version' in variables and variables['gas_version'] >= '2.23') or \
1130-
('xcode_version' in variables and variables['xcode_version'] >= '5.0') or \
1131-
('llvm_version' in variables and variables['llvm_version'] >= '3.3') or \
1132-
('nasm_version' in variables and variables['nasm_version'] >= '2.10')
1138+
if not options.shared_openssl and not options.openssl_no_asm:
1139+
is_x86 = 'x64' in variables['target_arch'] or 'ia32' in variables['target_arch']
11331140

1134-
if not options.without_ssl and not openssl110_asm_supported and \
1135-
variables['openssl_no_asm'] == 0:
1136-
warn('''openssl_no_asm is enabled due to missed or old assembler.
1137-
Please refer BUILDING.md''')
1138-
variables['openssl_no_asm'] = 1
1141+
# supported asm compiler for AVX2. See https://github.com/openssl/openssl/
1142+
# blob/OpenSSL_1_1_0-stable/crypto/modes/asm/aesni-gcm-x86_64.pl#L52-L69
1143+
openssl110_asm_supported = \
1144+
('gas_version' in variables and float(variables['gas_version']) >= 2.23) or \
1145+
('xcode_version' in variables and float(variables['xcode_version']) >= 5.0) or \
1146+
('llvm_version' in variables and float(variables['llvm_version']) >= 3.3) or \
1147+
('nasm_version' in variables and float(variables['nasm_version']) >= 2.10)
1148+
1149+
if is_x86 and not openssl110_asm_supported:
1150+
error('''Did not find a new enough assembler, install one or build with
1151+
--openssl-no-asm.
1152+
Please refer to BUILDING.md''')
1153+
1154+
elif options.openssl_no_asm:
1155+
warn('''--openssl-no-asm will result in binaries that do not take advantage
1156+
of modern CPU cryptographic instructions and will therefore be slower.
1157+
Please refer to BUILDING.md''')
1158+
1159+
if options.openssl_no_asm and options.shared_openssl:
1160+
error('--openssl-no-asm is incompatible with --shared-openssl')
11391161

11401162
if options.openssl_fips:
1141-
print('Error: FIPS is not supported yet in this version')
1142-
exit(1)
1143-
variables['openssl_fips'] = ''
1163+
error('FIPS is not supported in this version of Node.js')
11441164

1145-
if options.without_ssl:
1146-
def without_ssl_error(option):
1147-
print('Error: --without-ssl is incompatible with %s' % option)
1148-
exit(1)
1149-
if options.shared_openssl:
1150-
without_ssl_error('--shared-openssl')
1151-
if options.openssl_no_asm:
1152-
without_ssl_error('--openssl-no-asm')
1153-
if options.openssl_fips:
1154-
without_ssl_error('--openssl-fips')
1155-
return
11561165
configure_library('openssl', o)
11571166

11581167

@@ -1208,9 +1217,8 @@ def configure_intl(o):
12081217
def icu_download(path):
12091218
# download ICU, if needed
12101219
if not os.access(options.download_path, os.W_OK):
1211-
print('Error: cannot write to desired download path. ' \
1212-
'Either create it or verify permissions.')
1213-
sys.exit(1)
1220+
error('''Cannot write to desired download path.
1221+
Either create it or verify permissions.''')
12141222
for icu in icus:
12151223
url = icu['url']
12161224
md5 = icu['md5']
@@ -1249,8 +1257,7 @@ def configure_intl(o):
12491257
with_icu_source = options.with_icu_source
12501258
have_icu_path = bool(options.with_icu_path)
12511259
if have_icu_path and with_intl != 'none':
1252-
print('Error: Cannot specify both --with-icu-path and --with-intl')
1253-
sys.exit(1)
1260+
error('Cannot specify both --with-icu-path and --with-intl')
12541261
elif have_icu_path:
12551262
# Chromium .gyp mode: --with-icu-path
12561263
o['variables']['v8_enable_i18n_support'] = 1
@@ -1278,9 +1285,8 @@ def configure_intl(o):
12781285
o['variables']['v8_enable_i18n_support'] = 1
12791286
pkgicu = pkg_config('icu-i18n')
12801287
if pkgicu[0] is None:
1281-
print('Error: could not load pkg-config data for "icu-i18n".')
1282-
print('See above errors or the README.md.')
1283-
sys.exit(1)
1288+
error('''Could not load pkg-config data for "icu-i18n".
1289+
See above errors or the README.md.''')
12841290
(libs, cflags, libpath) = pkgicu
12851291
# libpath provides linker path which may contain spaces
12861292
if libpath:
@@ -1366,10 +1372,9 @@ def configure_intl(o):
13661372
os.rename(tmp_icu, icu_full_path)
13671373
shutil.rmtree(icu_tmp_path)
13681374
else:
1369-
print('Error: --with-icu-source=%s did not result in an "icu" dir.' % \
1370-
with_icu_source)
13711375
shutil.rmtree(icu_tmp_path)
1372-
sys.exit(1)
1376+
error('--with-icu-source=%s did not result in an "icu" dir.' % \
1377+
with_icu_source)
13731378

13741379
# ICU mode. (icu-generic.gyp)
13751380
o['variables']['icu_gyp_path'] = 'tools/icu/icu-generic.gyp'
@@ -1382,17 +1387,15 @@ def configure_intl(o):
13821387
if localzip:
13831388
nodedownload.unpack(localzip, icu_parent_path)
13841389
if not os.path.isdir(icu_full_path):
1385-
print('Cannot build Intl without ICU in %s.' % icu_full_path)
1386-
print('(Fix, or disable with "--with-intl=none" )')
1387-
sys.exit(1)
1390+
error('''Cannot build Intl without ICU in %s.
1391+
Fix, or disable with "--with-intl=none"''' % icu_full_path)
13881392
else:
13891393
print('* Using ICU in %s' % icu_full_path)
13901394
# Now, what version of ICU is it? We just need the "major", such as 54.
13911395
# uvernum.h contains it as a #define.
13921396
uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h')
13931397
if not os.path.isfile(uvernum_h):
1394-
print('Error: could not load %s - is ICU installed?' % uvernum_h)
1395-
sys.exit(1)
1398+
error('Could not load %s - is ICU installed?' % uvernum_h)
13961399
icu_ver_major = None
13971400
matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
13981401
match_version = re.compile(matchVerExp)
@@ -1401,8 +1404,7 @@ def configure_intl(o):
14011404
if m:
14021405
icu_ver_major = m.group(1)
14031406
if not icu_ver_major:
1404-
print('Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h)
1405-
sys.exit(1)
1407+
error('Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h)
14061408
icu_endianness = sys.byteorder[0];
14071409
o['variables']['icu_ver_major'] = icu_ver_major
14081410
o['variables']['icu_endianness'] = icu_endianness
@@ -1426,10 +1428,9 @@ def configure_intl(o):
14261428
# may be little-endian if from a icu-project.org tarball
14271429
o['variables']['icu_data_in'] = icu_data_in
14281430
if not os.path.isfile(icu_data_path):
1429-
print('Error: ICU prebuilt data file %s does not exist.' % icu_data_path)
1430-
print('See the README.md.')
14311431
# .. and we're not about to build it from .gyp!
1432-
sys.exit(1)
1432+
error('''ICU prebuilt data file %s does not exist.
1433+
See the README.md.''' % icu_data_path)
14331434
# map from variable name to subdirs
14341435
icu_src = {
14351436
'stubdata': 'stubdata',

0 commit comments

Comments
 (0)