I have an x86_64-unknown-linux-musl
host with a 1.77.1 toolchain, and I want to add aarch64-unknown-freebsd
as a target. The usual way doesn't work because there are no precompiled binaries for tier 3 platforms.
$ rustup target add --toolchain 1.77.1 aarch64-unknown-freebsd
error: toolchain '1.77.1-x86_64-unknown-linux-musl' does not contain component 'rust-std' for target 'aarch64-unknown-freebsd'
I cloned the Rust repository at version 1.77.1 and created a config.toml
based on the example in the repository root and random information I came across online. This is what I ended up with:
[build]
build = "x86_64-unknown-linux-musl"
host = ["aarch64-unknown-freebsd"]
target = ["aarch64-unknown-freebsd"]
cargo = "/workspace/destdir/bin/cargo"
rustc = "/workspace/destdir/bin/rustc"
rustfmt = "/workspace/destdir/bin/rustfmt"
docs = false
python = "/usr/bin/python3"
verbose = 2
[install]
prefix = "/workspace/destdir/whatamidoing"
sysconfdir = "etc"
[rust]
parallel-compiler = false
channel = "stable"
musl-root = "/opt/x86_64-linux-musl/x86_64-linux-musl/sys-root/usr"
[target.aarch64-unknown-freebsd]
cc = "/opt/bin/aarch64-unknown-freebsd13.2-libgfortran5-cxx11/aarch64-unknown-freebsd13.2-clang"
cxx = "/opt/bin/aarch64-unknown-freebsd13.2-libgfortran5-cxx11/aarch64-unknown-freebsd13.2-clang++"
ar = "/opt/bin/aarch64-unknown-freebsd13.2-libgfortran5-cxx11/aarch64-unknown-freebsd13.2-ar"
ranlib = "/opt/bin/aarch64-unknown-freebsd13.2-libgfortran5-cxx11/aarch64-unknown-freebsd13.2-ranlib"
linker = "/opt/bin/aarch64-unknown-freebsd13.2-libgfortran5-cxx11/aarch64-unknown-freebsd13.2-clang"
[target.x86_64-unknown-linux-musl]
cc = "/opt/x86_64-linux-musl/bin/x86_64-linux-musl-gcc"
cxx = "/opt/x86_64-linux-musl/bin/x86_64-linux-musl-g++"
ar = "/opt/x86_64-linux-musl/bin/x86_64-linux-musl-ar"
ranlib = "/opt/x86_64-linux-musl/bin/x86_64-linux-musl-ranlib"
linker = "/opt/x86_64-linux-musl/bin/x86_64-linux-musl-gcc"
crt-static = false
From there, I proceeded as described in another forum post, at least as I understood the recommended steps there, but I ran into the same error they did.
./x.py build --config ./config.toml # this took 5 days...
./x.py dist --config ./config.toml --target aarch64-unknown-freebsd
./x.py install --config ./config.toml --target aarch64-unknown-freebsd
rustup toolchain link whatamidoing /workspace/destdir/whatamidoing
rustup target add aarch64-unknown-freebsd --toolchain whatamidoing
The last line produced the message
error: toolchain 'whatamidoing' does not support components: whatamidoing is a custom toolchain
I'm sure much of what I've done here is very incorrect, at least for what I'm trying to accomplish. I'd just like to be able to compile Rust code for aarch64-unknown-freebsd
with a 1.77.1 toolchain on an x86_64-unknown-linux-musl
host in the same way one would compile for any other target. Any guidance would be greatly appreciated!