From: stratakis Date: Wed, 7 Nov 2018 22:05:13 +0000 (+0100) Subject: [3.6] bpo-31354: Let configure --with-lto work on all builds (GH-10261) X-Git-Tag: v3.6.8rc1~131 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6b9459996f5166300982d0427119eb326e74dac;p=thirdparty%2FPython%2Fcpython.git [3.6] bpo-31354: Let configure --with-lto work on all builds (GH-10261) 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. --- diff --git a/Makefile.pre.in b/Makefile.pre.in index d912a19e79f5..82f7edd1014c 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -473,7 +473,7 @@ profile-opt: $(MAKE) profile-removal build_all_generate_profile: - $(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)" + $(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG)" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)" run_profile_task: : # FIXME: can't run for a cross build @@ -483,7 +483,7 @@ build_all_merge_profile: $(LLVM_PROF_MERGER) build_all_use_profile: - $(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@" + $(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG)" LDFLAGS="$(LDFLAGS)" # Compile and run with gcov .PHONY=coverage coverage-lcov coverage-report diff --git a/Misc/NEWS.d/next/Build/2017-09-08-11-48-11.bpo-31354.4f-VJK.rst b/Misc/NEWS.d/next/Build/2017-09-08-11-48-11.bpo-31354.4f-VJK.rst new file mode 100644 index 000000000000..b63c9ea6e01f --- /dev/null +++ b/Misc/NEWS.d/next/Build/2017-09-08-11-48-11.bpo-31354.4f-VJK.rst @@ -0,0 +1 @@ +Allow --with-lto to be used on all builds, not just `make profile-opt`. diff --git a/configure b/configure index bfa4b83cd6c0..75a80a797d34 100755 --- a/configure +++ b/configure @@ -681,7 +681,6 @@ LLVM_PROF_FILE LLVM_PROF_MERGER PGO_PROF_USE_FLAG PGO_PROF_GEN_FLAG -LTOFLAGS DEF_MAKE_RULE DEF_MAKE_ALL_RULE ABIFLAGS @@ -1516,8 +1515,8 @@ Optional Packages: --with-suffix=.exe set executable suffix --with-pydebug build with Py_DEBUG defined --with-assertions build with C assertions enabled - --with-lto Enable Link Time Optimization in PGO builds. - Disabled by default. + --with-lto Enable Link Time Optimization in any build. Disabled + by default. --with-hash-algorithm=[fnv|siphash24] select hash algorithm --with-address-sanitizer @@ -6584,7 +6583,6 @@ else fi # Enable LTO flags - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-lto" >&5 $as_echo_n "checking for --with-lto... " >&6; } @@ -6637,6 +6635,9 @@ if test "$Py_LTO" = 'true' ; then # to get debug symbols. LTOFLAGS="$LTOFLAGS -g" fi + + CFLAGS="$CFLAGS $LTOFLAGS" + LDFLAGS="$LDFLAGS $LTOFLAGS" fi # Enable PGO flags. diff --git a/configure.ac b/configure.ac index 3f2459ab7100..b411c3e8f6f1 100644 --- a/configure.ac +++ b/configure.ac @@ -1310,9 +1310,8 @@ else fi # Enable LTO flags -AC_SUBST(LTOFLAGS) AC_MSG_CHECKING(for --with-lto) -AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]), +AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in any build. Disabled by default.]), [ if test "$withval" != no then @@ -1354,6 +1353,9 @@ if test "$Py_LTO" = 'true' ; then # to get debug symbols. LTOFLAGS="$LTOFLAGS -g" fi + + CFLAGS="$CFLAGS $LTOFLAGS" + LDFLAGS="$LDFLAGS $LTOFLAGS" fi # Enable PGO flags.