fix: AMD64 cpus not detected as X86_64 on FreeBSD
Linux and Rust both seems to normalize amd64 CPUs to x86_64
for AMD CPUs, but FreeBSD will return amd64
for both uname -m
and sysctl hw.machine
. While rustup treats both x86_64
and amd64
, rustup uses the same triple as cc -dumpmachine
.
E.g.:
% uname -m
amd64
% sysctl hw.machine
hw.machine: amd64
% cc -dumpmachine
x86_64-unknown-freebsd14.2
% rustup show | grep host
Default host: x86_64-unknown-freebsd
Here is the output of the example guess-host-triple
binary on this host, from current master
and from this branch:
% RUST_LOG=debug cargo run --example guess-host-triple
[ snip warnings ]
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
Running `target/debug/examples/guess-host-triple`
WARN 2025-06-30T09:09:50Z: guess_host_triple: uname returned unrecognised machine "amd64"
WARN 2025-06-30T09:09:50Z: guess_host_triple: Could not guess triple for (Unknown, Little, FreeBsd)
Could not determine host triple
% git co fix/amd64-misidentifed
Switched to branch 'fix/amd64-misidentifed'
% RUST_LOG=debug cargo run --example guess-host-triple
[ snip lint warnings ]
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.41s
Running `target/debug/examples/guess-host-triple`
x86_64-unknown-freebsd
I also fixed a couple very basic linter warnings, but didn't get very ambitious, as I don't have all the archs covered.
Edited by penryu