{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreiaxbmd7barxmjsh345h7i3iut7klnvcg7spdk5pfstk6ntfzmnmna",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mjk2nhrefq32"
  },
  "path": "/t/more-granual-build-rs-companion-links-rs/24176#post_1",
  "publishedAt": "2026-04-15T11:56:54.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "(click for more details)"
  ],
  "textContent": "## The problem\n\nClick to fold (click for more details)\n\n## Palliatives / working around it with the current tools\n\nClick to seeRelevant snippet from my rust-analyzer config (click for more details)\n\n* * *\n\n## The suggested solution\n\nWould be for Cargo to fully acknowledge and embrace this _`package.links` with a companion build script_ (the \"conceptual `links.rs` build script\"), and reïfy this _concept_ :\n\n  1. Allow for `package.links` to be set to an object rather than just a string, with, at least:\n\n     * `name` entry, to be set to its identifying name,\n     * `script` entry: to be set to point to some `.rs` file.\n       * Optionally, it could be set to `true` to default to `\"links.rs\"`; and/or having such a file alongside a `Cargo.toml` _and_ a `links = \"libfoo`\" kind of entry could be tantamount to all this.\n\n    [package]\n    links = { name = \"libfoo\", script = \"links.rs\" }\n\n\n  2. Such a `links.rs`-specified Rust file shall:\n\n     * be interpreted like a `build.rs` does currently in Rust:\n\n       * involving `build-dependencies`,\n       * living in the `build`/host universe (_e.g._ , w.r.t. Cargo `resolver` or whatnot);\n       * being bypassable through `links` overrides (the `build.rs` being the one bypassed _as a fallback_ , for retro-compat).\n     * but only involved:\n\n       * for actual `cargo`-compiling commands, such as `build/run/test/bench`, _i.e._ , **it would be skipped when running`cargo check/clippy/doc`**.\n       * invoked in the tail-end of the compilation pipeline.\n\nOr, more precisely, deemed to have no dependents inside Cargo pipelining but for the compilation/linkage of the very final artifact(s) (which `cargo check/clippy/doc` do not produce).\n\n\n",
  "title": "More granual `build.rs` companion: `links.rs`"
}