Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add aarch64-unknown-freebsd image #1271

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/1271.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"description": "add aarch64-unknown-freebsd image.",
"type": "added",
"breaking": false
}
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/b_issue_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ body:
- aarch64-linux-android
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- aarch64-unknown-freebsd
- arm-linux-androideabi
- arm-unknown-linux-gnueabi
- arm-unknown-linux-gnueabihf
Expand Down
38 changes: 38 additions & 0 deletions docker/Dockerfile.aarch64-unknown-freebsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive

COPY common.sh lib.sh /
RUN /common.sh

COPY cmake.sh /
RUN /cmake.sh

COPY xargo.sh /
RUN /xargo.sh

RUN echo "export ARCH=aarch64" > /freebsd-arch.sh
COPY freebsd-common.sh /
COPY freebsd.sh /
RUN /freebsd.sh

COPY freebsd-install.sh /
COPY freebsd-extras.sh /
RUN /freebsd-extras.sh

ENV CROSS_TOOLCHAIN_PREFIX=aarch64-unknown-freebsd12-
ENV CROSS_SYSROOT=/usr/local/aarch64-unknown-freebsd12

COPY freebsd-gcc.sh /usr/bin/"$CROSS_TOOLCHAIN_PREFIX"gcc.sh
COPY toolchain.cmake /opt/toolchain.cmake

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 \
CXX_aarch64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_aarch64_unknown_freebsd=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_freebsd="--sysroot=$CROSS_SYSROOT" \
AARCH64_UNKNOWN_FREEBSD_OPENSSL_DIR="$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=FreeBSD \
CROSS_CMAKE_SYSTEM_PROCESSOR=amd64 \
CROSS_CMAKE_CRT=freebsd \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
3 changes: 3 additions & 0 deletions docker/freebsd-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ set -euo pipefail

export FREEBSD_ARCH=
case "${ARCH}" in
aarch64) # releases are under http://ftp.freebsd.org/pub/FreeBSD/releases/
FREEBSD_ARCH=arm64 # http://ftp.freebsd.org/pub/FreeBSD/releases/arm64/
;;
x86_64)
FREEBSD_ARCH=amd64
;;
Expand Down
6 changes: 6 additions & 0 deletions docker/freebsd-extras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ set -euo pipefail
# shellcheck disable=SC1091
. freebsd-install.sh

case "${FREEBSD_ARCH}" in
arm64) # extras mirrors are under https://pkg.freebsd.org/
FREEBSD_ARCH=aarch64 # https://pkg.freebsd.org/FreeBSD:13:aarch64/
;;
esac

main() {
apt-get update && apt-get install --assume-yes --no-install-recommends \
curl \
Expand Down
5 changes: 5 additions & 0 deletions src/docker/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ pub mod tests {
assert_eq!(arch!("arm-unknown-linux-gnueabihf")?, Architecture::Arm);
assert_eq!(arch!("armv7-unknown-linux-gnueabihf")?, Architecture::Arm);
assert_eq!(arch!("aarch64-unknown-linux-gnu")?, Architecture::Arm64);
assert_eq!(arch!("aarch64-unknown-freebsd")?, Architecture::Arm64);
assert_eq!(arch!("mips-unknown-linux-gnu")?, Architecture::Mips);
assert_eq!(
arch!("mips64-unknown-linux-gnuabi64")?,
Expand All @@ -424,6 +425,10 @@ pub mod tests {
fn os_from_target() -> Result<()> {
assert_eq!(Os::from_target(&t!("x86_64-apple-darwin"))?, Os::Darwin);
assert_eq!(Os::from_target(&t!("x86_64-unknown-freebsd"))?, Os::Freebsd);
assert_eq!(
Os::from_target(&t!("aarch64-unknown-freebsd"))?,
Os::Freebsd
);
assert_eq!(Os::from_target(&t!("x86_64-unknown-netbsd"))?, Os::Netbsd);
assert_eq!(Os::from_target(&t!("sparcv9-sun-solaris"))?, Os::Solaris);
assert_eq!(Os::from_target(&t!("sparcv9-sun-illumos"))?, Os::Illumos);
Expand Down
5 changes: 5 additions & 0 deletions src/docker/provided_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ pub static PROVIDED_IMAGES: &[ProvidedImage] = &[
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
sub: None
},
ProvidedImage {
name: "aarch64-unknown-freebsd",
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
sub: None
},
ProvidedImage {
name: "x86_64-unknown-netbsd",
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ impl TargetTriple {
"x86_64-unknown-dragonfly" => Some("dragonflybsd-amd64"),
"i686-unknown-freebsd" => Some("freebsd-i386"),
"x86_64-unknown-freebsd" => Some("freebsd-amd64"),
"aarch64-unknown-freebsd" => Some("freebsd-arm64"),
"x86_64-unknown-netbsd" => Some("netbsd-amd64"),
"sparcv9-sun-solaris" => Some("solaris-sparc"),
"x86_64-sun-solaris" => Some("solaris-amd64"),
Expand Down
8 changes: 8 additions & 0 deletions targets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ cpp = true
dylib = true
std = true

[[target]]
target = "aarch64-unknown-freebsd"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
Copy link
Member

@Emilgardis Emilgardis Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ci test failed with

     Checking foo v0.1.0 (/home/runner/work/cross/cross/target/tmp/tmp.pcmLAmfkzI)
     Running `rustc --crate-name foo --edition=2021 tmp.pcmLAmfkzI/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=12b0d6c0320165c1 -C extra-filename=-12b0d6c0320165c1 --out-dir /target/aarch64-unknown-freebsd/debug/deps --target aarch64-unknown-freebsd -C linker=aarch64-unknown-freebsd12-gcc.sh -L dependency=/target/aarch64-unknown-freebsd/debug/deps -L dependency=/target/debug/deps`
error[E0463]: can't find crate for `core`
  |
  = note: the `aarch64-unknown-freebsd` target may not be installed
  = help: consider downloading the target with `rustup target add aarch64-unknown-freebsd`

error[E0463]: can't find crate for `compiler_builtins`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `foo` due to 2 previous errors

Caused by:
  process didn't exit successfully: `rustc --crate-name foo --edition=2021 tmp.pcmLAmfkzI/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=12b0d6c0320165c1 -C extra-filename=-12b0d6c0320165c1 --out-dir /target/aarch64-unknown-freebsd/debug/deps --target aarch64-unknown-freebsd -C linker=aarch64-unknown-freebsd12-gcc.sh -L dependency=/target/aarch64-unknown-freebsd/debug/deps -L dependency=/target/debug/deps` (exit status: 1)
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
[cross] warning: rust-std is not available for aarch64-unknown-freebsd
[cross] note: you may need to build components for the target via `-Z build-std=<components>` or in your cross configuration specify `target.aarch64-unknown-freebsd.build-std`
              the available components are core, std, alloc, and proc_macro
Error: Process completed with exit code 101.

I do not understand why though, this is the check for if the target needs to be installed or not, and for some reason rust-std-aarch-unknown-freebsd is not found here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, it's tier 3, thought it was t2, can you add build-std = true to the target

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ rustup component add rust-std-aarch64-unknown-freebsd --toolchain stable-x86_64-unknown-linux-gnu
error: toolchain 'stable-x86_64-unknown-linux-gnu' does not contain component 'rust-std-aarch64-unknown-freebsd' for target 'x86_64-unknown-linux-gnu'
note: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey thanks for digging in @Emilgardis

Sorry I've been away on leave for a couple of weeks, and been catching up with other stuff, have kicked that off with build-std = true now

build-std = true

[[target]]
target = "x86_64-unknown-netbsd"
os = "ubuntu-latest"
Expand Down