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

Mac Arm64 Support & Example? #7

Closed
cjgratacos opened this issue Dec 21, 2021 · 5 comments
Closed

Mac Arm64 Support & Example? #7

cjgratacos opened this issue Dec 21, 2021 · 5 comments
Labels
arm64 darwin enhancement New feature or request help wanted Extra attention is needed

Comments

@cjgratacos
Copy link

cjgratacos commented Dec 21, 2021

Thanks for the awesome tool.

I was wondering if it is possible to cross compile to aarch64-apple-darwin rust target (arm64 darwin) since this is using https://github.com/tpoechtrager/osxcross? If so can an example be given and update the read me with it? I know the Readme talks about it but it is not clear and it doesn't work.

Example of how I am trying to compile the project:

docker run --rm \
    --volume "${PWD}/":/root/src:z \
    --workdir /root/src \
    joseluisq/rust-linux-darwin-builder:1.57.0 \
    sh -c "rustup target add aarch64-apple-darwin && CC=oa64-clang CXX=oa64-clang++ LIBZ_SYS_STATIC=1 cargo build --release --target aarch64-apple-darwin"
@cjgratacos cjgratacos changed the title Mac Arm64 Suppor & Example? Mac Arm64 Support & Example? Dec 21, 2021
@joseluisq joseluisq added enhancement New feature or request help wanted Extra attention is needed labels Dec 21, 2021
@joseluisq
Copy link
Owner

The image is amd64 only. So it's not supported out-of-the-box from the Docker image standing point.
However yeah it's possible to cross compile to aarch64-apple-darwin since we are using osxcross but this involves more setup to do.

So this issue should be a nice to have feature request.

@xrl
Copy link

xrl commented Dec 21, 2021

What is the more work required? I started building aarch64 (but don't have an ARM64 Darwin laptop yet) with:

    rustup target add aarch64-apple-darwin      && \

added in to the Dockerfile. Then in my app's CI I can build the binary with:

    cargo build --target aarch64-apple-darwin --release

and my cargo-config.toml has this entry:

[target.aarch64-apple-darwin]
linker = "arm64e-apple-darwin21.1-clang"
ar = "arm64e-apple-darwin21.1-ar"

with all three of those tweaks, my CI builds go through, no error. The compiled aarch64 binary looks about the right size as the other artifacts. Your mileage may vary!

@joseluisq
Copy link
Owner

joseluisq commented Dec 21, 2021

Yeah, that also was my impression at first glance. Like touching cargo config and adding the corresponding toolchain.
Honestly I didn't tried myself aarch64-apple-darwin since I don't target it.
But as I said should work unless the reporter needs some specific things.

@cjgratacos
Copy link
Author

Sorry for the delay response, but the following works:

  • adding the following to ./.cargo/config.toml
[target.aarch64-apple-darwin]
linker = "arm64e-apple-darwin21.1-clang"
ar = "arm64e-apple-darwin21.1-ar"
  • running the following on the root of the project:
docker run --rm \
    --volume "${PWD}/":/root/src:z \
    --workdir /root/src \
    joseluisq/rust-linux-darwin-builder:1.60.0 \
    sh -c "rustup target add aarch64-apple-darwin && CC=oa64-clang CXX=oa64-clang++ LIBZ_SYS_STATIC=1 cargo build --release --target aarch64-apple-darwin"

Thanks to @xrl for the suggestion :)

@joseluisq
Copy link
Owner

Released on v1.65.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm64 darwin enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants