-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdefault.nix
More file actions
68 lines (66 loc) · 2.43 KB
/
default.nix
File metadata and controls
68 lines (66 loc) · 2.43 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
let
lib = import <nixpkgs/lib>;
in lib.makeOverridable (
{ pkgs ? import (fetchTarball {
# Currently latest nixpkgs 24.11
url = "https://github.com/NixOS/nixpkgs/archive/9c6b49aeac36e2ed73a8c472f1546f6d9cf1addc.tar.gz";
sha256 = "0zwnaiw6cryrvwxxa96f72p4w75wq2miyi066f2sk8n7ivj0kxcb";
}) {}
/**
<arg>cc</arg>: Compiler Collection used for compiling RISC-V binaries.
* **Type**: string
* **Default value**: `"gcc14"`
* **Available values**: Prefix of any nixpkgs-supported <u>xxx</u>Stdenv.
To list available <u>xxx</u>Stdenv:
```bash
nix-instantiate --eval -E 'let pkgs=import <nixpkgs> {}; in builtins.filter (x: pkgs.lib.hasSuffix "Stdenv" x)(builtins.attrNames pkgs)'
```
* **TODO**: Currently only supports GCC's stdenv.
LLVM's fortran compiler (flang) is needed to support Clang's stdenv.
Preliminary experiments with riscv64-jemalloc show that Clang provides better auto-vectorization than GCC.
*/
, cc ? "gcc14"
, ...
}@args:
assert pkgs.pkgsCross.riscv64 ? "${cc}Stdenv";
rec {
deterPkgs = pkgs.lib.makeScope pkgs.lib.callPackageWith (self: pkgs // {
riscv64-pkgs = pkgs.pkgsCross.riscv64;
riscv64-stdenv = self.riscv64-pkgs."${cc}Stdenv";
riscv64-cc = self.riscv64-stdenv.cc;
riscv64-fortran = self.riscv64-pkgs.wrapCCWith {
cc = self.riscv64-stdenv.cc.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
};
# fixup wrapped prefix, which only appear if hostPlatform!=targetPlatform
# for more details see <nixpkgs>/pkgs/build-support/cc-wrapper/default.nix
stdenvNoCC = self.riscv64-pkgs.stdenvNoCC.override {
hostPlatform = pkgs.stdenv.hostPlatform;
};
# Beginning from 24.05, wrapCCWith receive `runtimeShell`.
# If leave it empty, the default uses riscv64-pkgs.runtimeShell,
# thus executing the sheBang will throw error:
# `cannot execute: required file not found`.
runtimeShell = pkgs.runtimeShell;
};
rmExt = name: builtins.concatStringsSep "."
(pkgs.lib.init
(pkgs.lib.splitString "." name));
writeShScript = name: passthru: text: pkgs.writeTextFile {
inherit name;
text = ''
#!/usr/bin/env sh
${text}
'';
executable = true;
derivationArgs = { inherit passthru; };
};
utils = pkgs.callPackage ./utils.nix {};
});
build = deterPkgs.callPackage ./builders {} args;
}
)