-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add an aarch64
linux binary to all new releases
#152
Merged
Merged
Conversation
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
afinetooth
changed the title
First working version for this approach.
Approach 1: Sep 11, 2024
luislavena
's crystal-xbuild-container
> First working version for this approach.
afinetooth
changed the title
Approach 1:
Approach 1: Sep 11, 2024
luislavena
's crystal-xbuild-container
> First working version for this approach.luislavena
's crystal-xbuild-container
afinetooth
changed the title
Approach 1:
Approach 1: Using Sep 11, 2024
luislavena
's crystal-xbuild-container
luislavena
's crystal-xbuild
container
afinetooth
changed the title
Approach 1: Using
Approach 1: Sep 16, 2024
luislavena
's crystal-xbuild
containercrystal-xbuild
container
afinetooth
changed the title
Approach 1:
Add Sep 18, 2024
crystal-xbuild
containeraarch64
linux binary to all new releases (crystal-xbuild
container method)
afinetooth
changed the title
Add
Add Sep 18, 2024
aarch64
linux binary to all new releases (crystal-xbuild
container method)aarch64
linux binary to all new releases
afinetooth
changed the title
Add
Add an Sep 18, 2024
aarch64
linux binary to all new releasesaarch64
linux binary to all new releases
Pull Request Test Coverage Report for Build 10966290363Details
💛 - Coveralls |
…remove old/unused targets.
…te all variables everywhere in our shell script).
…re our first release with the new ones.
…efile targets in test-binaries.yml workflow.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes:
Add an
aarch64
linux binary to all new releasesCross-compiling
coverage-reporter
foraarch64
proved challenging. We tried several approaches from the Crystal community, but settled on thiscrystal-xbuild
containers method, which produced our first success.☑️ Checklist for
crystal-xbuild
containers method:coverage-reporter
context🛠️ Usage:
1. Build the
xbuild-container
:2. Run the build command(s):
These commands cross-compile
coverage-reporter
for different architectures; right now just:x86_64
andaarch64
.For convenience, a single command lets us compile and strip all the linux binaries we need:
These sub-targets compile
coverage-reporter
for specific architectures:Similar targets strip each binary:
3. Package the binaries for distribution
This command packages the binaries for a release:
Note: The release procedure itself is handled by the
release
job in our.github/workflows/build.yml
workflow, which is triggered when we push a new tag.✅ Testing the binaries:
While you can examine the binaries on your local machine:
You probably can't run them due to an architecture mismatch:
For instance, on MacOS (
arm64
) I get an exec format error when I try to run the linuxaarch64
executable:So, to create a test environment, you can run the original
crystal-xbuild
container, with this command:Or, better, run one of these two (2) architecture-specific Ubuntu containers, with these commands:
Example:
Testing the
aarch64
executable in an Ubuntu 22.04 (aarch64
) container:Note:
In our final release artifacts, tarballs of each architecture-specific binary will untar to a binary named
coveralls
so it's ready to use with commands,coveralls report
,coveralls done
, etc.📖 About the
crystal-xbuild
containers methodThe approach was created by Crystal community member, luislavena, and is covered in his 2-part blog post (Part 1 | Part 2). It aligns with best practices offered by the official Crystal Doc on Static Linking (which highlights known difficulties in compiling static binaries of Crystal apps).
Note: This approach does not make use of Docker's
buildx
extension for cross-compilation. Instead, "xbuild" here is a generic term that stands for "cross-build."Components:
Cross-compilation via Docker: The
crystal-xbuild
container is a pre-configured environment for cross-compiling multi-architecture builds, targetingx86_64
,aarch64
, andarm64
.crystal-xbuild
is based on a custom docker image namedhydrofoil-crystal
:luislavena
zig
cross-compilation tool.Key scripts:
xbuild.sh
: Handles the core cross-compilation logic with a modular approach:-lunwind
formusl
,libiconv
formacOS
).zig cc
simplifies linking multiple architecture-specific librariesDockerfile
: Installs the dependencies required for cross-compilation into the base image (zig
, etc.)Makefile
: Holds convenient targets for building and testing our new cross-platform binaries.homebrew-downloader.cr
: Not used. Fetches theMacOS
libraries required for cross-compliation from Homebrew's API.homebrew-bump-formula
action.Core differentiator: Zig
Zig is the standout differentiator for this approach. It has robust support for cross-compilation on multiple platforms and simplifies the build process. Read more here and here.
⏭️ Pecadillos
Known Issues / Opportunities:
aarch64
binary - Harmless but annoying. Relates toclang
version used inzig
right now. Tracking issue here. See comment oncompile-aarch64
target inMakefile
for more.crystal build
vs.shards build
- We would prefer to use ofshards build --production
instead ofcrystal build --release
as used currently inscripts/xbuild.sh
, but it's a low priority for now since our stripped binaries are ~7.5MB
each.hydrofoil-crystal
is hosted at GitHub Packages and is not likely to disappear anytime soon, it might be wise to maintain our own registry of base images.