@@ -4,6 +4,7 @@ class Crystal < Formula
4
4
license "Apache-2.0"
5
5
6
6
stable do
7
+ # TODO: Replace arm64 linux bootstrap with official when available
7
8
url "https://github.com/crystal-lang/crystal/archive/refs/tags/1.16.1.tar.gz"
8
9
sha256 "07d2ddb619aa15b30f16f8fafd6417e5e3a0fb6d97ce4f328e683796486976cf"
9
10
@@ -43,11 +44,6 @@ class Crystal < Formula
43
44
44
45
uses_from_macos "libffi" # for the interpreter
45
46
46
- on_linux do
47
- # There is no bootstrap compiler for arm64 Linux
48
- depends_on arch : :x86_64
49
- end
50
-
51
47
# It used to be the case that every new crystal release was built from a
52
48
# previous release, except patches. Crystal is updating its policy to
53
49
# allow 4 minor releases of compatibility unless otherwise specified.
@@ -66,6 +62,16 @@ class Crystal < Formula
66
62
end
67
63
68
64
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
69
75
on_intel do
70
76
url "https://github.com/crystal-lang/crystal/releases/download/#{ boot_version . major_minor_patch } /crystal-#{ boot_version } -linux-x86_64.tar.gz"
71
77
# version boot_version
@@ -86,7 +92,15 @@ def install
86
92
non_keg_only_runtime_deps = deps . filter_map { |dep | dep . to_formula unless dep . build? }
87
93
. reject ( &:keg_only? )
88
94
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
90
104
ENV . append_path "PATH" , "boot/bin"
91
105
ENV [ "LLVM_CONFIG" ] = llvm . opt_bin /"llvm-config"
92
106
ENV [ "CRYSTAL_LIBRARY_PATH" ] = ENV [ "HOMEBREW_LIBRARY_PATHS" ]
0 commit comments