Skip to content

Commit 4c81401

Browse files
octaviansoldeagpshead
authored andcommitted
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 b3ad0e5 commit 4c81401

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

‎Makefile.pre.in‎

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

465465
build_all_generate_profile:
466-
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
466+
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG)" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)"
467467

468468
run_profile_task:
469469
@ # FIXME: can't run for a cross build
@@ -473,7 +473,7 @@ build_all_merge_profile:
473473
$(LLVM_PROF_MERGER)
474474

475475
build_all_use_profile:
476-
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@"
476+
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG)" LDFLAGS="$(LDFLAGS)"
477477

478478
# Compile and run with gcov
479479
.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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,6 @@ LLVM_PROF_FILE
679679
LLVM_PROF_MERGER
680680
PGO_PROF_USE_FLAG
681681
PGO_PROF_GEN_FLAG
682-
LTOFLAGS
683682
DEF_MAKE_RULE
684683
DEF_MAKE_ALL_RULE
685684
ABIFLAGS
@@ -1511,8 +1510,8 @@ Optional Packages:
15111510
--with-suffix=.exe set executable suffix
15121511
--with-pydebug build with Py_DEBUG defined
15131512
--with-assertions build with C assertions enabled
1514-
--with-lto Enable Link Time Optimization in PGO builds.
1515-
Disabled by default.
1513+
--with-lto Enable Link Time Optimization in any build. Disabled
1514+
by default.
15161515
--with-hash-algorithm=[fnv|siphash24]
15171516
select hash algorithm
15181517
--with-address-sanitizer
@@ -6511,7 +6510,6 @@ else
65116510
fi
65126511

65136512
# Enable LTO flags
6514-
65156513
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-lto" >&5
65166514
$as_echo_n "checking for --with-lto... " >&6; }
65176515

@@ -6557,6 +6555,8 @@ if test "$Py_LTO" = 'true' ; then
65576555
esac
65586556
;;
65596557
esac
6558+
CFLAGS="$CFLAGS $LTOFLAGS"
6559+
LDFLAGS="$LDFLAGS $LTOFLAGS"
65606560
fi
65616561

65626562
# Enable PGO flags.

‎configure.ac‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,9 +1282,8 @@ else
12821282
fi
12831283

12841284
# Enable LTO flags
1285-
AC_SUBST(LTOFLAGS)
12861285
AC_MSG_CHECKING(for --with-lto)
1287-
AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]),
1286+
AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in any build. Disabled by default.]),
12881287
[
12891288
if test "$withval" != no
12901289
then
@@ -1319,6 +1318,8 @@ if test "$Py_LTO" = 'true' ; then
13191318
esac
13201319
;;
13211320
esac
1321+
CFLAGS="$CFLAGS $LTOFLAGS"
1322+
LDFLAGS="$LDFLAGS $LTOFLAGS"
13221323
fi
13231324

13241325
# Enable PGO flags.

0 commit comments

Comments
 (0)