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():
386
386
387
387
# --with-lto
388
388
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' )
393
394
394
395
if support .check_cflags_pgo ():
395
396
# PGO (--enable-optimizations)
Original file line number Diff line number Diff line change @@ -852,7 +852,7 @@ def python_is_optimized():
852
852
def check_cflags_pgo ():
853
853
# Check if Python was built with ./configure --enable-optimizations:
854
854
# 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 '' )
856
856
pgo_options = [
857
857
# GCC
858
858
'-fprofile-use' ,
@@ -867,13 +867,24 @@ def check_cflags_pgo():
867
867
return any (option in cflags_nodist for option in pgo_options )
868
868
869
869
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
+
870
881
def check_bolt_optimized ():
871
882
# Always return false, if the platform is WASI,
872
883
# because BOLT optimization does not support WASM binary.
873
884
if is_wasi :
874
885
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 )
877
888
878
889
879
890
Py_GIL_DISABLED = bool (sysconfig .get_config_var ('Py_GIL_DISABLED' ))
Original file line number Diff line number Diff line change 24
24
if support .check_cflags_pgo ():
25
25
raise unittest .SkipTest ("test_gdb is not reliable on PGO builds" )
26
26
27
+ if support .check_ldflags_lto ():
28
+ raise unittest .SkipTest ("test_gdb is not reliable on LTO builds" )
29
+
27
30
if support .check_bolt_optimized ():
28
31
raise unittest .SkipTest ("test_gdb is not reliable on BOLT optimized builds" )
29
32
Original file line number Diff line number Diff line change @@ -744,6 +744,11 @@ def test_get_signal_name(self):
744
744
self .assertEqual (support .get_signal_name (exitcode ), expected ,
745
745
exitcode )
746
746
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
+
747
752
# XXX -follows a list of untested API
748
753
# make_legacy_pyc
749
754
# 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