Yashar Yashar -4 years ago 360
Linux Question

what does --enable-optimizations do while compiling python?

I'm trying to compile Python 3.6 on an arm based Linux machine,

outputs this:

If you want a release build with all optimizations active (LTO, PGO, etc),
please run
./configure --enable-optimizations

what does

Answer Source

This flag enables Profile guided optimization (PGO) and Link Time Optimization (LTO).

Both are expensive optimizations that slow down the build process but yield a significant speed boost (around 10-20% from what I remember reading).

The discussion of what these exactly do is beyond my knowledge and probably too broad for a single question. Either way, you can read a bit about the LTO implementation in gcc and, get a start by reading the wiki page on PGO.

Also, see these relevant issues opened on the Python Bug Tracker, that added these:

  1. Profile Guided Optimization improvements (better training, llvm support, etc) (Added PGO.)
  2. Link Time Optimizations support for GCC and CLANG (Added LTO.)
  3. CPython build options for out-of-the box performance (Adds the --enable-optimizations flag to the configure script which enables the aforementioned optimizations.)

As pointed out by @Shuo in a comment, LTO isn't always included with --enable-optimizations as stated in Issue 28032. Some platforms (depending on the supported version of gcc), don't have it enabled by default.

Future versions of this flag will probably always have it enabled though, so it's pretty safe to talk about them both here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download