--enable-optimizations在编译python时会做什么? [英] what does --enable-optimizations do while compiling python?

查看:683
本文介绍了--enable-optimizations在编译python时会做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在基于arm的Linux机器上编译Python 3.6, ./configure输出以下内容:

I'm trying to compile Python 3.6 on an arm based Linux machine, ./configure outputs this:

如果您希望发布的版本具有所有优化功能(LTO,PGO等)处于活动状态, 请运行./configure --enable-optimizations.

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

--enable-optimizations做什么?

推荐答案

此标志启用配置文件引导的优化(PGO)和链接时间优化(LTO).

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

这都是昂贵的优化,它们会减慢构建过程,但会显着提高速度(我记得阅读的内容大约有10-20%).

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

这些确切功能的讨论超出了我的理解,可能对于一个问题来说范围太广.无论哪种方式,您都可以从有关GCC的文档中了解一些有关LTO的信息.实现并通过阅读其Wiki页面开始使用PGO.

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 LTO from the the docs on GCC which has an implementation for it and get a start on PGO by reading its wiki page.

此外,请参阅在添加了这些功能的Python Bug Tracker上打开的相关问题:

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

  • 问题24915 :配置文件引导的优化改进(更好的培训,llvm支持等)(已添加PGO.)
  • 问题25702 :对GCC和CLANG的链接时间优化支持(已添加LTO.)
  • 问题26359 : CPython构建用于实现即席即用性能的选项(将--enable-optimizations标志添加到配置脚本中,以启用上述优化.)
  • Issue 24915: Profile Guided Optimization improvements (better training, llvm support, etc) (Added PGO.)
  • Issue 25702: Link Time Optimizations support for GCC and CLANG (Added LTO.)
  • Issue 26359: CPython build options for out-of-the box performance (Adds the --enable-optimizations flag to the configure script which enables the aforementioned optimizations.)

@Shuo在评论中指出并在问题28032 中指出,LTO是"t始终使用--enable-optimizations标志启用 .某些平台(取决于gcc 的受支持版本)会在配置脚本中将其禁用.

As pointed out by @Shuo in a comment and stated in Issue 28032, LTO isn't always enabled with the --enable-optimizations flag. Some platforms (depending on the supported version of gcc) will disable it in the configuration script.

此标志的未来版本可能始终会启用它,因此在这里讨论它们都是很安全的.

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

这篇关于--enable-optimizations在编译python时会做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆