-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a bunch of riscv-related packages #213222
Changes from all commits
3790bb8
1eedee1
353ba79
21b4685
3f9b190
ab24ccf
6369162
4230e35
27e9f60
7d8b0f0
76234cd
002982f
bd0320a
e2960e7
525b19b
e50a8b7
d20823e
5084ca9
a69397e
935f374
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,47 @@ | ||||||||||||||||||||||||||||||||||||||
{ stdenv | ||||||||||||||||||||||||||||||||||||||
, fetchFromGitHub | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
, arch | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
, ocamlPackages | ||||||||||||||||||||||||||||||||||||||
, ncurses | ||||||||||||||||||||||||||||||||||||||
, ocaml | ||||||||||||||||||||||||||||||||||||||
, zlib | ||||||||||||||||||||||||||||||||||||||
, z3 | ||||||||||||||||||||||||||||||||||||||
}: | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
stdenv.mkDerivation rec { | ||||||||||||||||||||||||||||||||||||||
pname = "sail-riscv"; | ||||||||||||||||||||||||||||||||||||||
version = "0.5"; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
nativeBuildInputs = with ocamlPackages; [ sail ocamlbuild findlib ncurses ocaml zlib.dev z3 ]; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
src = fetchFromGitHub { | ||||||||||||||||||||||||||||||||||||||
owner = "riscv"; | ||||||||||||||||||||||||||||||||||||||
repo = pname; | ||||||||||||||||||||||||||||||||||||||
rev = version; | ||||||||||||||||||||||||||||||||||||||
hash = "sha256-7PZNNUMaCZEBf0lOCqkquewRgZPooBOjIbGF7JlLnEo="; | ||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
ARCH = arch; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
outputs = [ "out" "ocaml_emu" "isabelle_model" "coq_model" "hol4_model" ]; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
preConfigure = "sed 's/^SAIL:=$(/SAIL:=sail #/' -i Makefile"; | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
SAIL_DIR = "${ocamlPackages.sail}/share/sail"; | ||||||||||||||||||||||||||||||||||||||
SAIL = "sail"; | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move these to |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
installPhase = '' | ||||||||||||||||||||||||||||||||||||||
runHook preInstall | ||||||||||||||||||||||||||||||||||||||
mkdir -p $out/bin | ||||||||||||||||||||||||||||||||||||||
cp c_emulator/riscv_sim_${arch} $out/bin | ||||||||||||||||||||||||||||||||||||||
mkdir -p $ocaml_emu/bin | ||||||||||||||||||||||||||||||||||||||
cp ocaml_emulator/riscv_ocaml_sim_${arch} $ocaml_emu/bin | ||||||||||||||||||||||||||||||||||||||
cp -r generated_definitions/coq/ $coq_model | ||||||||||||||||||||||||||||||||||||||
cp -r generated_definitions/isabelle/ $isabelle_model | ||||||||||||||||||||||||||||||||||||||
cp -r generated_definitions/hol4/ $hol4_model | ||||||||||||||||||||||||||||||||||||||
runHook postInstall | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+37
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these files extremely large or something? Keeping everything in $out is fine in most cases.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
''; | ||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ stdenv | ||
, lib | ||
, fetchFromGitHub | ||
, fetchurl | ||
|
||
, gcc12 | ||
, glibc | ||
, newlib | ||
, gdb | ||
, qemu | ||
, musl | ||
, spike | ||
, riscv-pk | ||
|
||
, autoconf | ||
, curl | ||
, automake | ||
, python3 | ||
, libmpc | ||
, gawk | ||
, bison | ||
, flex | ||
, texinfo | ||
, gperf | ||
, libtool | ||
, expat | ||
, gmp | ||
, mpfr | ||
, flock | ||
|
||
, srcs ? { | ||
binutils = { | ||
url = "mirror://gnu/binutils/binutils-2.39.tar.bz2"; | ||
hash = "sha256-2iSoT+8iAQLdJAQt8G/eqFHCYUpTd/hu/6KPM7exYUg="; | ||
}; | ||
dejagnu = { | ||
url = "mirror://gnu/dejagnu/dejagnu-1.6.3.tar.gz"; | ||
hash = "sha256-h9rvrNeVi0pp+IxoVtvRY0JhljxBQHnQw3H1ic1mouM="; | ||
}; | ||
gcc = { | ||
url = gcc12.cc.src.url; | ||
hash = gcc12.cc.src.outputHash; | ||
}; | ||
glibc = { | ||
url = glibc.src.url; | ||
hash = glibc.src.outputHash; | ||
}; | ||
newlib = { | ||
url = newlib.src.url; | ||
hash = "sha256-8pbjcvUTJCJNOHzBFtw3pr05cZh1Z0b5OisC6aXUAVQ="; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (same for spike and pk) Why override the hash here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original (newlib/spike/pk).src uses fetchurl, not fetchzip, so its just more convenient There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However the url could change as the versions are updated, these override would slowly rotten. |
||
}; | ||
gdb = { | ||
url = gdb.src.url; | ||
hash = gdb.src.outputHash; | ||
}; | ||
qemu = { | ||
url = qemu.src.url; | ||
hash = qemu.src.outputHash; | ||
}; | ||
musl = { | ||
url = musl.src.url; | ||
hash = musl.src.outputHash; | ||
}; | ||
spike = { | ||
url = spike.src.url; | ||
hash = "sha256-mynCIP7R6GfjvqS1xWXyYpI31SWk2f4WaGmcRAYAOh8="; | ||
}; | ||
pk = { | ||
url = riscv-pk.src.url; | ||
hash = "sha256-Rf6ACDD0WptZK6XU/bdDo+TCEmZT+DTZBKXKuScQf/Y="; | ||
}; | ||
} | ||
|
||
, isa ? "rv64gc" | ||
, withLinux ? false | ||
}: | ||
with lib; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Globally scoped |
||
let | ||
|
||
extract = file: stdenv.mkDerivation { | ||
name = file.name + "-unpacked"; | ||
src = file; | ||
dontPatch = true; | ||
dontConfigure = true; | ||
dontBuild = true; | ||
installPhase = "cp -r . $out"; | ||
dontFixup = true; | ||
}; | ||
|
||
srcs_fetched = mapAttrs (name: value: if value ? outPath then value else fetchurl value) srcs; | ||
srcs_extracted = mapAttrs (name: value: extract value) srcs_fetched; | ||
srcFlags = mapAttrsToList (name: value: "--with-${name}-src=${value}") srcs_extracted; | ||
|
||
in stdenv.mkDerivation rec { | ||
pname = "riscv-gnu-toolchain-" + isa; | ||
version = "2023.01.04"; | ||
|
||
buildInputs = [ autoconf automake flock curl python3 libmpc gawk bison flex texinfo gperf libtool expat.dev gmp.dev mpfr.dev ]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous comment on |
||
hardeningDisable = [ "format" ]; | ||
|
||
patches = [ ./nodotgit.patch ]; | ||
configureFlags = [ | ||
"--with-arch=${isa}" | ||
] ++ | ||
srcFlags ++ | ||
optional withLinux "--enable-linux"; | ||
|
||
preConfigure = '' | ||
patchShebangs . | ||
''; | ||
|
||
src = fetchFromGitHub { | ||
owner = "riscv-collab"; | ||
repo = pname; | ||
rev = version; | ||
hash = "sha256-PXPQ/ho+fOudZRErnyQZTVFdceWGBF+geo+3y0tkNm4="; | ||
}; | ||
|
||
meta = with lib; { | ||
homepage = "https://github.com/riscv-collab/riscv-gnu-toolchain"; | ||
description = "RISC-V C and C++ cross-compiler"; | ||
maintainers = with maintainers; [ genericnerdyusername ]; | ||
license = with licenses; [ bsd3 gpl2 lgpl21 ]; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/Makefile.in b/Makefile.in | ||
index 09c5772..a988d0d 100644 | ||
--- a/Makefile.in | ||
+++ b/Makefile.in | ||
@@ -279,9 +279,7 @@ GCCPKGVER := | ||
endif | ||
|
||
$(srcdir)/%/.git: | ||
- cd $(srcdir) && \ | ||
- flock `git rev-parse --git-dir`/config git submodule init $(dir $@) && \ | ||
- flock `git rev-parse --git-dir`/config git submodule update $(dir $@) | ||
+ true | ||
|
||
# | ||
# GLIBC |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ stdenv | ||
, fetchFromGitHub | ||
, lib | ||
, ncurses | ||
, makeWrapper | ||
|
||
, ocamlbuild | ||
, findlib | ||
, ocaml | ||
, num | ||
, zarith | ||
}: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "lem"; | ||
version = "2022-12-10"; | ||
|
||
minimalOCamlVersion = "4.07"; | ||
|
||
nativeBuildInputs = [ makeWrapper ocamlbuild findlib ocaml ]; | ||
buildInputs = [ ncurses num ]; | ||
propagatedBuildInputs = [ zarith ]; | ||
|
||
installFlags = "INSTALL_DIR=$(out)"; | ||
|
||
preInstall = "mkdir -p $OCAMLFIND_DESTDIR"; | ||
postInstall = '' | ||
mv $out/bin/lem $out/bin/.lem_wrapped | ||
makeWrapper $out/bin/.lem_wrapped $out/bin/lem --set LEMLIB $out/share/lem/library | ||
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
''; | ||
|
||
src = fetchFromGitHub { | ||
owner = "rems-project"; | ||
repo = pname; | ||
rev = version; | ||
hash = "sha256-ZQgcuIVRkJS0KtpzjbO4OPHGg6B0TadWA6XpRir30y8="; | ||
}; | ||
|
||
|
||
meta = with lib; { | ||
homepage = "https://github.com/rems-project/lem"; | ||
description = "A tool for lightweight executable mathematics"; | ||
maintainers = with maintainers; [ genericnerdyusername ]; | ||
license = with licenses; [ bsd3 gpl2 ]; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ lib | ||
, fetchFromGitHub | ||
, stdenv | ||
|
||
, findlib | ||
, ocaml | ||
, lem | ||
, num | ||
}: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "linksem"; | ||
version = "0.8"; | ||
|
||
minimalOCamlVersion = "4.06"; | ||
|
||
nativeBuildInputs = [ findlib ocaml ]; | ||
buildInputs = [ lem num ]; | ||
|
||
preInstall = "mkdir -p $OCAMLFIND_DESTDIR"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "rems-project"; | ||
repo = pname; | ||
rev = version; | ||
hash = "sha256-7/YfDK3TruKCckMzAPLRrwBkHRJcX1S+AzXHWRxkZPA="; | ||
}; | ||
|
||
meta = with lib; { | ||
homepage = "https://github.com/rems-project/linksem"; | ||
description = "Linksem is a formalisation of substantial parts of ELF linking and DWARF debug information"; | ||
maintainers = with maintainers; [ genericnerdyusername ]; | ||
license = licenses.bsd2; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ lib | ||
, fetchFromGitHub | ||
, buildDunePackage | ||
|
||
, base64 | ||
, omd | ||
, menhir | ||
, ott | ||
, linenoise | ||
, dune-site | ||
, pprint | ||
, makeWrapper | ||
, lem | ||
, z3 | ||
, linksem | ||
, num | ||
}: | ||
|
||
buildDunePackage rec { | ||
pname = "sail"; | ||
version = "0.15"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "rems-project"; | ||
repo = "sail"; | ||
rev = version; | ||
hash = "sha256-eNdFOSzkniNvSCZeORRJ/IYAu+9P4HSouwmhd4BQLPk="; | ||
}; | ||
|
||
duneVersion = "3"; | ||
minimalOCamlVersion = "4.08"; | ||
|
||
SAIL_DIR = "$out"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be moved to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which part in the project need this ? maybe their is a better way. |
||
|
||
nativeBuildInputs = [ base64 omd menhir ott linenoise dune-site pprint makeWrapper ]; | ||
|
||
propagatedBuildInputs = [ lem z3 linksem num ]; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
rm -r aarch* # Remove code derived from non-bsd2 arm spec | ||
rm -r snapshots # Some of this might be derived from stuff in the aarch dir, it builds fine without it | ||
Comment on lines
+41
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not define it un preBuild hook ? since you rewrite a part of buildDunePackage |
||
dune build --release ''${enableParallelBuild:+-j $NIX_BUILD_CORES} | ||
runHook postBuild | ||
''; | ||
checkPhase = '' | ||
runHook preCheck | ||
dune runtest ''${enableParallelBuild:+-j $NIX_BUILD_CORES} | ||
runHook postCheck | ||
''; | ||
installPhase = '' | ||
runHook preInstall | ||
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR | ||
runHook postInstall | ||
''; | ||
Comment on lines
+39
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like these should have been handled by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
postInstall = '' | ||
mv $out/bin/sail $out/bin/.sail_wrapped | ||
makeWrapper $out/bin/.sail_wrapped $out/bin/sail --set SAIL_DIR $out/share/sail | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
''; | ||
|
||
meta = with lib; { | ||
homepage = "https://github.com/rems-project/sail"; | ||
description = "Sail is a language for describing the instruction-set architecture (ISA) semantics of processors"; | ||
maintainers = with maintainers; [ genericnerdyusername ]; | ||
license = licenses.bsd2; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ buildPythonPackage | ||
, mbstrdecoder | ||
, typepy | ||
|
||
, fetchFromGitHub | ||
, lib | ||
}: | ||
|
||
buildPythonPackage rec { | ||
pname = "dataproperty"; | ||
version = "0.55.0"; | ||
|
||
propagatedBuildInputs = [ mbstrdecoder typepy ]; | ||
doCheck = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why disabling test ? |
||
|
||
src = fetchFromGitHub { | ||
owner = "thombashi"; | ||
repo = pname; | ||
rev = "v${version}"; | ||
hash = "sha256-ODSrKZ8M/ni9r2gkVIKWaKkdr+3AVi4INkEKJ+cmb44="; | ||
}; | ||
|
||
meta = with lib; { | ||
homepage = "https://github.com/thombashi/dataproperty"; | ||
description = "A Python library for extract property from data"; | ||
maintainers = with maintainers; [ genericnerdyusername ]; | ||
license = licenses.mit; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use
zlib.dev
here,zlib
is enough, stdenv automatically selects the correct output. Also only compilers/tools should reside innativeBuildInputs
, libraries should be inbuildInputs
. You may setstrictDeps = true;
to make sure everything is correctly located.