Skip to content

crystal: use 84codes deb to bootstrap arm64 linux #220398

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

Merged
merged 1 commit into from
Apr 19, 2025
Merged
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
26 changes: 20 additions & 6 deletions Formula/c/crystal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Crystal < Formula
license "Apache-2.0"

stable do
# TODO: Replace arm64 linux bootstrap with official when available
url "https://github.com/crystal-lang/crystal/archive/refs/tags/1.16.1.tar.gz"
sha256 "07d2ddb619aa15b30f16f8fafd6417e5e3a0fb6d97ce4f328e683796486976cf"

Expand Down Expand Up @@ -43,11 +44,6 @@ class Crystal < Formula

uses_from_macos "libffi" # for the interpreter

on_linux do
# There is no bootstrap compiler for arm64 Linux
depends_on arch: :x86_64
end

# It used to be the case that every new crystal release was built from a
# previous release, except patches. Crystal is updating its policy to
# allow 4 minor releases of compatibility unless otherwise specified.
Expand All @@ -66,6 +62,16 @@ class Crystal < Formula
end

on_linux do
on_arm do
# NOTE: Since there are no official arm64 linux builds, we use the recommended[^1]
# community-maintained builds. Upstream CI also uses 84codes docker images[^2].
# The version used is 1.11.0 as there was an issue building with 1.10.1.
#
# [^1]: https://github.com/crystal-lang/crystal/issues/9833#issuecomment-1766007872
# [^2]: https://github.com/crystal-lang/crystal/blob/master/.github/workflows/aarch64.yml#L70
url "https://packagecloud.io/84codes/crystal/packages/any/any/crystal_1.11.0-124_arm64.deb/download.deb?distro_version_id=35"
sha256 "fc42e49f703a9b60c81a87be67ea68726125cf7fddce2d4cafceb4324dca1ec8"
end
on_intel do
url "https://github.com/crystal-lang/crystal/releases/download/#{boot_version.major_minor_patch}/crystal-#{boot_version}-linux-x86_64.tar.gz"
# version boot_version
Expand All @@ -86,7 +92,15 @@ def install
non_keg_only_runtime_deps = deps.filter_map { |dep| dep.to_formula unless dep.build? }
.reject(&:keg_only?)

resource("boot").stage "boot"
if OS.linux? && Hardware::CPU.arm?
resource("boot").stage do
system "ar", "x", Dir["*.deb"].first
system "tar", "xf", "data.tar.gz"
(buildpath/"boot").install Dir["usr/*"]
end
else
resource("boot").stage "boot"
end
ENV.append_path "PATH", "boot/bin"
ENV["LLVM_CONFIG"] = llvm.opt_bin/"llvm-config"
ENV["CRYSTAL_LIBRARY_PATH"] = ENV["HOMEBREW_LIBRARY_PATHS"]
Expand Down
Loading