Skip to content

Commit

Permalink
fix: fix fuzzing with 1.80 nightly
Browse files Browse the repository at this point in the history
Summary:
Rust started using their own linker that blows up when in nix. So
rust-overlay wraps that linker with their own scripts. Fenix hasn't
found a fix yet.

I really want to get rid of gcc

Test Plan:
`cargo fuzz run multi_replay_agent -- -runs=1`
  • Loading branch information
elliottneilclark committed Jun 27, 2024
1 parent bf0395c commit 79b61e7
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 129 deletions.
63 changes: 31 additions & 32 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

189 changes: 94 additions & 95 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,142 +10,140 @@
inputs.nixpkgs.follows = "nixpkgs";
};

fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};


advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};

outputs = { self, nixpkgs, crane, fenix, flake-utils, advisory-db, ... }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
crane,
rust-overlay,
flake-utils,
advisory-db,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ fenix.overlays.default ];
pkgs = import nixpkgs {
inherit system overlays;
config.allowBroken = true;
inherit system;
config = {
allowBroken = true;
};
overlays = [ (import rust-overlay) ];
};

inherit (pkgs) lib;

craneLib = crane.lib.${system};
rust-toolchain = pkgs.rust-bin.selectLatestNightlyWith (
toolchain:
toolchain.default.override {
extensions = [ "rust-src" ];
targets = [
"aarch64-apple-darwin"
"x86_64-apple-darwin"
"aarch64-unknown-linux-gnu"
"x86_64-unknown-linux-gnu"
];
}
);

craneLib = (crane.mkLib pkgs).overrideToolchain rust-toolchain;
src = craneLib.cleanCargoSource (craneLib.path ./.);

# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;

buildInputs = [
# Add additional build inputs here
]
++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
buildInputs =
[ ]
++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
};

toolchain = "complete";
rustPkg = fenix.packages.${system}.${toolchain}.withComponents
[
"cargo"
"clippy"
"rust-src"
"llvm-tools"
"rustc"
"rustfmt"
];

craneLibLLvmTools = craneLib.overrideToolchain rustPkg;

# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;

# Build the actual crate itself, reusing the dependency
# artifacts from above.
rs-poker = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
rs-poker = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
doCheck = false;
}
);
in
{
checks = {
# Build the crate as part of `nix flake check` for convenience
inherit rs-poker;

# Run clippy (and deny all warnings) on the crate source,
# again, resuing the dependency artifacts from above.
#
# Note that this is done as a separate derivation so that
# we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself.
rs-poker-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});

rs-poker-doc = craneLib.cargoDoc (commonArgs // {
inherit cargoArtifacts;
});

# Check formatting
rs-poker-fmt = craneLib.cargoFmt {
inherit src;
cargoClippyExtraArgs = "--all --check";
};

# Audit dependencies
rs-poker-audit = craneLib.cargoAudit {
inherit src advisory-db;
checks =
{
# Build the crate as part of `nix flake check` for convenience
inherit rs-poker;

# Run clippy (and deny all warnings) on the crate source,
# again, resuing the dependency artifacts from above.
rs-poker-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);

rs-poker-doc = craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; });

# Check formatting
rs-poker-fmt = craneLib.cargoFmt {
inherit src;
cargoClippyExtraArgs = "--all --check";
};

# Audit dependencies
rs-poker-audit = craneLib.cargoAudit { inherit src advisory-db; };

# Run tests since rs-poker has doCheck = false;
rs-poker-nextest = craneLib.cargoNextest (
commonArgs
// {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
cargoNextestExtraArgs = "--all-targets";
}
);
}
// lib.optionalAttrs (system == "x86_64-linux") {
rs-poker-coverage = craneLib.cargoTarpaulin (commonArgs // { inherit cargoArtifacts; });
};

# Run tests with cargo-nextest
# Consider setting `doCheck = false` on `rs-poker` if you do not want
# the tests to run twice
rs-poker-nextest = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
cargoNextestExtraArgs = "--all-targets";
});
} // lib.optionalAttrs (system == "x86_64-linux") {
# NB: cargo-tarpaulin only supports x86_64 systems
# Check code coverage (note: this will not upload coverage anywhere)
rs-poker-coverage = craneLib.cargoTarpaulin (commonArgs // {
inherit cargoArtifacts;
});
};

packages = {
inherit rs-poker;
default = rs-poker;
} // lib.optionalAttrs (system == "x86_64-linux") {
rs-poker-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs // {
inherit cargoArtifacts;
});
};

apps.default = flake-utils.lib.mkApp {
drv = rs-poker;
};
apps.default = flake-utils.lib.mkApp { drv = rs-poker; };

devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks.${system};

nativeBuildInputs = with pkgs; [
rustPkg
rust-analyzer-nightly
rust-toolchain
rust-analyzer
pkg-config
git
cmake
openssl

cargo-release
cargo-audit
cargo-watch
cargo-fuzz
];

shellHook = ''
Expand All @@ -157,5 +155,6 @@
export PATH=$CARGO_HOME/bin:$PATH
'';
};
});
}
);
}
3 changes: 2 additions & 1 deletion src/arena/historian/directory_historian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ impl DirectoryHistorian {
///
/// # Arguments
///
/// * `base_path` - The base path where the game action files will be stored.
/// * `base_path` - The base path where the game action files will be
/// stored.
pub fn new(base_path: PathBuf) -> Self {
DirectoryHistorian {
base_path,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
//! * `HoldemCompetition` that keeps track of all simulation based stats from
//! simluations genreated via `HoldemSimulationGenerator`.
//! * Each `HoldemSimulationGenerator` is built of `AgentsGenerator`,
//! `HistorianGenerator`, and `GameStateGenerator`
//! `HistorianGenerator`, and `GameStateGenerator`
//!
//!
//! ### Example
Expand Down

0 comments on commit 79b61e7

Please sign in to comment.