Skip to content

Commit 3beb95c

Browse files
octaviansoldeastratakis
authored andcommitted
[3.6] bpo-31354: Let configure --with-lto work on all builds
Allow configure --with-lto to apply to all builds, not just profile-opt builds. Whether this is actually useful or not must be determined by the person building CPython using their own toolchain. My own quick test on x86_64 Debian 9 (gcc 6.3, binutils 2.28) seemed to suggest that it wasn't, but I expect better toolchains can or will exist at some point. The point is to allow it at all.
1 parent 00093f6 commit 3beb95c

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

Makefile.pre.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ profile-opt:
473473
$(MAKE) profile-removal
474474

475475
build_all_generate_profile:
476-
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
476+
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG)" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)"
477477

478478
run_profile_task:
479479
: # FIXME: can't run for a cross build
@@ -483,7 +483,7 @@ build_all_merge_profile:
483483
$(LLVM_PROF_MERGER)
484484

485485
build_all_use_profile:
486-
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@"
486+
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG)" LDFLAGS="$(LDFLAGS)"
487487

488488
# Compile and run with gcov
489489
.PHONY=coverage coverage-lcov coverage-report
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow --with-lto to be used on all builds, not just `make profile-opt`.

configure

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ LLVM_PROF_FILE
681681
LLVM_PROF_MERGER
682682
PGO_PROF_USE_FLAG
683683
PGO_PROF_GEN_FLAG
684-
LTOFLAGS
685684
DEF_MAKE_RULE
686685
DEF_MAKE_ALL_RULE
687686
ABIFLAGS
@@ -1516,8 +1515,8 @@ Optional Packages:
15161515
--with-suffix=.exe set executable suffix
15171516
--with-pydebug build with Py_DEBUG defined
15181517
--with-assertions build with C assertions enabled
1519-
--with-lto Enable Link Time Optimization in PGO builds.
1520-
Disabled by default.
1518+
--with-lto Enable Link Time Optimization in any build. Disabled
1519+
by default.
15211520
--with-hash-algorithm=[fnv|siphash24]
15221521
select hash algorithm
15231522
--with-address-sanitizer
@@ -6584,7 +6583,6 @@ else
65846583
fi
65856584

65866585
# Enable LTO flags
6587-
65886586
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-lto" >&5
65896587
$as_echo_n "checking for --with-lto... " >&6; }
65906588

@@ -6637,6 +6635,9 @@ if test "$Py_LTO" = 'true' ; then
66376635
# to get debug symbols.
66386636
LTOFLAGS="$LTOFLAGS -g"
66396637
fi
6638+
6639+
CFLAGS="$CFLAGS $LTOFLAGS"
6640+
LDFLAGS="$LDFLAGS $LTOFLAGS"
66406641
fi
66416642

66426643
# Enable PGO flags.

configure.ac

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,8 @@ else
13101310
fi
13111311

13121312
# Enable LTO flags
1313-
AC_SUBST(LTOFLAGS)
13141313
AC_MSG_CHECKING(for --with-lto)
1315-
AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]),
1314+
AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in any build. Disabled by default.]),
13161315
[
13171316
if test "$withval" != no
13181317
then
@@ -1354,6 +1353,9 @@ if test "$Py_LTO" = 'true' ; then
13541353
# to get debug symbols.
13551354
LTOFLAGS="$LTOFLAGS -g"
13561355
fi
1356+
1357+
CFLAGS="$CFLAGS $LTOFLAGS"
1358+
LDFLAGS="$LDFLAGS $LTOFLAGS"
13571359
fi
13581360

13591361
# Enable PGO flags.

0 commit comments

Comments
 (0)