-
Notifications
You must be signed in to change notification settings - Fork 129
/
compilers-overlay.nix
106 lines (97 loc) · 3.94 KB
/
compilers-overlay.nix
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
# This overlays add a customStdenv attribute which provide an stdenv with
# different versions of the compilers. This can be used to test Gecko builds
# against different compiler settings, or different compiler versions.
#
# See release.nix "builder" function, to understand how these different stdenv
# are used.
self: super:
let
noSysDirs = (super.stdenv.system != "x86_64-darwin"
&& super.stdenv.system != "x86_64-freebsd"
&& super.stdenv.system != "i686-freebsd"
&& super.stdenv.system != "x86_64-kfreebsd-gnu");
crossSystem = null;
gcc473 = super.wrapCC (super.callPackage ./pkgs/gcc-4.7 (with self; {
inherit noSysDirs;
texinfo = texinfo4;
# I'm not sure if profiling with enableParallelBuilding helps a lot.
# We can enable it back some day. This makes the *gcc* builds faster now.
profiledCompiler = false;
# When building `gcc.crossDrv' (a "Canadian cross", with host == target
# and host != build), `cross' must be null but the cross-libc must still
# be passed.
cross = null;
libcCross = if crossSystem != null then libcCross else null;
libpthreadCross =
if crossSystem != null && crossSystem.config == "i586-pc-gnu"
then gnu.libpthreadCross
else null;
}));
# By default wrapCC keep the same header files, but NixOS is using the
# latest header files from GCC, which are not supported by clang, because
# clang implement a different set of locking primitives than GCC. This
# expression is used to wrap clang with a matching verion of the libc++.
maybeWrapClang = cc: cc;
/*
if cc ? clang
then clangWrapCC cc
else cc;
*/
clangWrapCC = llvmPackages:
let libcxx =
super.lib.overrideDerivation llvmPackages.libcxx (drv: {
# https://bugzilla.mozilla.org/show_bug.cgi?id=1277619
# https://llvm.org/bugs/show_bug.cgi?id=14435
patches = drv.patches ++ [ ./pkgs/clang/bug-14435.patch ];
});
in
super.callPackage <nixpkgs/pkgs/build-support/cc-wrapper> {
cc = llvmPackages.clang-unwrapped or llvmPackages.clang;
isClang = true;
stdenv = self.clangStdenv;
libc = self.glibc;
# cc-wrapper pulls gcc headers, which are not compatible with features
# implemented in clang. These packages are used to override that.
extraPackages = [ self.libcxx llvmPackages.libcxxabi ];
nativeTools = false;
nativeLibc = false;
};
buildWithCompiler = cc:
super.stdenvAdapters.overrideCC self.stdenv (maybeWrapClang cc);
chgCompilerSource = cc: name: src:
cc.override (conf:
if conf ? gcc then # Nixpkgs 14.12
{ gcc = super.lib.overrideDerivation conf.gcc (old: { inherit name src; }); }
else # Nixpkgs 15.05
{ cc = super.lib.overrideDerivation conf.cc (old: { inherit name src; }); }
);
compilersByName = with self; {
clang = llvmPackages.clang;
clang36 = llvmPackages_36.clang;
clang37 = llvmPackages_37.clang;
clang38 = llvmPackages_38.clang; # not working yet.
clang5 = llvmPackages_5.clang or llvmPackages.clang;
clang6 = llvmPackages_6.clang or llvmPackages.clang;
clang7 = llvmPackages_7.clang or llvmPackages.clang;
clang12 = llvmPackages_12.clang or llvmPackages.clang;
clang13 = llvmPackages_13.clang or llvmPackages.clang;
gcc = gcc;
gcc6 = gcc6;
gcc5 = gcc5;
gcc49 = gcc49;
gcc48 = gcc48;
gcc474 = chgCompilerSource gcc473 "gcc-4.7.4" (fetchurl {
url = "mirror://gnu/gcc/gcc-4.7.4/gcc-4.7.4.tar.bz2";
sha256 = "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj";
});
gcc473 = gcc473;
# Version used on Linux slaves, except Linux x64 ASAN.
gcc472 = chgCompilerSource gcc473 "gcc-4.7.2" (fetchurl {
url = "mirror://gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2";
sha256 = "115h03hil99ljig8lkrq4qk426awmzh0g99wrrggxf8g07bq74la";
});
};
in {
customStdenvs =
super.lib.mapAttrs (name: value: buildWithCompiler value) compilersByName;
}