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

Build native image for Linux aarch64 #1

Merged
merged 1 commit into from
Jan 3, 2023

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Jan 3, 2023

⚠️ sbt/sbt#7108 needs to be merged before to be able to generate the correct binary!
(The workflows from this pull request need to re-run afterwards)


It's not possible to cross compile with native-image currently, not even for a different architecture on the same OS (like x86_64 -> aarch64 in Linux; unlike gcc where you could just install gcc-aarch64-linux-gnu), see

So that's why it is necessary to run the GraalVM on the system you want to build a binary for. So it seems the only viable workaround is to make use of https://github.com/uraimo/run-on-arch-action. That is what

  • coursier is using here
  • scala-ci is using here

As a result of this PR, you can download the aarch64 artifact here in my fork already: https://github.com/mkurz/sbtn-dist/actions/runs/3825630367

Eventually, this PR is needed to fix

- os: macOS-latest
uploaded_filename: sbtn-x86_64-apple-darwin
local_path: client/target/bin/sbtn
- os: ubuntu-latest
uploaded_filename: sbtn-x86_64-pc-linux
local_path: client/target/bin/sbtn
- os: ubuntu-22.04
uploaded_filename: sbtn-aarch64-pc-linux
local_path: client/target/bin/sbtn
Copy link
Member Author

Choose a reason for hiding this comment

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

ubuntu-22.04 and ubuntu-latest refer to the same image.
However, adding ubuntu-22.04 is just a stupid workaround so we kick off a extra job that generates us the aarch64 binary.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm.. I thought I tried that, but it didn't work immediately, so I just use the now merged approach... Anyway, not so important I guess.

@@ -31,6 +33,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: sbt/sbt
ref: 1.8.x
Copy link
Member Author

@mkurz mkurz Jan 3, 2023

Choose a reason for hiding this comment

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

@eed3si9n I think it would be a good idea to define the branch here. Like now I would like to use the current stable sbt branch (1.8.x).
Would it make sense to introduce a 1.8.x and 1.9.x branch here in the sbt/sbtn-dist repository as well, which refer to the according sbt branch in its native.yml? And even remove the develop branch?
What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Yea, thus far I've only had to build sbtn for fresh new minor releases, so assuming the default branch has been ok.

#apt-get update -q && apt-get install -q -y sbt
# Workaround:
curl -Ls https://scala.jfrog.io/artifactory/debian/sbt-1.8.0.deb -o sbt-1.8.0.deb
apt install -y ./sbt-1.8.0.deb
Copy link
Member Author

Choose a reason for hiding this comment

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

Another alternative to install sbt inside this QEMU virtual machine would be to use sdkman:

curl -s "https://get.sdkman.io" | bash
source "/root/.sdkman/bin/sdkman-init.sh"
sdk install sbt

We could also use coursier, like seen in the scala-ci or coursier repo... However I didn't do that since coursier does not publish a aarch64 64k page-size compatible binary yet (but soon 😉), so I couldn't test that locally on my machine... (It should work in the CI virtual machine though)

Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

So that's why it is necessary to run the GraalVM on the system you want to build a binary for. So it seems the only viable workaround is to make use of https://github.com/uraimo/run-on-arch-action.

That's amazing. I didn't know such magic was possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants