From e8e1f3c2139350193083ac2aadae073c7eded501 Mon Sep 17 00:00:00 2001 From: Kevin Quick Date: Tue, 29 Aug 2023 20:43:05 -0700 Subject: [PATCH 1/3] Add flake to support building via nix. --- flake.lock | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b3ae7f9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "levers": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1687557470, + "narHash": "sha256-T0TAGZPiI5cwWR2OMLVYW7aj3Aco7v8qIVF7JoEgO9Y=", + "owner": "kquick", + "repo": "nix-levers", + "rev": "0e31d80978a9fb6a96df0722aa298d008a57c53e", + "type": "github" + }, + "original": { + "owner": "kquick", + "repo": "nix-levers", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1685566663, + "narHash": "sha256-btHN1czJ6rzteeCuE/PNrdssqYD2nIA4w48miQAFloM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4ecab3273592f27479a583fb6d975d4aba3486fe", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "levers": "levers", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..04b613f --- /dev/null +++ b/flake.nix @@ -0,0 +1,53 @@ +{ + description = "Yet Another Pointer Analysis for LLVM"; + + inputs = { + nixpkgs.url = github:nixos/nixpkgs/23.05; + levers = { + url = "github:kquick/nix-levers"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, levers }: + { + apps = levers.eachSystem (system: rec + { + default = yapall; + yapall = { + type = "app"; + program = "${self.packages.${system}.yapall}/bin/yapall"; + }; + }); + packages = levers.eachSystem (system: + let pkgs = import nixpkgs { inherit system; }; + in rec { + default = yapall; + yapall = pkgs.rustPlatform.buildRustPackage { + pname = "yapall"; + version = "0.0.0"; + src = self; + cargoLock = { + lockFile = ./Cargo.lock; + outputHashes = { + }; + }; + LLVM_SYS_140_PREFIX = "${pkgs.llvm_14.dev}/"; + RUSTC_LLVM_14 = "${pkgs.rustc}/bin/rustc"; + buildInputs = [ + pkgs.llvm_14.dev + pkgs.libxml2 + pkgs.zlib + ]; + nativeCheckInputs = [ + pkgs.clang_14 + ]; + meta = with pkgs.lib; { + description = "Yet Anothyer Pointer Analysis for LLVM"; + license = licenses.bsd3; + homepage = "https://galois.com/"; + }; + }; + }); + }; +} From 7982d6d6d07bf9212f891143ff8f7afee814c19a Mon Sep 17 00:00:00 2001 From: Kevin Quick Date: Wed, 30 Aug 2023 11:00:23 -0700 Subject: [PATCH 2/3] Cleanup flake.nix and disable hardening for -O0 tests. --- flake.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 04b613f..113d790 100644 --- a/flake.nix +++ b/flake.nix @@ -29,8 +29,6 @@ src = self; cargoLock = { lockFile = ./Cargo.lock; - outputHashes = { - }; }; LLVM_SYS_140_PREFIX = "${pkgs.llvm_14.dev}/"; RUSTC_LLVM_14 = "${pkgs.rustc}/bin/rustc"; @@ -39,13 +37,17 @@ pkgs.libxml2 pkgs.zlib ]; + # Disable nix default of hardening, which will cause compilation of + # various tests at -O0 to fail because _FORTIFY_SOURCE requires some + # level of optimization. + hardeningDisable = [ "all" ]; nativeCheckInputs = [ pkgs.clang_14 ]; meta = with pkgs.lib; { - description = "Yet Anothyer Pointer Analysis for LLVM"; + description = "Yet Another Pointer Analysis for LLVM"; license = licenses.bsd3; - homepage = "https://galois.com/"; + homepage = "https://github.com/GaloisInc/yapall"; }; }; }); From 6271c5897404b1f078c43f9e7f797126b27910b8 Mon Sep 17 00:00:00 2001 From: Kevin Quick Date: Wed, 30 Aug 2023 11:01:08 -0700 Subject: [PATCH 3/3] Add devShells to flake.nix for nix develop usage. --- flake.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/flake.nix b/flake.nix index 113d790..ae90ac4 100644 --- a/flake.nix +++ b/flake.nix @@ -51,5 +51,28 @@ }; }; }); + devShells = levers.eachSystem (system: + let pkgs = import nixpkgs { inherit system; }; + in + { + # buildRustPackage doesn't provide assistance here, so simply + # manually create a shell. + default = pkgs.mkShell { + packages = [ + pkgs.rustc + pkgs.cargo + pkgs.llvm_14 + pkgs.clang_14 + pkgs.llvm_14.dev + pkgs.libxml2 + pkgs.zlib + pkgs.lit + pkgs.rust-analyzer + ]; + LLVM_SYS_140_PREFIX = "${pkgs.llvm_14.dev}/"; + RUSTC_LLVM_14 = "${pkgs.rustc}/bin/rustc"; + hardeningDisable = [ "all" ]; + }; + }); }; }