diff options
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/python/cpython/default.nix')
-rw-r--r-- | nixpkgs/pkgs/development/interpreters/python/cpython/default.nix | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix b/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix index b8132cea4fc7..f52255f4748b 100644 --- a/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix +++ b/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix @@ -39,6 +39,13 @@ , includeSiteCustomize ? true , static ? stdenv.hostPlatform.isStatic , enableOptimizations ? false +# enableNoSemanticInterposition is a subset of the enableOptimizations flag that doesn't harm reproducibility. +# clang starts supporting `-fno-sematic-interposition` with version 10 +, enableNoSemanticInterposition ? (!stdenv.cc.isClang || (stdenv.cc.isClang && lib.versionAtLeast stdenv.cc.version "10")) +# 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 +# enabling LTO on *-darwin causes python3 to fail when linking. +, enableLTO ? stdenv.is64bit && stdenv.isLinux , reproducibleBuild ? true , pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}" }: @@ -100,6 +107,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 +199,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 +287,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 +338,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; |