diff options
Diffstat (limited to 'pkgs/development/interpreters/python/cpython/default.nix')
-rw-r--r-- | pkgs/development/interpreters/python/cpython/default.nix | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index b8132cea4fc71..842d132fd44c7 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -39,6 +39,11 @@ , includeSiteCustomize ? true , static ? stdenv.hostPlatform.isStatic , enableOptimizations ? false +# enableNoSemanticInterposition is a subset of the enableOptimizations flag that doesn't harm reproducibility. +, enableNoSemanticInterposition ? true +# enableLTO is a subset of the enableOptimizations flag that doesn't harm reproducibility. +# enabling LTO on 32bit arch causes downstream packages to fail when linking +, enableLTO ? stdenv.is64bit , reproducibleBuild ? true , pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}" }: @@ -100,6 +105,8 @@ let ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc pythonForBuild + ] ++ optionals (stdenv.cc.isClang && enableLTO) [ + stdenv.cc.cc.libllvm.out ]; buildInputs = filter (p: p != null) ([ @@ -190,6 +197,10 @@ 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") + # Make sure that the virtualenv activation scripts are + # owner-writable, so venvs can be recreated without permission + # errors. + ./virtualenv-permissions.patch ] ++ optionals mimetypesSupport [ # Make the mimetypes module refer to the right file ./mimetypes.patch @@ -274,6 +285,8 @@ in with passthru; stdenv.mkDerivation { "--with-system-ffi" ] ++ optionals enableOptimizations [ "--enable-optimizations" + ] ++ optionals enableLTO [ + "--with-lto" ] ++ optionals (pythonOlder "3.7") [ # This is unconditionally true starting in CPython 3.7. "--with-threads" @@ -323,6 +336,17 @@ in with passthru; stdenv.mkDerivation { export DETERMINISTIC_BUILD=1; '' + optionalString stdenv.hostPlatform.isMusl '' export NIX_CFLAGS_COMPILE+=" -DTHREAD_STACK_SIZE=0x100000" + '' + + + # enableNoSemanticInterposition essentially sets that CFLAG -fno-semantic-interposition + # which changes how symbols are looked up. This essentially means we can't override + # libpython symbols via LD_PRELOAD anymore. This is common enough as every build + # that uses --enable-optimizations has the same "issue". + # + # The Fedora wiki has a good article about their journey towards enabling this flag: + # https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup + optionalString enableNoSemanticInterposition '' + export CFLAGS_NODIST="-fno-semantic-interposition" ''; setupHook = python-setup-hook sitePackages; |