gpt4 book ai didi

python - 编译 python 时 --enable-optimizations 做了什么?

转载 作者:IT老高 更新时间:2023-10-28 12:36:30 28 4
gpt4 key购买 nike

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

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

--enable-optimizations 是做什么的?

最佳答案

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

两者都是昂贵的优化,会减慢构建过程,但会显着提高速度(我记得读过的内容大约提高了 10-20%)。

关于这些究竟做了什么的讨论超出了我的知识范围,对于一个问题来说可能过于宽泛。无论哪种方式,您都可以从 the docs on GCC which has an implementation for it 中了解一些有关 LTO 的信息。并通过阅读 its wiki page 开始使用 PGO .

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

  • Issue 24915 :Profile Guided Optimization 改进(更好的培训、llvm 支持等)(添加了 PGO。)
  • Issue 25702 :对 GCC 和 CLANG 的链接时间优化支持(添加了 LTO。)
  • Issue 26359 : 开箱即用的 CPython 构建选项(将 --enable-optimizations 标志添加到启用上述优化的配置脚本中。)

正如@Shuo 在评论中指出并在 Issue 28032 中所述, LTO 并非总是 使用 --enable-optimizations 标志启用。某些平台(depending on the supported version of gcc)会在配置脚本中禁用它。

这个标志的 future 版本可能会一直启用它,所以在这里讨论它们是很安全的。

关于python - 编译 python 时 --enable-optimizations 做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41405728/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com