File tree Expand file tree Collapse file tree 5 files changed +29
-7
lines changed
Expand file tree Collapse file tree 5 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -386,10 +386,11 @@ def get_build_info():
386386
387387 # --with-lto
388388 optimizations = []
389- if '-flto=thin' in ldflags_nodist :
390- optimizations .append ('ThinLTO' )
391- elif '-flto' in ldflags_nodist :
392- optimizations .append ('LTO' )
389+ if support .check_ldflags_lto ():
390+ if '-flto=thin' in ldflags_nodist :
391+ optimizations .append ('ThinLTO' )
392+ else :
393+ optimizations .append ('LTO' )
393394
394395 if support .check_cflags_pgo ():
395396 # PGO (--enable-optimizations)
Original file line number Diff line number Diff line change @@ -852,7 +852,7 @@ def python_is_optimized():
852852def check_cflags_pgo ():
853853 # Check if Python was built with ./configure --enable-optimizations:
854854 # with Profile Guided Optimization (PGO).
855- cflags_nodist = sysconfig .get_config_var ('PY_CFLAGS_NODIST' ) or ''
855+ cflags_nodist = ( sysconfig .get_config_var ('PY_CFLAGS_NODIST' ) or '' )
856856 pgo_options = [
857857 # GCC
858858 '-fprofile-use' ,
@@ -867,13 +867,24 @@ def check_cflags_pgo():
867867 return any (option in cflags_nodist for option in pgo_options )
868868
869869
870+ def check_ldflags_lto ():
871+ # Check if Python was built with ./configure --with-lto:
872+ # with Link Time Optimization (PGO).
873+ ldflags_nodist = (sysconfig .get_config_var ('PY_LDFLAGS_NODIST' ) or '' )
874+ lto_options = {
875+ '-flto' ,
876+ '-flto=thin' ,
877+ }
878+ return any (option in ldflags_nodist for option in lto_options )
879+
880+
870881def check_bolt_optimized ():
871882 # Always return false, if the platform is WASI,
872883 # because BOLT optimization does not support WASM binary.
873884 if is_wasi :
874885 return False
875- config_args = sysconfig .get_config_var ('CONFIG_ARGS' ) or ''
876- return '--enable-bolt' in config_args
886+ config_args = ( sysconfig .get_config_var ('CONFIG_ARGS' ) or '' )
887+ return ( '--enable-bolt' in config_args )
877888
878889
879890Py_GIL_DISABLED = bool (sysconfig .get_config_var ('Py_GIL_DISABLED' ))
Original file line number Diff line number Diff line change 2424if support .check_cflags_pgo ():
2525 raise unittest .SkipTest ("test_gdb is not reliable on PGO builds" )
2626
27+ if support .check_ldflags_lto ():
28+ raise unittest .SkipTest ("test_gdb is not reliable on LTO builds" )
29+
2730if support .check_bolt_optimized ():
2831 raise unittest .SkipTest ("test_gdb is not reliable on BOLT optimized builds" )
2932
Original file line number Diff line number Diff line change @@ -744,6 +744,11 @@ def test_get_signal_name(self):
744744 self .assertEqual (support .get_signal_name (exitcode ), expected ,
745745 exitcode )
746746
747+ def test_compiler_flags (self ):
748+ self .assertIsInstance (support .check_cflags_pgo (), bool )
749+ self .assertIsInstance (support .check_ldflags_lto (), bool )
750+ self .assertIsInstance (support .check_bolt_optimized (), bool )
751+
747752 # XXX -follows a list of untested API
748753 # make_legacy_pyc
749754 # is_resource_enabled
Original file line number Diff line number Diff line change 1+ Skip test_gdb if Python is built with Link Time Optimization (LTO). Patch by
2+ Victor Stinner.
You can’t perform that action at this time.
0 commit comments