Skip to content
Aria Beingessner edited this page Mar 16, 2023 · 7 revisions

cargo-dist frequently refers to platforms referenced using Rust's target-triple syntax. See Rust's platform support page for a pretty extensive listing with high-level descriptions of what they refer to, but here's a quick TLDR:

A "target triple" is a quadruple of the form CPU-VENDOR-OS(-ABI), such as "aarch64-apple-darwin" (arm64 macOS) or "x86_64-pc-windows-msvc" (x64 Windows). In practice it largely amounts to HARDWARE-SOFTWARE since the VENDOR-OS(-ABI) part tends to be tightly coupled. When ABI is relevant there's usually a "normal" one (linux-gnu and windows-msvc) and a "weird one" (linux-musl and windows-gnu). Here are some notable patterns:

Hardware:

  • i686 is "32-bit x86"
  • x86_64 is "64-bit x86"
  • aarch64 is "64-bit ARM"

(More accursed souls may also care about "powerpc", "powerpc64", "mips", "mips64", "arm", "armv7", "riscv64gc"...)

Software:

  • pc-windows-msvc is "Windows"
  • pc-windows-gnu is "MinGW"
  • apple-darwin is "macOS"
  • unknown-linux-gnu is "normal linux (dynamically linked glibc)"
  • unknown-linux-musl is "musl linux (statically linked musl libc)"

(More accursed souls may also care about "apple-ios", "linux-android", "unknown-freebsd", "unknown-illumos"...)

Default Platforms

When you run cargo dist init we will populate your config with "default platforms" we expect you'll want to support, here's the rationale!

currently default platforms

The following platforms are all defaulted for being ubiquitous desktop/server environments that are easy to build with x64 runners of the relevant platforms.

  • x86_64-pc-windows-msvc ("64-bit windows")
  • x86_64-apple-darwin ("intel macOS")
  • x86_64-unknown-linux-gnu ("64-bit linux")
  • aarch64-apple-darwin ("arm64 macOS" / "apple silicon")

future default platforms

The following platforms might be defaulted in the future, pending further work/discussion.

Nearby Platforms

"nearby platforms" is a concept I just made up to describe platforms which are in some sense trivially interoperable. There are two notions of nearby that we find interesting:

  • nearby-buildable: when going to build a non-host target with cargo, a "nearby platform" can be installed with rustup target add and is expected to succeed with only that intervention
  • nearby-runnable: when going to install an application, a "nearby platform" can be used as a fallback for otherwise-unsupported target-triples

Examples:

  • x86_64-apple-darwin ("intel macOS") and aarch64-apple-darwin ("apple silicon") are mutually nearby-buildable (Apple makes cross-compilation between its platforms easy)
  • i686-pc-windows-msvc ("32-bit windows") is nearby-runnable on x86_64-pc-windows-msvc ("64-bit windows"), but not vice-versa

nearby-buildable

"x on y" here means "x is buildable on y with only rustup target add x" (assuming you have all the other tools necessary to build native binaries on y).

definitely nearby-buildable

  • x86_64-apple-darwin on aarch64-apple-darwin (tested)
  • aarch64-apple-darwin on x86_64-apple-darwin (tested)
  • i686-pc-windows-msvc on x86_64-pc-windows-msvc (tested)

maybe nearby-buildable

  • x86_64-pc-windows-msvc on i686-pc-windows-msvc (plausible, untested, needs 32-bit windows)
  • x86_64-pc-windows-msvc on x86_64-pc-windows-gnu (plausible, untested, needs 64-bit mingw)
  • i686-pc-windows-gnu on x86_64-pc-windows-gnu (plausible, untested, needs 64-bit mingw)
  • i686-unknown-linux-gnu on x86_64-unknown-linux-gnu (plausible, untested, needs 64-bit linux)
  • i686-apple-darwin on x86_64-apple-darwin (semi-plausible, untested, needs 64-bit macos)

notably NOT nearby-buildable

  • x86_64-pc-windows-gnu on x86_64-pc-windows-msvc (complains about gcc.exe)
  • x86_64-unknown-linux-musl on x86_64-unknown-linux-gnu (needs "musl-tools" to be installed?)

nearby-runnable

"x on y" here means "x is runnable on y" (either natively or through an automatic emulation shim you expect any reasonable machine to have)

definitely nearby-runnable

  • i686-pc-windows-msvc on x86_64-pc-windows-msvc (claimed, this working is like The Point Of x64)
  • x86_64-pc-windows-msvc on aarch64-pc-windows-msvc (claimed, windows apparently has its own kind of rosetta2)
  • i686-pc-windows-msvc on aarch64-pc-windows-msvc (claimed, windows apparently has its own kind of rosetta2)
  • x86_64-unknown-linux-musl on x86_64-unknown-linux-gnu (claimed, this working is like The Point Of musl)

pseudo nearby-runnable

These ones are "it's complicated"

  • x86_64-apple-darwin on aarch64-apple-darwin (tested, relies on rosetta2 being installed)

This one's annoying. A fresh-out-of-the-box arm64 macbook ("apple silicon") does not have rosetta2 installed, but if you run "an x64 app" the OS will automatically install it. Unfortunately this is not true for "an x64 binary". I think it needs to specifically be a .app or something? There is ostensibly a way to detect if a machine has rosetta2 setup, so I guess we should add that to our installer logic. This is sad because it means nearby-runnable is not a static decision at build time, and instead requires additional install-time negotiation :(

  • i686-apple-darwin on x86_64-apple-darwin (reported, depends on OS version)

macOS Catalina (macOS 10.15, October 2019) dropped system support for 64-bit applications, and Apple is Very Good at getting people to update their OS. So by default you should just assume this doesn't work, but if you were really ambitious you could check at runtime for the OS version?

maybe nearby-runnable

  • x86_64-pc-windows-msvc on x86_64-pc-windows-gnu (certain, untested, needs 64-bit mingw)
  • i686-pc-windows-msvc on x86_64-pc-windows-gnu (certain, untested, needs 64-bit mingw)
  • i686-pc-windows-gnu on x86_64-pc-windows-gnu (certain, untested, needs 64-bit mingw)
  • i686-unknown-linux-gnu on x86_64-unknown-linux-gnu (probable, untested, needs 64-bit linux)