Skip to content

Commit

Permalink
added llvm-translator derivations.
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinafyi committed Sep 18, 2023
1 parent db16759 commit 915aa7e
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 25 deletions.
51 changes: 51 additions & 0 deletions llvm-translator/alive2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{ stdenv,
lib,
fetchpatch,
fetchFromGitHub,
cmake, ninja, git, z3, re2c, zlib, ncurses,
llvm-rtti-eh
}:

stdenv.mkDerivation rec {
pname = "alive2";
version = "2022-10-26";

src = fetchFromGitHub {
owner = "AliveToolkit";
repo = "alive2";
rev = "bc51b72cf5773967fd29155f1ffb251df4d5e94e";
sha256 = "sha256-qPH6+QL7X4bUlOwUWWgyQWz+iPNeytGxUp3eG1tKXn0=";
leaveDotGit = true;
};

patchFile = fetchpatch {
url = "https://github.com/AliveToolkit/alive2/commit/9a7504a99972e2c613deacaa8a4f1798829d2ff2.patch";
hash = "sha256-6hvG89H0vQBO8SdN76PuphJz4sXSbDImqFtJNCTFetI=";
};

nativeBuildInputs = [ cmake ninja git re2c ];
buildInputs = [ z3 zlib ncurses ];

cmakeFlags = [ "-DBUILD_TV=1" "-DLLVM_DIR=${llvm-rtti-eh.dev}/lib/cmake/llvm" ];

patchPhase = ''
runHook prePatch
patch --verbose -p1 -u < ${patchFile}
runHook postPatch
'';

installPhase = ''
runHook preInstall
ninja install
mkdir -p $out/bin
for f in *; do
if [[ -x $f ]] && [[ ! -d $f ]]; then
cp -v $f $out/bin/$f
fi
done
runHook postInstall
'';
}
32 changes: 32 additions & 0 deletions llvm-translator/asl-translator.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ lib,
fetchFromGitHub,
ocaml,
pkgs,
ocamlPackages,
llvmPackages_14,
asli,
z3
}:

let ocaml-llvm = ocamlPackages.llvm.override { libllvm = llvmPackages_14.libllvm; };
in ocamlPackages.buildDunePackage rec {
pname = "asl-translator";
version = "unstable-2023-09-18";

buildInputs = [ z3 ];
propagatedBuildInputs = [ asli ocaml-llvm ];

src = fetchFromGitHub {
owner = "UQ-PAC";
repo = "llvm-translator";
rev = "d86b20f98c0bbe445059b54812cbb15ecb4be67f";
sha256 = "sha256-4mB+z/tnE6ghX3Kj0ZUbJHQeU5lz4fVOtADXgcjcRxg=";
};
sourceRoot = "source/asl-translator";

meta = {
homepage = "https://github.com/UQ-PAC/llvm-translator";
description = "llvm-translator for comparison of lifter outputs (asl-translator component).";
maintainers = [ "Kait Lam <[email protected]>" ];
};
}
10 changes: 10 additions & 0 deletions llvm-translator/llvm-rtti-eh.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ llvmPackages_15 }:

llvmPackages_15.libllvm.overrideAttrs (final: prev: {
cmakeFlags = prev.cmakeFlags ++ [
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_ENABLE_EH=ON"
"-DLLVM_TARGETS_TO_BUILD=X86;AArch64;ARM"
];
doCheck = false;
})
5 changes: 5 additions & 0 deletions llvm-translator/retdec-tools.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ retdec }:

retdec.overrideAttrs (final: prev: {
cmakeFlags = prev.cmakeFlags ++ [ "-DRETDEC_DEV_TOOLS=1" ];
})
52 changes: 34 additions & 18 deletions overlay.nix
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
final: prev:
{
asli = (prev.callPackage ./asli.nix {})
# .overrideAttrs { src = prev.lib.cleanSource ~/progs/aslp; }
;
let
sbt-drv-repo = builtins.fetchTarball {
url = "https://github.com/zaninime/sbt-derivation/archive/master.tar.gz";
};
sbt-drv-overlay = import "${sbt-drv-repo}/overlay.nix";

aslp = prev.callPackage ./aslp.nix {};
overlay = final: prev:
{
asli = (prev.callPackage ./asli.nix {})
# .overrideAttrs { src = prev.lib.cleanSource ~/progs/aslp; }
;

bap-asli-plugin = (prev.callPackage ./bap-asli-plugin.nix {})
# .overrideAttrs { src = prev.lib.cleanSource ~/progs/bap-asli-plugin; }
;
aslp = prev.callPackage ./aslp.nix {};

bap-plugins = prev.callPackage ./bap-plugins.nix {};
bap-asli-plugin = (prev.callPackage ./bap-asli-plugin.nix {})
# .overrideAttrs { src = prev.lib.cleanSource ~/progs/bap-asli-plugin; }
;

bap-aslp = prev.callPackage ./bap-aslp.nix {};
bap-plugins = prev.callPackage ./bap-plugins.nix {};

bap-uq-pac = prev.callPackage ./bap-uq-pac.nix {};
bap-aslp = prev.callPackage ./bap-aslp.nix {};

basil = (prev.callPackage ./basil.nix {})
# .overrideAttrs { src = prev.lib.cleanSource ~/progs/basil; }
;
bap-uq-pac = prev.callPackage ./bap-uq-pac.nix {};

jre = final.temurin-jre-bin-17;
jdk = final.temurin-bin-17;
}
basil = (prev.callPackage ./basil.nix {})
# .overrideAttrs { src = prev.lib.cleanSource ~/progs/basil; }
;

jre = final.temurin-jre-bin-17;
jdk = final.temurin-bin-17;


# llvm-translator packages
asl-translator = prev.callPackage ./llvm-translator/asl-translator.nix {};
retdec-tools = prev.callPackage ./llvm-translator/retdec-tools.nix {};
llvm-rtti-eh = prev.callPackage ./llvm-translator/llvm-rtti-eh.nix {};
alive2 = prev.callPackage ./llvm-translator/alive2.nix {};

};
in final: prev:
prev.lib.composeExtensions sbt-drv-overlay overlay final prev
8 changes: 1 addition & 7 deletions pkgs.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
{ system ? builtins.currentSystem, overlays ? [] }:
let
sbt-drv-repo = builtins.fetchTarball {
url = "https://github.com/zaninime/sbt-derivation/archive/master.tar.gz";
};
sbt-drv-overlay = import "${sbt-drv-repo}/overlay.nix";
in
import <nixpkgs> { inherit system; overlays = overlays ++ [ (import ./overlay.nix) sbt-drv-overlay ]; }
import <nixpkgs> { inherit system; overlays = overlays ++ [ (import ./overlay.nix) ]; }

0 comments on commit 915aa7e

Please sign in to comment.