forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup cross compilation for aarhc64-unknown-freebsd
- Loading branch information
1 parent
f63c8c0
commit 9be0701
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[target.aarch64-unknown-freebsd] | ||
# We need to build std, as aarch64-unknown-freebsd is not a tier 1 rust target | ||
build-std = true | ||
image.name = "ghcr.io/cross-rs/aarch64-unknown-freebsd:local" | ||
image.toolchain = ["linux/arm64/v8=aarch64-unknown-linux-gnu"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Cross-Compilation | ||
|
||
Since `aarch64-unknown-freebsd` is not a Rust tier-1 target, we use [cross](https://github.com/cross-rs/cross) to cross-compile for it. | ||
|
||
We need the latest `cross` binary, as well as a custom docker image. | ||
|
||
```shell | ||
git clone https://github.com/cross-rs/cross.git | ||
``` | ||
|
||
Then, apply the following patch: | ||
|
||
```patch | ||
From 49ed9ce2082116ac41f80afef1e7c9390d358cd3 Mon Sep 17 00:00:00 2001 | ||
From: Martin Fink <[email protected]> | ||
Date: Wed, 21 Feb 2024 17:46:53 +0100 | ||
Subject: [PATCH] add link | ||
|
||
--- | ||
docker/Dockerfile.aarch64-unknown-freebsd | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/docker/Dockerfile.aarch64-unknown-freebsd b/docker/Dockerfile.aarch64-unknown-freebsd | ||
index 8631717..d03726a 100644 | ||
--- a/docker/Dockerfile.aarch64-unknown-freebsd | ||
+++ b/docker/Dockerfile.aarch64-unknown-freebsd | ||
@@ -31,6 +31,8 @@ COPY freebsd-fetch-best-mirror.sh / | ||
COPY freebsd-setup-packagesite.sh / | ||
COPY freebsd-install-package.sh / | ||
|
||
+RUN ln -s $(which gcc) /usr/local/bin/aarch64-unknown-linux-gnu-gcc | ||
+ | ||
ENV CARGO_TARGET_AARCH64_UNKNOWN_FREEBSD_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc.sh \ | ||
AR_aarch64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"ar \ | ||
CC_aarch64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"gcc \ | ||
-- | ||
2.43.0 | ||
``` | ||
|
||
and run the following (assuming you are running on an AArch64 machine). | ||
|
||
```shell | ||
cargo build-docker-image \ | ||
--platform=aarch64-unknown-linux-gnu \ | ||
aarch64-unknown-freebsd \ | ||
--tag local | ||
``` | ||
|
||
If you're on X86, run: | ||
|
||
```shell | ||
cargo build-docker-image \ | ||
aarch64-unknown-freebsd \ | ||
--tag local | ||
``` | ||
|
||
Then, install the latest version of `cross`: | ||
|
||
```shell | ||
cargo install --git https://github.com/cross-rs/cross.git cross | ||
``` | ||
|
||
Now, you can cross-compile for `aarch64-unknown-freebsd`: | ||
|
||
```shell | ||
rustup override set nightly | ||
cross build --target aarch64-unknown-freebsd --release | ||
``` | ||
|
||
The built binary can be found in `target/aarch64-unknown-freebsd/release/`. |