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

julia: build on ARM #96194

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
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
90 changes: 4 additions & 86 deletions Formula/julia.rb
Original file line number Diff line number Diff line change
@@ -1,69 +1,26 @@
class Julia < Formula
desc "Fast, Dynamic Programming Language"
homepage "https://julialang.org/"
url "https://github.com/JuliaLang/julia/releases/download/v1.8.0-beta1/julia-1.8.0-beta1.tar.gz"
sha256 "84e5a4551fb607ed8142a6da6632cbb52fca8fbbd79c5275c898bdf22cef41d2"
license all_of: ["MIT", "BSD-3-Clause", "Apache-2.0", "BSL-1.0"]
head "https://github.com/JuliaLang/julia.git", branch: "master"

stable do
url "https://github.com/JuliaLang/julia/releases/download/v1.7.2/julia-1.7.2.tar.gz"
sha256 "0847943dd65001f3322b00c7dc4e12f56e70e98c6b798ccbd4f02d27ce161fef"

# Patches for compatibility with LLVM 13
patch do
url "https://github.com/JuliaLang/julia/commit/677ce6d3adc2f70886f72795b0e5c739e75730ee.patch?full_index=1"
sha256 "ebcedfbc61b6cc77c0dd9aebb9f1dfa477326241bf5a54209533e4886aad5af3"
end

patch do
url "https://github.com/JuliaLang/julia/commit/47f9139e88917813cb7beee5e690c48c2ac65de4.patch?full_index=1"
sha256 "cdc41494b2a163ca363da8ea9bcf27d7541a6dc9e6b4eff72f6c8ff8ce1b67b6"
end

patch do
url "https://github.com/JuliaLang/julia/commit/1eb063f1957b2e287ad0c7435debc72af58bb6f1.patch?full_index=1"
sha256 "d95b9fb5f327bc3ac351c35317a776ef6a46c1cdff248562e70c76e58eb9a903"
end

# Backported from:
# https://github.com/JuliaLang/julia/commit/f8c918b00f7c62e204d324a827e2ee2ef05bb66a
patch do
url "https://raw.githubusercontent.com/archlinux/svntogit-community/074e62e4e946201779d2d6df9a261c91d111720f/trunk/f8c918b0.patch"
sha256 "bc6c85cbbca489ef0b2876dbeb6ae493c11573e058507b8bcb9e01273bc3a38c"
end

# Backported from:
# https://github.com/JuliaLang/julia/commit/6330398088e235e4d4fdbda38c41c87e02384edb.patch
patch do
url "https://raw.githubusercontent.com/archlinux/svntogit-community/df73abb8162e31e6541d2143d1db5f9f1d70b632/trunk/63303980.patch"
sha256 "ce9cd140c3bc39987d60340bf365d6238e79cf4d5385494272c49c64af22ef78"
end

# Fix compatibility with LibGit2 1.2.0+
# https://github.com/JuliaLang/julia/pull/43250
patch do
url "https://github.com/JuliaLang/julia/commit/4d7fc8465ed9eb820893235a6ff3d40274b643a7.patch?full_index=1"
sha256 "3a34a2cd553929c2aee74aba04c8e42ccb896f9d491fb677537cd4bca9ba7caa"
end
end

bottle do
sha256 cellar: :any, monterey: "1952d5d5e006180fc02ca3b362cdee7e3c25f2eed26a4e58bda1b1cf75f2b52c"
sha256 cellar: :any, big_sur: "6bf092ffc5838d21cbaf35ba5330e8674ac79f4a314c6321d042b6b7eb9a78c7"
sha256 cellar: :any, catalina: "cbcd464ba9cb10e78920e3dc38c23bd4b61347527ed3737ec61e71d390a83441"
sha256 cellar: :any_skip_relocation, x86_64_linux: "741aa32d988bcd48dba2f51ea58a21ef0461719768e14e53544aadccaa60d386"
end

# Requires the M1 fork of GCC to build
# https://github.com/JuliaLang/julia/issues/36617
depends_on arch: :x86_64
depends_on "cmake" => :build # Needed to build LLVM
depends_on "ca-certificates"
depends_on "curl"
depends_on "gcc" # for gfortran
depends_on "gmp"
depends_on "libgit2"
depends_on "libnghttp2"
depends_on "libssh2"
depends_on "llvm"
depends_on "mbedtls@2"
depends_on "mpfr"
depends_on "openblas"
Expand All @@ -89,38 +46,7 @@ class Julia < Formula

fails_with gcc: "5"

# Fix segfaults with Curl 7.81. We need to patch the contents of a tarball, so this can't be a `patch` block.
# https://github.com/JuliaLang/Downloads.jl/issues/172
resource "curl-patch" do
url "https://raw.githubusercontent.com/archlinux/svntogit-community/6751794c82949589805db950119afba77549554a/trunk/julia-curl-7.81.patch"
sha256 "710587dd88c7698dc5cdf47a1a50f6f144b584b7d9ffb85fac3f5f79c65fce11"
end

# Fix compatibility with LibGit2 1.4.0+
patch do
url "https://raw.githubusercontent.com/archlinux/svntogit-community/cd813138d8a6fd496d0972a033d55028613be06d/trunk/julia-libgit-1.4.patch"
sha256 "cfe498a090d0026b92f9db4ed65ac3818c2efa5ec83bcefed728d27abff73081"
end

def install
# Fix segfaults with Curl 7.81. Remove when this is resolved upstream.
srccache = buildpath/"stdlib/srccache"
srccache.install resource("curl-patch")

cd srccache do
tarball = Pathname.glob("Downloads-*.tar.gz").first
system "tar", "-xzf", tarball
extracted_dir = Pathname.glob("JuliaLang-Downloads.jl-*").first
to_patch = extracted_dir/"src/Curl/Multi.jl"
system "patch", to_patch, "julia-curl-7.81.patch"
system "tar", "-czf", tarball, extracted_dir

md5sum = Digest::MD5.file(tarball).hexdigest
sha512sum = Digest::SHA512.file(tarball).hexdigest
(buildpath/"deps/checksums"/tarball/"md5").atomic_write md5sum
(buildpath/"deps/checksums"/tarball/"sha512").atomic_write sha512sum
end

# Build documentation available at
# https://github.com/JuliaLang/julia/blob/v#{version}/doc/build/build.md
args = %W[
Expand All @@ -129,7 +55,6 @@ def install
prefix=#{prefix}
sysconfdir=#{etc}
USE_SYSTEM_CSL=1
USE_SYSTEM_LLVM=1
USE_SYSTEM_LIBUNWIND=1
USE_SYSTEM_PCRE=1
USE_SYSTEM_OPENLIBM=1
Expand Down Expand Up @@ -160,12 +85,10 @@ def install
# Values adapted from https://github.com/JuliaCI/julia-buildbot/blob/master/master/inventory.py
march = if build.head?
"native"
elsif Hardware::CPU.arm?
"armv8-a"
else
Hardware.oldest_cpu
end
args << "MARCH=#{march}"
args << "MARCH=#{march}" unless Hardware::CPU.arm?

cpu_targets = ["generic"]
cpu_targets += if Hardware::CPU.arm?
Expand Down Expand Up @@ -210,11 +133,6 @@ def install
s.change_make_var! "LOCALBASE", HOMEBREW_PREFIX
end

# Don't try to use patchelf on our libLLVM.so. This is only present on 1.7.1.
patchelf = Regexp.escape("$(PATCHELF)")
shlib_ext = Regexp.escape(".$(SHLIB_EXT)")
inreplace "Makefile", %r{^\s+#{patchelf} --set-rpath .*/libLLVM#{shlib_ext}$}, "" if OS.linux? && build.stable?

# Remove library versions from MbedTLS_jll, nghttp2_jll and libLLVM_jll
# https://git.archlinux.org/svntogit/community.git/tree/trunk/julia-hardcoded-libs.patch?h=packages/julia
%w[MbedTLS nghttp2 LibGit2 OpenLibm].each do |dep|
Expand Down
1 change: 1 addition & 0 deletions audit_exceptions/unstable_allowlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"automysqlbackup": "3.0-rc",
"aview": "1.3.0rc",
"ftgl": "2.1.3-rc",
"julia": "1.8.0-beta",
"libcaca": "0.99b",
"librasterlite2": "1.1.0-beta",
"premake": "4.4-beta",
Expand Down