diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..b940451 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,7 @@ +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=mold"] + +[alias] +# Shortcut for development runs with dynamic linking enabled. +dev = "run --features dev" diff --git a/Cargo.lock b/Cargo.lock index fbf6bb1..4a191f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -355,6 +355,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "950238d3049d81006a6fd6b898a34cfc01bb5462a7668795a54d640aed19fd0a" dependencies = [ + "bevy_dylib", "bevy_internal", ] @@ -686,6 +687,15 @@ dependencies = [ "sysinfo", ] +[[package]] +name = "bevy_dylib" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70547c664f17a903cdef1e8e673496e9bdfa3d69dece9c01523d79067a876e34" +dependencies = [ + "bevy_internal", +] + [[package]] name = "bevy_ecs" version = "0.19.0" diff --git a/Cargo.toml b/Cargo.toml index 3b5474c..2542932 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,12 @@ bevy = { version = "0.19.0", features = ["bevy_feathers", "jpeg"] } rfd = "0.17.2" variadics_please = "2.0.0" +[features] +# Enabled via `cargo run --features dev` or `cargo dev`. Dynamic-links Bevy so +# tiny code changes don't relink the full graph. Don't ship a release build +# with this on — it produces a `.so` Bevy that's awkward to distribute. +dev = ["bevy/dynamic_linking"] + # Light opts on our crate, full opts on dependencies. Recommended by Bevy. [profile.dev] opt-level = 1 diff --git a/shell.nix b/shell.nix index 97eecab..fdcd4c9 100644 --- a/shell.nix +++ b/shell.nix @@ -9,7 +9,10 @@ # Source: https://bevy.org/learn/quick-start/getting-started/setup/ pkgs.mkShell { - nativeBuildInputs = [ pkgs.pkg-config ]; + # `mold` + `clang` give us the fast linker pair Bevy recommends for dev + # iteration. `.cargo/config.toml` wires clang as the linker driver and + # passes `-fuse-ld=mold`. + nativeBuildInputs = [ pkgs.pkg-config pkgs.mold pkgs.clang ]; buildInputs = with pkgs; [ udev