mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-20 23:51:03 +00:00
Merge pull request #84072 from gnprice/python-build
cpython: Use optimizations, for a 25% speedup.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
, zlib
|
||||
, self
|
||||
, configd
|
||||
, autoreconfHook
|
||||
, python-setup-hook
|
||||
, nukeReferences
|
||||
# For the Python package set
|
||||
@@ -53,6 +54,7 @@ let
|
||||
version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoreconfHook
|
||||
nukeReferences
|
||||
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
buildPackages.stdenv.cc
|
||||
@@ -97,6 +99,31 @@ in with passthru; stdenv.mkDerivation {
|
||||
# (since it will do a futile invocation of gcc (!) to find
|
||||
# libuuid, slowing down program startup a lot).
|
||||
(./. + "/${sourceVersion.major}.${sourceVersion.minor}/no-ldconfig.patch")
|
||||
] ++ optionals stdenv.isLinux [
|
||||
# Optimize symbol tables for the sake of dynamic linking.
|
||||
# Significant for Python because of extension modules.
|
||||
(
|
||||
if pythonAtLeast "3.8" then
|
||||
fetchpatch {
|
||||
url = "https://salsa.debian.org/cpython-team/python3/-/raw/3.8.3rc1-1/debian/patches/link-opt.diff";
|
||||
sha256 = "0va85318nahnqgydwjs7723h8gx41inbdawdy6v4hiykzgc8s7vs";
|
||||
}
|
||||
else if isPy37 then
|
||||
fetchurl {
|
||||
url = "https://salsa.debian.org/cpython-team/python3/-/raw/3.7.6-1/debian/patches/link-opt.diff";
|
||||
sha256 = "1aqvsc0p3sxnfsi8jz7537wl6v95v26ba4nflwvmn5lxlc3y3g13";
|
||||
}
|
||||
else if isPy36 then
|
||||
fetchpatch {
|
||||
url = "https://salsa.debian.org/cpython-team/python3/-/raw/3.6.8-1/debian/patches/link-opt.diff";
|
||||
sha256 = "1nhdrgla75ily9gk7xx0crxa7ynqzks0djxk36sa3lgg5w8vjvyr";
|
||||
}
|
||||
else
|
||||
fetchpatch {
|
||||
url = "https://salsa.debian.org/cpython-team/python3/-/raw/27103a32e/debian/patches/link-opt.diff";
|
||||
sha256 = "0vp36276ndbrwr7882vg7vjd61c8mv7bqgal6bbh2fimp6zlkdhv";
|
||||
}
|
||||
)
|
||||
] ++ optionals (isPy35 || isPy36) [
|
||||
# Determinism: Write null timestamps when compiling python files.
|
||||
./3.5/force_bytecode_determinism.patch
|
||||
@@ -110,6 +137,14 @@ in with passthru; stdenv.mkDerivation {
|
||||
] ++ optionals (isPy37 || isPy38) [
|
||||
# Fix darwin build https://bugs.python.org/issue34027
|
||||
./3.7/darwin-libutil.patch
|
||||
] ++ optionals (pythonOlder "3.8") [
|
||||
# Backport from CPython 3.8 of a good list of tests to run for PGO.
|
||||
(
|
||||
if isPy36 || isPy37 then
|
||||
./3.6/profile-task.patch
|
||||
else
|
||||
./3.5/profile-task.patch
|
||||
)
|
||||
] ++ optionals (isPy3k && hasDistutilsCxxPatch) [
|
||||
# Fix for http://bugs.python.org/issue1222585
|
||||
# Upstream distutils is calling C compiler to compile C++ code, which
|
||||
@@ -141,11 +176,14 @@ in with passthru; stdenv.mkDerivation {
|
||||
PYTHONHASHSEED=0;
|
||||
|
||||
configureFlags = [
|
||||
"--enable-optimizations"
|
||||
"--enable-shared"
|
||||
"--with-threads"
|
||||
"--without-ensurepip"
|
||||
"--with-system-expat"
|
||||
"--with-system-ffi"
|
||||
] ++ optionals (pythonOlder "3.7") [
|
||||
# This is unconditionally true starting in CPython 3.7.
|
||||
"--with-threads"
|
||||
] ++ optionals (sqlite != null && isPy3k) [
|
||||
"--enable-loadable-sqlite-extensions"
|
||||
] ++ optionals (openssl != null) [
|
||||
|
||||
Reference in New Issue
Block a user