diff --git a/nix/_sources/generated.json b/nix/_sources/generated.json index b40a3d51d2..1c3e7b022c 100644 --- a/nix/_sources/generated.json +++ b/nix/_sources/generated.json @@ -14,6 +14,26 @@ }, "version": "0.4.5" }, + "lief": { + "cargoLocks": null, + "date": null, + "extract": null, + "name": "lief", + "passthru": null, + "pinned": false, + "src": { + "deepClone": false, + "fetchSubmodules": false, + "leaveDotGit": false, + "name": null, + "owner": "lief-project", + "repo": "LIEF", + "rev": "0.13.2", + "sha256": "sha256-lH4SqwPB2Jp/wUI2Cll67PQbHbwMqpNuLy/ei8roiHg=", + "type": "github" + }, + "version": "0.13.2" + }, "lzallright": { "cargoLocks": { "Cargo.lock": [ diff --git a/nix/_sources/generated.nix b/nix/_sources/generated.nix index 2191a8280c..8d8619a003 100644 --- a/nix/_sources/generated.nix +++ b/nix/_sources/generated.nix @@ -9,6 +9,17 @@ sha256 = "sha256-+cPOzzO3bCQAu8LrbjUJ5S/SR5OFitOYLIu5L9t/q+k="; }; }; + lief = { + pname = "lief"; + version = "0.13.2"; + src = fetchFromGitHub { + owner = "lief-project"; + repo = "LIEF"; + rev = "0.13.2"; + fetchSubmodules = false; + sha256 = "sha256-lH4SqwPB2Jp/wUI2Cll67PQbHbwMqpNuLy/ei8roiHg="; + }; + }; lzallright = { pname = "lzallright"; version = "v0.2.3"; diff --git a/nvfetcher.toml b/nvfetcher.toml index 66d9c20a7b..998e279575 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml @@ -18,3 +18,7 @@ fetch.pypi = "treelib" [pyfatfs] src.pypi = "pyfatfs" fetch.pypi = "pyfatfs" + +[lief] +src.github_tag = "lief-project/LIEF" +fetch.github = "lief-project/LIEF" diff --git a/overlay.nix b/overlay.nix index 1b19017a5a..465ed18981 100644 --- a/overlay.nix +++ b/overlay.nix @@ -11,19 +11,68 @@ inputs: final: prev: hardeningDisable = (super.hardeningDisable or [ ]) ++ [ "fortify3" ]; }); - # Lief 12.3 incompatibility with Cmake 3.26 - lief = prev.lief.overrideAttrs (super: { - postPatch = '' - substituteInPlace setup.py \ - --replace \ - 'cmake_args = ["-DLIEF_FORCE_API_EXPORTS=ON", "-DLIEF_PYTHON_API=on"]' \ - 'cmake_args = ["-DLIEF_FORCE_API_EXPORTS=ON", "-DLIEF_PYTHON_API=on", "-DLIEF_EXAMPLES=off"]' - ''; - }); - # Own package updated independently of nixpkgs jefferson = final.callPackage ./nix/jefferson { }; + lief = prev.lief.overrideAttrs (super: with final; { + + outputs = [ "out" "py" ]; + + nativeBuildInputs = [ + cmake + ninja + ]; + + # Not a propagatedBuildInput because only the $py output needs it; $out is + # just the library itself (e.g. C/C++ headers). + buildInputs = with python3.pkgs; [ + python3 + setuptools + tomli + ]; + + CXXFLAGS = lib.optional stdenv.isLinux [ "-ffunction-sections" "-fdata-sections" "-fvisibility-inlines-hidden" "-static-libstdc++" "-static-libgcc" ] + ++ lib.optional stdenv.isDarwin [ "-faligned-allocation" "-fno-aligned-new" "-fvisibility=hidden" ]; + + CFLAGS = lib.optional stdenv.isLinux [ "-ffunction-sections" "-fdata-sections" "-static-libstdc++" "-static-libgcc" ]; + LDFLAGS = lib.optional stdenv.isLinux [ "-Wl,--gc-sections" "-Wl,--exclude-libs,ALL" ]; + + + dontUseCmakeConfigure = true; + + buildPhase = '' + runHook preBuild + + mkdir -p build + cmake -S . -B build -GNinja -DCMAKE_LINK_WHAT_YOU_USE=on -DBUILD_SHARED_LIBS=on -DLIEF_INSTALL_COMPILED_EXAMPLES=off -DCMAKE_INSTALL_PREFIX=$out -DCMAKE_BUILD_TYPE=Release + + cmake --build build --target all + + runHook postBuild + ''; + + postBuild = '' + pushd api/python + ${python3.interpreter} setup.py build --parallel=$NIX_BUILD_CORES + popd + ''; + + installPhase = '' + runHook preInstall + + cmake --build build --target install + + runHook postInstall + ''; + + postInstall = '' + pushd api/python + ${python3.interpreter} setup.py install --skip-build --root=/ --prefix=$py + popd + ''; + + }); + python3 = prev.python3 // { pkgs = prev.python3.pkgs.overrideScope (pyFinal: pyPrev: {