Skip to content

Commit 3777589

Browse files
committed
crystal: use 84codes deb to bootstrap arm64 linux
1 parent b041e2d commit 3777589

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Formula/c/crystal.rb

+20-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Crystal < Formula
44
license "Apache-2.0"
55

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

@@ -43,11 +44,6 @@ class Crystal < Formula
4344

4445
uses_from_macos "libffi" # for the interpreter
4546

46-
on_linux do
47-
# There is no bootstrap compiler for arm64 Linux
48-
depends_on arch: :x86_64
49-
end
50-
5147
# It used to be the case that every new crystal release was built from a
5248
# previous release, except patches. Crystal is updating its policy to
5349
# allow 4 minor releases of compatibility unless otherwise specified.
@@ -66,6 +62,16 @@ class Crystal < Formula
6662
end
6763

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

89-
resource("boot").stage "boot"
95+
if OS.linux? && Hardware::CPU.arm?
96+
resource("boot").stage do
97+
system "ar", "x", Dir["*.deb"].first
98+
system "tar", "xf", "data.tar.xz"
99+
(buildpath/"boot").install Dir["usr/*"]
100+
end
101+
else
102+
resource("boot").stage "boot"
103+
end
90104
ENV.append_path "PATH", "boot/bin"
91105
ENV["LLVM_CONFIG"] = llvm.opt_bin/"llvm-config"
92106
ENV["CRYSTAL_LIBRARY_PATH"] = ENV["HOMEBREW_LIBRARY_PATHS"]

0 commit comments

Comments
 (0)