-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.nix
More file actions
123 lines (111 loc) · 2.74 KB
/
python.nix
File metadata and controls
123 lines (111 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{
fetchFromGitHub,
callPackage,
runCommand,
lib,
python313,
openssl,
llvmPackages_19,
llvmPackages_20,
llvmPackages_18,
llvm_gh114990,
...
}:
let
src = fetchFromGitHub {
owner = "python";
repo = "cpython";
rev = "9211b3dabeacb92713ac3f5f0fa43bc7cf69afd8";
hash = "sha256-yKLUIgs/693+8xVB16zGl4O4UU/gQlmbW9N5UDUDksA=";
};
buildPython =
{ stdenv, python3 }:
stdenv.mkDerivation {
pname = "python";
version = "3.14";
src = src;
buildInputs = python3.buildInputs;
nativeBuildInputs = python3.nativeBuildInputs;
enableParallelBuilding = true;
configureFlags = [
"--with-openssl=${openssl.dev}"
];
};
notLLVM = l: builtins.filter (p: (p.pname or "") != "llvm") l;
withOpt =
opt: p:
p.overrideAttrs (
final: prev: {
configureFlags = (prev.configureFlags or [ ]) ++ [ opt ];
}
);
withTC = withOpt "--with-tail-call-interp";
withOptimizations = withOpt "--enable-optimizations";
withLTO = withOpt "--with-lto";
withLLVM = (
llvm: p:
(p.override ({
stdenv = llvm.stdenv;
})).overrideAttrs
(
final: prev: {
nativeBuildInputs = [ llvm.bintools ] ++ (notLLVM prev.nativeBuildInputs or [ ]);
}
)
);
noZeroCallUsed = (
p:
p.overrideAttrs {
hardeningDisable = [ "zerocallusedregs" ];
}
);
withTailDup = (
p:
p.overrideAttrs (
final: prev: {
preConfigure = ''
configureFlagsArray+=(
"OPT=-g -O3 -Wall -mllvm -tail-dup-pred-size=5000"
"LDFLAGS=-fuse-ld=lld -Wl,-mllvm -Wl,-tail-dup-pred-size=5000"
)
'';
}
)
);
builds = rec {
inherit src;
base = callPackage buildPython { python3 = python313; };
optimized = withOptimizations base;
optLTO = withLTO optimized;
clang18 = withLLVM llvmPackages_18 optLTO;
clang19 = withLLVM llvmPackages_19 optLTO;
clang20 = withLLVM llvmPackages_20 optLTO;
clang18nozero = noZeroCallUsed clang18;
clang19taildup = withTailDup clang19;
clang20taildup = withTailDup clang20;
clang19_gh114990 = withLLVM llvm_gh114990 optLTO;
clang19TC = withTC clang19;
clang20TC = withTC clang20;
clang19TCnozero = noZeroCallUsed clang19TC;
clang20TCnozero = noZeroCallUsed clang20TC;
clang19TCskipzero = clang19TC.overrideAttrs {
patches = [
./patches/skip-zero.patch
];
};
};
in
builds
// {
all =
let
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.strings) concatStringsSep;
in
runCommand "python-builds" { } (
''
mkdir -p $out
''
+ concatStringsSep "\n" (mapAttrsToList (k: v: "ln -nsf ${v} $out/${k}") builds)
);
}