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 <cclauss@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
1 parent 41430be commit 8da83e8

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎configure.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def get_version_helper(cc, regexp):
701701
ifmatch:
702702
returnmatch.group(2)
703703
else:
704-
return'0'
704+
return'0.0'
705705

706706
defget_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
ifmatch:
721721
returnmatch.group(1)
722722
else:
723-
return'0'
723+
return'0.0'
724724

725725
defget_llvm_version(cc):
726726
returnget_version_helper(
@@ -753,7 +753,7 @@ def get_gas_version(cc):
753753
returnmatch.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
ifnotoptions.openssl_no_asmandoptions.dest_cpuin ('x86', 'x64'):
765765
nasm_version=get_nasm_version('nasm')
766766
o['variables']['nasm_version'] =nasm_version
767-
ifnasm_version==0:
767+
ifnasm_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) ifis_clangelse0
786+
o['variables']['llvm_version'] =get_llvm_version(CC) ifis_clangelse'0.0'
787787

788788
# Need xcode_version or gas_version when openssl asm files are compiled.
789789
ifoptions.without_ssloroptions.openssl_no_asmoroptions.shared_openssl:

‎deps/openssl/openssl.gyp‎

Lines changed: 3 additions & 3 deletions
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 1 addition & 1 deletion
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)