{
  "version": "https://jsonfeed.org/version/1",
  "title": "Ian's Digital Garden",
  "home_page_url": "https://ianwwagner.com/",
  "feed_url": "https://ianwwagner.com//tag-cross-compilation.json",
  "description": "",
  "items": [
    {
      "id": "https://ianwwagner.com//the-rust-toolchain-toml-file.html",
      "url": "https://ianwwagner.com//the-rust-toolchain-toml-file.html",
      "title": "The rust-toolchain.toml file",
      "content_html": "<p>This isn't so much a TIL as a quick PSA.\nIf you're a Rust developer and need to ensure specific things about your toolchain,\nthe <code>rust-toolchain.toml</code> file is a real gem!</p>\n<p>I don't quite remember how, but I accidentally discovered this file a year or two ago.\nSince then, I've spread the good news to at least half a dozen other devs,\nand most of them simply had no idea it existed.\nSo, without further ado...</p>\n<h1><a href=\"#what-does-the-file-do\" aria-hidden=\"true\" class=\"anchor\" id=\"what-does-the-file-do\"></a>What does the file do?</h1>\n<p><code>rust-toolchain.toml</code> is a file that lets you specify certain things about your Rust toolchain.\nFor example, if you need to use nightly rust for a project,\nyou can specify that in your toolchain file.\nIt also lets you specify other cargo components to install\nand specify cross-compilation targets you want to have available.</p>\n<h1><a href=\"#why-would-i-need-this\" aria-hidden=\"true\" class=\"anchor\" id=\"why-would-i-need-this\"></a>Why would I need this?</h1>\n<p>The headline use case in <a href=\"https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file\">The rustup book</a>\nis to pin to a specific release.\nThis is pretty rare in practice I think, unless you need <code>nightly</code>.\nYou can specify channels like <code>nightly</code>, <code>stable</code>, and <code>beta</code> in addition to specific releases.</p>\n<p>The killer use case in my opinion is for easier cross-compilation.\nI do a lot of cross compiling, and codifying all required targets in a single file makes life much easier!</p>\n<p>The best part is that, as long as you're using <code>rustup</code>, everything is automatic!\nFor projects with a large number of collaborators (like an open-source library),\nthis makes it a lot easier to onboard new devs.</p>\n<h2><a href=\"#what-if-im-not-using-rustup\" aria-hidden=\"true\" class=\"anchor\" id=\"what-if-im-not-using-rustup\"></a>What if I'm not using rustup?</h2>\n<p>Not everyone uses rustup.\nFor example, some devs I know use nix.\nWhen I asked one of them about how to do this without duplicating work,\nthey suggested <a href=\"https://github.com/nix-community/fenix\">Fenix</a>,\nwhich is able to consume the <code>rust-toolchain.toml</code>.</p>\n<p>If you have suggestions or experiences with other invironments,\nlet me know and I'll update this post.\nContact links in the footer.</p>\n<h1><a href=\"#show-me-an-example\" aria-hidden=\"true\" class=\"anchor\" id=\"show-me-an-example\"></a>Show me an example!</h1>\n<p>Here's what the file looks like for a cross-platform mobile library that I maintain:</p>\n<pre><code class=\"language-toml\">[toolchain]\nchannel = &quot;stable&quot;\ntargets = [\n    # iOS\n    &quot;aarch64-apple-ios&quot;,\n    &quot;x86_64-apple-ios&quot;,\n    &quot;aarch64-apple-ios-sim&quot;,\n\n    # Android\n    &quot;armv7-linux-androideabi&quot;,\n    &quot;i686-linux-android&quot;,\n    &quot;aarch64-linux-android&quot;,\n    &quot;x86_64-linux-android&quot;,\n    &quot;x86_64-unknown-linux-gnu&quot;,\n    &quot;x86_64-apple-darwin&quot;,\n    &quot;aarch64-apple-darwin&quot;,\n    &quot;x86_64-pc-windows-gnu&quot;,\n    &quot;x86_64-pc-windows-msvc&quot;,\n\n    # WebAssembly\n    &quot;wasm32-unknown-unknown&quot;\n]\ncomponents = [&quot;clippy&quot;, &quot;rustfmt&quot;]\n</code></pre>\n",
      "summary": "",
      "date_published": "2025-01-13T00:00:00-00:00",
      "image": "",
      "authors": [
        {
          "name": "Ian Wagner",
          "url": "https://fosstodon.org/@ianthetechie",
          "avatar": "media/avi.jpeg"
        }
      ],
      "tags": [
        "rust",
        "cross-compilation"
      ],
      "language": "en"
    }
  ]
}