mirror of
https://github.com/lifting-bits/remill
synced 2026-06-21 13:56:07 +00:00
flake: add nix flake for building remill
Add a Nix flake that builds remill and its XED dependency using LLVM 17, with patched Ghidra sources for Sleigh. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Kyle Elliott
parent
962b68b964
commit
b32b614ffc
@@ -105,3 +105,6 @@ VERSION
|
||||
|
||||
# Doxygen generated documentation
|
||||
docs/doxygen/
|
||||
|
||||
# Nix
|
||||
result
|
||||
|
||||
Generated
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1767313136,
|
||||
"narHash": "sha256-16KkgfdYqjaeRGBaYsNrhPRRENs0qzkQVUooNHtoy2w=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ac62194c3917d5f474c1a844b6fd6da2db95077d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-25.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
{
|
||||
description = "Remill - Static binary translator that lifts machine code to LLVM bitcode";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
forSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
|
||||
in
|
||||
{
|
||||
packages = forSystems (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
llvmPkgs = pkgs.llvmPackages_17;
|
||||
|
||||
xed = llvmPkgs.stdenv.mkDerivation {
|
||||
pname = "xed";
|
||||
version = "2025.06.08";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "intelxed";
|
||||
repo = "xed";
|
||||
rev = "v2025.06.08";
|
||||
hash = "sha256-FXVWCq7ykuSsVx8iB7WkFD7DDq6o/4bgsS0YJQWE+XM=";
|
||||
};
|
||||
|
||||
mbuild = pkgs.fetchFromGitHub {
|
||||
owner = "intelxed";
|
||||
repo = "mbuild";
|
||||
rev = "v2024.11.04";
|
||||
hash = "sha256-iQVykBG3tEPxI1HmqBkvO1q+K8vi64qBfVC63/rcTOk=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ pkgs.python3 ];
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
postUnpack = "cp -r $mbuild mbuild";
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
patchShebangs .
|
||||
python3 mfile.py install \
|
||||
--install-dir=$out \
|
||||
--cc=$CC --cxx=$CXX \
|
||||
--ar=$AR \
|
||||
--compiler=clang \
|
||||
--static \
|
||||
--extra-ccflags=-fPIC \
|
||||
--extra-cxxflags=-fPIC
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/lib/cmake/XED
|
||||
cp ${./dependencies/XEDConfig.cmake.in} $out/lib/cmake/XED/XEDConfig.cmake
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
sleighSrc = pkgs.fetchFromGitHub {
|
||||
owner = "lifting-bits";
|
||||
repo = "sleigh";
|
||||
rev = "7c6b742";
|
||||
hash = "sha256-Di/maGPXHPSM/EUVTgNRsu7nJ0Of+tVRu+B4wr9OoBE=";
|
||||
};
|
||||
|
||||
ghidraSource = pkgs.applyPatches {
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "NationalSecurityAgency";
|
||||
repo = "ghidra";
|
||||
rev = "80ccdadeba79cd42fb0b85796b55952e0f79f323";
|
||||
hash = "sha256-7Iv1awZP5lU1LpGqC0nyiMxy0+3WOmM2NTdDYIzKmmk=";
|
||||
};
|
||||
patches =
|
||||
let dir = ./patches/sleigh;
|
||||
in map (f: dir + "/${f}")
|
||||
(builtins.filter (f: nixpkgs.lib.hasSuffix ".patch" f)
|
||||
(builtins.sort builtins.lessThan
|
||||
(builtins.attrNames (builtins.readDir dir))));
|
||||
};
|
||||
|
||||
remill = llvmPkgs.stdenv.mkDerivation {
|
||||
pname = "remill";
|
||||
version = "0-unstable-${self.shortRev or self.dirtyShortRev or "unknown"}";
|
||||
|
||||
src = self;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.cmake
|
||||
pkgs.ninja
|
||||
pkgs.git
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
llvmPkgs.llvm.dev
|
||||
llvmPkgs.llvm.lib
|
||||
xed
|
||||
pkgs.glog
|
||||
pkgs.gflags
|
||||
pkgs.gtest
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DFETCHCONTENT_SOURCE_DIR_SLEIGH=${sleighSrc}"
|
||||
"-DFETCHCONTENT_SOURCE_DIR_GHIDRASOURCE=${ghidraSource}"
|
||||
"-DFETCHCONTENT_FULLY_DISCONNECTED=ON"
|
||||
"-DCLANG_PATH:FILEPATH=${pkgs.writeShellScript "bc-clang" ''
|
||||
exec ${llvmPkgs.clang-unwrapped}/bin/clang++ \
|
||||
-resource-dir ${llvmPkgs.clang-unwrapped.lib}/lib/clang/17 \
|
||||
"$@"
|
||||
''}"
|
||||
"-DREMILL_ENABLE_TESTING=OFF"
|
||||
"-DGIT_FAIL_IF_NONZERO_EXIT=FALSE"
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
default = remill;
|
||||
inherit xed remill;
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user