File tree 3 files changed +23
-16
lines changed
3 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -350,12 +350,13 @@ if selected_platform in platform_list:
350
350
# Force to use Unicode encoding
351
351
env .Append (MSVC_FLAGS = ['/utf8' ])
352
352
else : # Rest of the world
353
+ version = methods .get_compiler_version (env ) or [- 1 , - 1 ]
354
+
353
355
shadow_local_warning = []
354
356
all_plus_warnings = ['-Wwrite-strings' ]
355
357
356
358
if methods .using_gcc (env ):
357
- version = methods .get_compiler_version (env )
358
- if version != None and version [0 ] >= '7' :
359
+ if version [0 ] >= 7 :
359
360
shadow_local_warning = ['-Wshadow-local' ]
360
361
361
362
if (env ["warnings" ] == 'extra' ):
@@ -369,8 +370,7 @@ if selected_platform in platform_list:
369
370
'-Wduplicated-branches' , '-Wduplicated-cond' ,
370
371
'-Wstringop-overflow=4' , '-Wlogical-op' ])
371
372
env .Append (CXXFLAGS = ['-Wnoexcept' , '-Wplacement-new=1' ])
372
- version = methods .get_compiler_version (env )
373
- if version != None and version [0 ] >= '9' :
373
+ if version [0 ] >= 9 :
374
374
env .Append (CCFLAGS = ['-Wattribute-alias=2' ])
375
375
elif (env ["warnings" ] == 'all' ):
376
376
env .Append (CCFLAGS = ['-Wall' ] + shadow_local_warning )
Original file line number Diff line number Diff line change 1
1
import os
2
- import os .path
3
2
import re
4
3
import glob
5
4
import subprocess
@@ -626,14 +625,23 @@ def detect_darwin_sdk_path(platform, env):
626
625
raise
627
626
628
627
def get_compiler_version (env ):
629
- # Not using this method on clang because it returns 4.2.1 # https://reviews.llvm.org/D56803
630
- if using_gcc (env ):
631
- version = decode_utf8 (subprocess .check_output ([env ['CXX' ], '-dumpversion' ]).strip ())
632
- else :
633
- version = decode_utf8 (subprocess .check_output ([env ['CXX' ], '--version' ]).strip ())
634
- match = re .search ('[0-9][0-9.]*' , version )
628
+ """
629
+ Returns an array of version numbers as ints: [major, minor, patch].
630
+ The return array should have at least two values (major, minor).
631
+ """
632
+ if not env .msvc :
633
+ # Not using -dumpversion as some GCC distros only return major, and
634
+ # Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
635
+ try :
636
+ version = decode_utf8 (subprocess .check_output ([env .subst (env ['CXX' ]), '--version' ]).strip ())
637
+ except (subprocess .CalledProcessError , OSError ):
638
+ print ("Couldn't parse CXX environment variable to infer compiler version." )
639
+ return None
640
+ else : # TODO: Implement for MSVC
641
+ return None
642
+ match = re .search ('[0-9]+\.[0-9.]+' , version )
635
643
if match is not None :
636
- return match .group ().split ('.' )
644
+ return list ( map ( int , match .group ().split ('.' )) )
637
645
else :
638
646
return None
639
647
Original file line number Diff line number Diff line change @@ -180,15 +180,14 @@ def configure(env):
180
180
env .Append (LINKFLAGS = ['-pipe' ])
181
181
182
182
# Check for gcc version >= 6 before adding -no-pie
183
+ version = get_compiler_version (env ) or [- 1 , - 1 ]
183
184
if using_gcc (env ):
184
- version = get_compiler_version (env )
185
- if version != None and version [0 ] >= '6' :
185
+ if version [0 ] >= 6 :
186
186
env .Append (CCFLAGS = ['-fpie' ])
187
187
env .Append (LINKFLAGS = ['-no-pie' ])
188
188
# Do the same for clang should be fine with Clang 4 and higher
189
189
if using_clang (env ):
190
- version = get_compiler_version (env )
191
- if version != None and version [0 ] >= '4' :
190
+ if version [0 ] >= 4 :
192
191
env .Append (CCFLAGS = ['-fpie' ])
193
192
env .Append (LINKFLAGS = ['-no-pie' ])
194
193
You can’t perform that action at this time.
0 commit comments