From d8ad1c44c57a2abe5261656817ca25f72c062140 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 21 Oct 2026 00:01:04 -0400 Subject: [PATCH] faster builds --- .cargo/config.toml | 5 +++++ ARCHITECTURE.md | 2 +- Cargo.toml | 5 ++++- README.md | 4 ++-- devenv.nix | 3 +++ 5 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..f973e9d --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[target.x86_64-unknown-linux-gnu] +rustflags = ["-C", "link-arg=-fuse-ld=lld"] + +[target.aarch64-unknown-linux-gnu] +rustflags = ["-C", "link-arg=-fuse-ld=lld"] diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index b7f42f2..952ead7 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -30,7 +30,7 @@ User-facing usage is in [`README.md`](README.md). Work tracking is in [`TODO.md` | OpenAPI | `utoipa` 6 + `schemars` | Generated REST and MCP description (DEC-15) | | Config | `figment` (TOML + env) + `clap` | Layered config with clear precedence | -Rust edition 2021; release profile uses LTO and `strip`. Cargo.lock is committed. The only dynamic dependencies are libc, libm, libgcc_s and libsystemd (check with `ldd`). +Rust edition 2021; release profile uses thin LTO and `strip`. Cargo.lock is committed. Local cargo builds link with lld via `.cargo/config.toml` (devenv provides it); the Nix package build excludes that file and keeps the default linker. The only dynamic dependencies are libc, libm, libgcc_s and libsystemd (check with `ldd`). ## Repo layout diff --git a/Cargo.toml b/Cargo.toml index 51797af..2d5989e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,10 @@ rcgen = { version = "0.14", default-features = false, features = ["ring", "pem"] # Pausable clock for tests. `full` does not include this, and the runtime build must not. tokio = { version = "1.53.3", features = ["test-util"] } +[profile.dev] +debug = "line-tables-only" + [profile.release] -lto = true +lto = "thin" strip = true codegen-units = 1 diff --git a/README.md b/README.md index aea63d6..060558e 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,11 @@ The service listens on loopback by default. To reach it from another machine set ## Build ```sh -devenv shell # toolchain, pkg-config, libsystemd, otelcol-contrib +devenv shell # toolchain, pkg-config, lld, libsystemd, otelcol-contrib cargo build --release # target/release/slinuxm ``` -Without devenv you need a Rust toolchain, `pkg-config` and the libsystemd development files. +Without devenv you need a Rust toolchain, `pkg-config`, the `lld` linker (`.cargo/config.toml` links with it) and the libsystemd development files. ### Version diff --git a/devenv.nix b/devenv.nix index fa6b7e5..11847fb 100644 --- a/devenv.nix +++ b/devenv.nix @@ -6,6 +6,9 @@ packages = [ pkgs.git pkgs.pkg-config + # Linker: .cargo/config.toml passes -fuse-ld=lld for local builds, so it + # must be on PATH in this shell. + pkgs.lld # libsystemd.pc lives in the .dev output; the pkg-config setup hook finds # it when the package is in `packages`. pkgs.systemd