-
Notifications
You must be signed in to change notification settings - Fork 4
/
rust-xtensa.nix
126 lines (111 loc) · 4.42 KB
/
rust-xtensa.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{pkgs}:
let
llvm-xtensa = (pkgs.callPackage ./llvm-xtensa.nix {});
lib = pkgs.lib;
lists = lib.lists;
fetchCargoTarball = pkgs.callPackage (pkgs.path + /pkgs/build-support/rust/fetchCargoTarball.nix) {};
toRustTarget = platform: with platform.parsed; let
cpu_ = {
"armv7a" = "armv7";
"armv7l" = "armv7";
"armv6l" = "arm";
}.${cpu.name} or platform.rustc.arch or cpu.name;
in platform.rustc.config
or "${cpu_}-${vendor.name}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";
# bootstrap
date = "2020-03-12";
# from rust-xtensa github
version = "1.44.0";
rustBinary = pkgs.callPackage (pkgs.path + /pkgs/development/compilers/rust/binary.nix) rec {
# Noted while installing out of band
# https://static.rust-lang.org/dist/2020-03-12/rust-std-beta-x86_64-unknown-linux-gnu.tar.xz
# https://static.rust-lang.org/dist/2020-03-12/rustc-beta-x86_64-unknown-linux-gnu.tar.xz
# https://static.rust-lang.org/dist/2020-03-12/cargo-beta-x86_64-unknown-linux-gnu.tar.xz
# https://static.rust-lang.org/dist/2020-01-31/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz
# noted by inspecting https://static.rust-lang.org/dist/2020-03-12
# version = "1.42.0";
# version = "nightly";
version = "beta";
platform = toRustTarget pkgs.stdenv.hostPlatform;
versionType = "bootstrap";
src = pkgs.fetchurl {
url = "https://static.rust-lang.org/dist/${date}/rust-${version}-${platform}.tar.gz";
# sha256 = "0llhg1xsyvww776d1wqaxaipm4f566hw1xyy778dhcwakjnhf7kx"; # 1.42.0
# sha256 = "0jhggcwr852c4cqb4qv9a9c6avnjrinjnyzgfi7sx7n1piyaad43"; # nightly
sha256 = "1cv402wp9dx6dqd9slc8wqsqkrb7kc66n0bkkmvgjx01n1jhv7n5"; # beta
};
};
bootstrapPlatform = pkgs.makeRustPlatform rustBinary;
src = pkgs.fetchFromGitHub {
owner = "MabezDev";
repo = "rust-xtensa";
# rust 1.42++
rev = "25ae59a82487b8249b05a78f00a3cc35d9ac9959";
fetchSubmodules = true;
sha256 = "1xr8rayvvinf1vahzfchlkpspa5f2nxic1j2y4dgdnnzb3rkvkg5";
};
in
rec {
rust-src = src;
rustc = (pkgs.rustc.override {
rustPlatform = bootstrapPlatform;
# override the rustc result attrs before calling
}).overrideAttrs ( old: rec {
pname = "rustc-xtensa";
inherit version src;
llvmSharedForBuild = llvm-xtensa;
llvmSharedForHost = llvm-xtensa;
llvmSharedForTarget = llvm-xtensa;
llvmShared = llvm-xtensa;
patches = [];
configureFlags =
(lists.remove "--enable-llvm-link-shared"
(lists.remove "--release-channel=stable" old.configureFlags)) ++ [
"--set=build.rustfmt=${pkgs.rustfmt}/bin/rustfmt"
"--llvm-root=${llvm-xtensa}"
"--experimental-targets=Xtensa"
# Nightly because xargo (which compiles a new core) can only build on nightly
# xargo replace with cargo xbuild
"--release-channel=nightly"
];
cargoDeps = fetchCargoTarball {
inherit pname;
inherit src;
sourceRoot = null;
srcs = null;
patches = [];
sha256 = "0z4mb33f72ik8a1k3ckbg3rf6p0403knx5mlagib0fs2gdswg9w5";
};
postConfigure = ''
${old.postConfigure}
unpackFile "$cargoDeps"
mv $(stripHash $cargoDeps) vendor
# export VERBOSE=1
'';
});
cargo = (pkgs.callPackage (pkgs.path + /pkgs/development/compilers/rust/cargo.nix) {
rustPlatform = bootstrapPlatform;
inherit (pkgs.darwin.apple_sdk.frameworks) Security CoreFoundation;
inherit rustc;
}).overrideAttrs(old: rec {
name = "cargo-xtensa-${version}";
inherit version src;
cargoDeps = fetchCargoTarball {
inherit name;
inherit src;
sourceRoot = null;
srcs = null;
patches = [];
sha256 = "1w5fz966vf09p87xbxc5pm9xq4f1gx8a2vj7fskx30skkwb97d13";
};
# cargoVendorDir = builtins.trace "${cargoDeps}" null;
postConfigure = ''
unpackFile "$cargoDeps"
mv $(stripHash $cargoDeps) vendor
# export VERBOSE=1
'';
});
rustPlatform = pkgs.makeRustPlatform {
inherit rustc cargo;
};
}