1717import hashlib
1818import http .client
1919import urllib .request
20- from urllib .error import URLError
20+ import urllib .error
2121
2222
2323def error_exit (error_str , extra_info = None , exception = None ):
@@ -336,8 +336,6 @@ def detect_compiler_target(compiler):
336336 config_dict ['CC_VENDOR' ] = cc_vendor
337337 config_dict ['CC_VERSION' ] = cc_version
338338 if cc_vendor == 'gnu' :
339- if int (config_dict ['CC_VERSION' ].split ("." )[0 ]) > 9 :
340- config_dict ['BASE_FFLAGS' ] = "-fallow-argument-mismatch"
341339 config_dict ['OMP_FLAGS' ] = "-fopenmp"
342340 config_dict ['DEBUG_FLAGS' ] = "-g"
343341 config_dict ['CHK_FLAGS' ] = "-O0 -fcheck=all"
@@ -376,7 +374,8 @@ def detect_compiler_target(compiler):
376374
377375def build_cmake_script (mydict ,build_debug = False ,use_openmp = False ,build_python = False ,build_tests = False ,
378376 build_examples = False ,build_docs = False ,build_coverage = False ,package_build = False ,
379- package_release = False ,enable_debug_stack = False ,enable_profiling = False ):
377+ package_release = False ,enable_debug_stack = False ,enable_profiling = False ,
378+ use_lto = True ,debug_check_flags = True ,debug_asanitizer = False ):
380379 def bool_to_string (val ):
381380 if val :
382381 return "TRUE"
@@ -401,10 +400,13 @@ def bool_to_string(val):
401400 "-DOFT_BUILD_PYTHON:BOOL={0}" .format (bool_to_string (build_python )),
402401 "-DOFT_BUILD_DOCS:BOOL={0}" .format (bool_to_string (build_docs )),
403402 "-DOFT_USE_OpenMP:BOOL={0}" .format (bool_to_string (use_openmp )),
403+ "-DOFT_USE_LTO:BOOL={0}" .format (bool_to_string (use_lto )),
404404 "-DOFT_PACKAGE_BUILD:BOOL={0}" .format (bool_to_string (package_build )),
405405 "-DOFT_PACKAGE_NIGHTLY:BOOL={0}" .format (bool_to_string (not package_release )),
406406 "-DOFT_COVERAGE:BOOL={0}" .format (bool_to_string (build_coverage )),
407407 "-DOFT_DEBUG_STACK:BOOL={0}" .format (bool_to_string (enable_debug_stack )),
408+ "-DOFT_DEBUG_CHECK:BOOL={0}" .format (bool_to_string (debug_check_flags )),
409+ "-DOFT_DEBUG_SANITIZER:BOOL={0}" .format (bool_to_string (debug_asanitizer )),
408410 "-DOFT_PROFILING:BOOL={0}" .format (bool_to_string (enable_profiling )),
409411 "-DOFT_THINCURR_LEGACY:BOOL=FALSE" ,
410412 "-DCMAKE_C_COMPILER:FILEPATH={CC}" ,
@@ -639,10 +641,11 @@ def fetch(self, force=False, nretry=2):
639641 for i in range (nretry + 1 ):
640642 try :
641643 fetch_file (self .url , self .file )
642- except http .client .HTTPException :
644+ except ( urllib . error . URLError , http .client .HTTPException , OSError ) as e :
643645 if i == nretry :
644646 raise
645647 else :
648+ print (repr (e ))
646649 print ('Warning: Retrying download ({0}/{1})' .format (i + 1 ,nretry + 1 ))
647650 continue
648651 break
@@ -660,10 +663,11 @@ def fetch(self, force=False, nretry=2):
660663 for i in range (nretry + 1 ):
661664 try :
662665 fetch_file (url , tmp_file )
663- except http .client .HTTPException :
666+ except ( urllib . error . URLError , http .client .HTTPException , OSError ) as e :
664667 if i == nretry :
665668 raise
666669 else :
670+ print (repr (e ))
667671 print ('Warning: Retrying download ({0}/{1})' .format (i + 1 ,nretry + 1 ))
668672 continue
669673 break
@@ -2150,6 +2154,7 @@ def setup_build(self):
21502154group .add_argument ("--oft_build_debug" , default = 0 , type = int , choices = (0 ,1 ), help = "Build debug version of OFT? (default: 0)" )
21512155group .add_argument ("--oft_build_python" , default = 1 , type = int , choices = (0 ,1 ), help = "Build OFT Python libraries? (default: 1)" )
21522156group .add_argument ("--oft_use_openmp" , default = 1 , type = int , choices = (0 ,1 ), help = "Build OFT with OpenMP support? (default: 1)" )
2157+ group .add_argument ("--oft_use_lto" , default = 1 , type = int , choices = (0 ,1 ), help = "Build OFT with Link-Time Optimization? (default: 1)" )
21532158group .add_argument ("--oft_build_tests" , default = 0 , type = int , choices = (0 ,1 ), help = "Build OFT tests? (default: 0)" )
21542159group .add_argument ("--oft_py_kernel" , default = "python3" , type = str , help = "Name of Jupyter kernel for testing Python examples (default: python3)" )
21552160group .add_argument ("--oft_build_examples" , default = 0 , type = int , choices = (0 ,1 ), help = "Build OFT examples? (default: 0)" )
@@ -2158,6 +2163,8 @@ def setup_build(self):
21582163group .add_argument ("--oft_package_python" , default = 1 , type = int , choices = (0 ,1 ), help = "Setup for build of PYPI wheels when packaging?" )
21592164group .add_argument ("--oft_package_release" , action = "store_true" , default = False , help = "Perform a release package of OFT?" )
21602165group .add_argument ("--oft_build_coverage" , action = "store_true" , default = False , help = "Build OFT with code coverage flags?" )
2166+ group .add_argument ("--oft_debug_checks" , default = 1 , type = int , choices = (0 ,1 ), help = "Build OFT with compiler runtime checks (requires Debug build)? (default: 1)" )
2167+ group .add_argument ("--oft_debug_asanitizer" , default = 0 , type = int , choices = (0 ,1 ), help = "Build OFT with address sanitizer checks (requires Debug build)? (default: 0)" )
21612168group .add_argument ("--oft_debug_stack" , action = "store_true" , default = False , help = "Enable internal debug stack?" )
21622169group .add_argument ("--oft_profiling" , action = "store_true" , default = False , help = "Enable internal profiling?" )
21632170#
@@ -2373,4 +2380,7 @@ def setup_build(self):
23732380 package_release = options .oft_package_release ,
23742381 enable_debug_stack = options .oft_debug_stack ,
23752382 enable_profiling = options .oft_profiling ,
2383+ use_lto = (options .oft_use_lto == 1 ),
2384+ debug_check_flags = (options .oft_debug_checks == 1 ),
2385+ debug_asanitizer = (options .oft_debug_asanitizer == 1 )
23762386 )
0 commit comments