From 312e20a3121573cb0ed99f0ffe518810d853d74b Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 20 Jul 2024 21:32:38 -0400 Subject: [PATCH 1/3] darwin.stdenv: fix scons Python override This reduces the number of Python builds in the bootstrap to two: a minimal build and a normal build. Both have LTO disabled, which is required due to missing LLVM LTO libraries. This is necessary to correctly enable LTO builds in Python because it needs `llvm-ar` from `stdenv.cc.cc.libllvm`, which does not exist in the bootstrap. --- pkgs/stdenv/darwin/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index bc9ccd1b67aa..4a2055c25e00 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -547,6 +547,8 @@ in buildInputs = old.buildInputs or [ ] ++ [ self.darwin.CF ]; }); + scons = super.scons.override { python3Packages = self.python3Minimal.pkgs; }; + darwin = super.darwin.overrideScope (selfDarwin: superDarwin: { apple_sdk = superDarwin.apple_sdk // { inherit (prevStage.darwin.apple_sdk) sdkRoot; From 53f938e573ebdbf7fb0271ebbc4b810bda6cdf47 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 20 Jul 2024 21:33:28 -0400 Subject: [PATCH 2/3] python{310,311,312,313}: fix LTO build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Python LTO builds using clang require the clang’s `llvm-ar` even on Darwin. --- pkgs/development/interpreters/python/cpython/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index 15c32eee3d44..fa0f9496db38 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -158,7 +158,7 @@ let ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc pythonOnBuildForHost - ] ++ optionals (stdenv.cc.isClang && !stdenv.isDarwin && (!stdenv.hostPlatform.useAndroidPrebuilt or false) && (enableLTO || enableOptimizations)) [ + ] ++ optionals (stdenv.cc.isClang && (!stdenv.hostPlatform.useAndroidPrebuilt or false) && (enableLTO || enableOptimizations)) [ stdenv.cc.cc.libllvm.out ]; From 0e8dbe9540fdb84ac99cef53f61a1caabe016f78 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 21 Jul 2024 00:26:22 -0400 Subject: [PATCH 3/3] python313: drop patch for _PY_SHORT_FLOAT_REPR == 0 The patch was merged upstream and is included in Python 3.13b4. --- ...ix-build-with-_PY_SHORT_FLOAT_REPR-0.patch | 53 ------------------- .../interpreters/python/cpython/default.nix | 9 +--- 2 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 pkgs/development/interpreters/python/cpython/3.13/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch diff --git a/pkgs/development/interpreters/python/cpython/3.13/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch b/pkgs/development/interpreters/python/cpython/3.13/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch deleted file mode 100644 index 1c9f8b1c4335..000000000000 --- a/pkgs/development/interpreters/python/cpython/3.13/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 94d8a9efe6ec86a6e5b4806dbfb82ac926286456 Mon Sep 17 00:00:00 2001 -From: Yureka -Date: Sun, 30 Jun 2024 09:45:58 +0200 -Subject: [PATCH] Fix build with _PY_SHORT_FLOAT_REPR == 0 - ---- - Include/internal/pycore_dtoa.h | 10 +++------- - 1 file changed, 3 insertions(+), 7 deletions(-) - -diff --git a/Include/internal/pycore_dtoa.h b/Include/internal/pycore_dtoa.h -index c5cfdf4ce8..e4222c5267 100644 ---- a/Include/internal/pycore_dtoa.h -+++ b/Include/internal/pycore_dtoa.h -@@ -11,8 +11,6 @@ extern "C" { - #include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR - - --#if _PY_SHORT_FLOAT_REPR == 1 -- - typedef uint32_t ULong; - - struct -@@ -22,15 +20,15 @@ Bigint { - ULong x[1]; - }; - --#ifdef Py_USING_MEMORY_DEBUGGER -+#if defined(Py_USING_MEMORY_DEBUGGER) || _PY_SHORT_FLOAT_REPR == 0 - - struct _dtoa_state { - int _not_used; - }; --#define _dtoa_interp_state_INIT(INTERP) \ -+#define _dtoa_state_INIT(INTERP) \ - {0} - --#else // !Py_USING_MEMORY_DEBUGGER -+#else // !Py_USING_MEMORY_DEBUGGER && _PY_SHORT_FLOAT_REPR != 0 - - /* The size of the Bigint freelist */ - #define Bigint_Kmax 7 -@@ -66,8 +64,6 @@ extern char* _Py_dg_dtoa(double d, int mode, int ndigits, - int *decpt, int *sign, char **rve); - extern void _Py_dg_freedtoa(char *s); - --#endif // _PY_SHORT_FLOAT_REPR == 1 -- - - extern PyStatus _PyDtoa_Init(PyInterpreterState *interp); - extern void _PyDtoa_Fini(PyInterpreterState *interp); --- -2.45.1 - diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index fa0f9496db38..dd569db15358 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -366,15 +366,10 @@ in with passthru; stdenv.mkDerivation (finalAttrs: { }; in [ "${mingw-patch}/*.patch" - ]) ++ optionals (pythonAtLeast "3.12") [ + ]) ++ optionals isPy312 [ # backport fix for various platforms; armv7l, riscv64, s390 # https://github.com/python/cpython/pull/121178 - ( - if (pythonAtLeast "3.13") then - ./3.13/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch - else - ./3.12/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch - ) + ./3.12/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch ]; postPatch = optionalString (!stdenv.hostPlatform.isWindows) ''