Skip to content

Commit 8da83e8

Browse files
committed
build: always use strings for compiler version in gyp files
If GYP finds a string variable that can be converted to an integer, it will do it when the variable is expanded. Use "0.0" instead of "0" to force strings and be able to use comparison operations such as `gas_version >= "2.26"` in Python 3. PR-URL: #29897 Reviewed-By: Christian Clauss <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent 41430be commit 8da83e8

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

configure.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def get_version_helper(cc, regexp):
701701
if match:
702702
return match.group(2)
703703
else:
704-
return '0'
704+
return '0.0'
705705

706706
def get_nasm_version(asm):
707707
try:
@@ -712,15 +712,15 @@ def get_nasm_version(asm):
712712
warn('''No acceptable ASM compiler found!
713713
Please make sure you have installed NASM from https://www.nasm.us
714714
and refer BUILDING.md.''')
715-
return '0'
715+
return '0.0'
716716

717717
match = re.match(r"NASM version ([2-9]\.[0-9][0-9]+)",
718718
to_utf8(proc.communicate()[0]))
719719

720720
if match:
721721
return match.group(1)
722722
else:
723-
return '0'
723+
return '0.0'
724724

725725
def get_llvm_version(cc):
726726
return get_version_helper(
@@ -753,7 +753,7 @@ def get_gas_version(cc):
753753
return match.group(1)
754754
else:
755755
warn('Could not recognize `gas`: ' + gas_ret)
756-
return '0'
756+
return '0.0'
757757

758758
# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
759759
# the version check more by accident than anything else but a more rigorous
@@ -764,7 +764,7 @@ def check_compiler(o):
764764
if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'):
765765
nasm_version = get_nasm_version('nasm')
766766
o['variables']['nasm_version'] = nasm_version
767-
if nasm_version == 0:
767+
if nasm_version == '0.0':
768768
o['variables']['openssl_no_asm'] = 1
769769
return
770770

@@ -783,7 +783,7 @@ def check_compiler(o):
783783
# to a version that is not completely ancient.
784784
warn('C compiler too old, need gcc 4.2 or clang 3.2 (CC=%s)' % CC)
785785

786-
o['variables']['llvm_version'] = get_llvm_version(CC) if is_clang else 0
786+
o['variables']['llvm_version'] = get_llvm_version(CC) if is_clang else '0.0'
787787

788788
# Need xcode_version or gas_version when openssl asm files are compiled.
789789
if options.without_ssl or options.openssl_no_asm or options.shared_openssl:

deps/openssl/openssl.gyp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
'variables': {
3-
'gas_version%': 0,
4-
'llvm_version%': 0,
5-
'nasm_version%': 0,
3+
'gas_version%': '0.0',
4+
'llvm_version%': '0.0',
5+
'nasm_version%': '0.0',
66
},
77
'targets': [
88
{

deps/openssl/openssl_common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
'TERMIOS',
6565
],
6666
'conditions': [
67-
[ 'llvm_version==0', {
67+
[ 'llvm_version=="0.0"', {
6868
'cflags': ['-Wno-old-style-declaration',],
6969
}],
7070
],

node.gyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@
290290
'-Wl,-bnoerrmsg',
291291
],
292292
}],
293-
['(OS=="linux" or OS=="mac") and llvm_version!=0', {
293+
['OS in ("linux", "mac") and llvm_version != "0.0"', {
294294
'libraries': ['-latomic'],
295295
}],
296296
],

0 commit comments

Comments
 (0)