@@ -349,11 +349,63 @@ def try_check_compiler(cc, lang):
349
349
return (True , is_clang , clang_version , gcc_version )
350
350
351
351
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
+
352
404
# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
353
405
# the version check more by accident than anything else but a more rigorous
354
406
# check involves checking the build number against a whitelist. I'm not
355
407
# quite prepared to go that far yet.
356
- def check_compiler ():
408
+ def check_compiler (o ):
357
409
if sys .platform == 'win32' :
358
410
return
359
411
@@ -372,6 +424,14 @@ def check_compiler():
372
424
# to a version that is not completely ancient.
373
425
warn ('C compiler too old, need gcc 4.2 or clang 3.2 (CC=%s)' % CC )
374
426
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 )
375
435
376
436
def cc_macros ():
377
437
"""Checks predefined macros using the CC command."""
@@ -945,8 +1005,16 @@ def configure_intl(o):
945
1005
pprint .pformat (icu_config , indent = 2 ) + '\n ' )
946
1006
return # end of configure_intl
947
1007
1008
+ output = {
1009
+ 'variables' : { 'python' : sys .executable },
1010
+ 'include_dirs' : [],
1011
+ 'libraries' : [],
1012
+ 'defines' : [],
1013
+ 'cflags' : [],
1014
+ }
1015
+
948
1016
# Print a warning when the compiler is too old.
949
- check_compiler ()
1017
+ check_compiler (output )
950
1018
951
1019
# determine the "flavor" (operating system) we're building for,
952
1020
# leveraging gyp's GetFlavor function
@@ -955,14 +1023,6 @@ if (options.dest_os):
955
1023
flavor_params ['flavor' ] = options .dest_os
956
1024
flavor = GetFlavor (flavor_params )
957
1025
958
- output = {
959
- 'variables' : { 'python' : sys .executable },
960
- 'include_dirs' : [],
961
- 'libraries' : [],
962
- 'defines' : [],
963
- 'cflags' : [],
964
- }
965
-
966
1026
configure_node (output )
967
1027
configure_libz (output )
968
1028
configure_http_parser (output )
0 commit comments