Skip to content

llvm lld flang wasi-runtimes 21.1.0-rc3 (pre-release) #234231

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

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions Aliases/lld@21
1 change: 1 addition & 0 deletions Aliases/llvm@21
14 changes: 12 additions & 2 deletions Formula/a/adaptivecpp.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
class Adaptivecpp < Formula
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Drop commit as downgraded LLVM instead:

desc "SYCL and C++ standard parallelism for CPUs and GPUs"
homepage "https://adaptivecpp.github.io/"
url "https://github.com/AdaptiveCpp/AdaptiveCpp/archive/refs/tags/v25.02.0.tar.gz"
sha256 "8cc8a3be7bb38f88d7fd51597e0ec924b124d4233f64da62a31b9945b55612ca"
license "BSD-2-Clause"
revision 1
head "https://github.com/AdaptiveCpp/AdaptiveCpp.git", branch: "develop"

stable do
url "https://github.com/AdaptiveCpp/AdaptiveCpp/archive/refs/tags/v25.02.0.tar.gz"
sha256 "8cc8a3be7bb38f88d7fd51597e0ec924b124d4233f64da62a31b9945b55612ca"

# Backport support for LLVM 21
patch do
url "https://github.com/AdaptiveCpp/AdaptiveCpp/commit/623aa0b1840c5ccd7a45d3e8b228f1bff5257056.patch?full_index=1"
sha256 "d3b8708ded954f04b87ad22254fd949c1d584d6de7a3f8a7e978ff715ca1a33d"
end
end

bottle do
sha256 arm64_sequoia: "fa1c355b2af0934de4aae2fdb882f7befae852e5523ed4b3f4270d69bfd46edf"
sha256 arm64_sonoma: "c01a61e3a4629d1c1c52ba7d9f5f0618f6b7f6a246d25da96c4e0ed481f0b6bc"
Expand All @@ -26,7 +36,7 @@
depends_on "libomp"
end

def install

Check failure on line 39 in Formula/a/adaptivecpp.rb

View workflow job for this annotation

GitHub Actions / Linux arm64

`brew install --verbose --formula --build-bottle adaptivecpp` failed on Linux arm64!

-- Found LibEdit: /home/linuxbrew/.linuxbrew/include (found version "2.11") -- Found ZLIB: /home/linuxbrew/.linuxbrew/lib/libz.so (found version "1.3.1") -- Found zstd: /home/linuxbrew/.linuxbrew/lib/libzstd.so -- Building AdaptiveCpp against LLVM configured from /home/linuxbrew/.linuxbrew/lib/cmake/llvm -- Selecting clang: /home/linuxbrew/.linuxbrew/Cellar/llvm/21.1.0-rc3/bin/clang++ CMake Error at CMakeLists.txt:459 (message): LLVM versions greater than 20 are not yet tested/supported, use -DACPP_EXPERIMENTAL_LLVM=ON if you still wish to try your luck. -- Using clang include directory: /home/linuxbrew/.linuxbrew/Cellar/llvm/21.1.0-rc3/lib/clang/21/include/.. -- Looking for C++ include filesystem -- Looking for C++ include filesystem - found -- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED -- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED - Success -- Performing Test HAS_MCPU_NATIVE -- Performing Test HAS_MCPU_NATIVE - Success -- Performing Test HAS_MARCH_NATIVE -- Performing Test HAS_MARCH_NATIVE - Success -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Found OpenMP_C: -fopenmp (found version "4.5") -- Found OpenMP_CXX: -fopenmp (found version "4.5") -- Found OpenMP: TRUE (found version "4.5") CMake Warning at src/runtime/CMakeLists.txt:364 (message): Could not find NUMA -- Default compilation target(s): generic -- Configuring incomplete, errors occurred! ==> Formula Path: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/a/adaptivecpp.rb ==> Configuration HOMEBREW_VERSION: 4.6.6-27-g566290d ORIGIN: https://github.com/Homebrew/brew HEAD: 566290dcbc776f6ba1a75bbfa16fe860cb821409 Last commit: 15 hours ago Branch: main Core tap HEAD: 693c3c7987414ccaeee290f5a2d93f5733d5b14f Core tap last commit: 5 hours ago Core tap JSON: 24 Aug 12:13 UTC HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew HOMEBREW_CASK_OPTS: [] HOMEBREW_COLOR: set HOMEBREW_CURL_PATH: /usr/bin/curl HOMEBREW_DOWNLOAD_CONCURRENCY: 8 HOMEBREW_FAIL_LOG_LINES: 150 HOMEBREW_FORBID_PACKAGES_FROM_PATHS: set HOMEBREW_GITHUB_API_TOKEN: set HOMEBREW_GIT_EMAIL: [email protected] HOMEBREW_GIT_NAME: BrewTestBot HOMEBREW_GIT_PATH: /usr/bin/git HOMEBREW_LOGS: /github/home/bottles/logs HOMEBREW_MAKE_JOBS: 4 HOMEBREW_NO_AUTO_UPDATE: set HOMEBREW_NO_EMOJI: set HOMEBREW_NO_ENV_HINTS: set HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: set HOMEBREW_NO_INSTALL_FROM_API: set HOMEBREW_SORBET_RUNTIME: set HOMEBREW_VERIFY_ATTESTATIONS: set Homebrew Ruby: 3.4.5 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/3.4.5/bin/ruby CPU: quad-core 64-bit arm Clang: 21.1.0 Git: 2.34.1 => /usr/bin/git Curl: 7.81.0 => /usr/bin/curl Kernel: Linux 6.8.0-1029-azure aarch64 GNU/Linux OS: Ubuntu 22.04.5 LTS Host glibc: 2.35 /usr/bin/gcc: 11.4.0 /usr/bin/ruby: N/A glibc: N/A gcc@11: N/A gcc: N/A xorg: N/A ==> ENV HOMEBREW_CC: gcc-11 HOMEBREW_CXX: g++-11 MAKEFLAGS: -j4 CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew/opt/berkeley-db@5:/home/linuxbrew/.linuxbrew/opt/binutils:/home/linuxbrew/.linuxbrew PKG_CONFIG_PATH: /home/linuxbrew/.linuxbrew/opt/icu4c@77/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/xz/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/lz4/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/zlib/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/zstd/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/bzip2/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/mpdecimal/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/openssl@3/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/ncurses/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/readline/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/sqlite/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/expat/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/libedit/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/libffi/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/z3/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/elfutils/lib/pkgconfig PKG_CONFIG_LIBDIR: HOMEBREW_MAKE_JOBS: 4 HOMEBREW_GIT: /usr/bin/git

Check failure on line 39 in Formula/a/adaptivecpp.rb

View workflow job for this annotation

GitHub Actions / Linux x86_64

`brew install --verbose --formula --build-bottle adaptivecpp` failed on Linux x86_64!

-- Found LibEdit: /home/linuxbrew/.linuxbrew/include (found version "2.11") -- Found ZLIB: /home/linuxbrew/.linuxbrew/lib/libz.so (found version "1.3.1") -- Found zstd: /home/linuxbrew/.linuxbrew/lib/libzstd.so -- Building AdaptiveCpp against LLVM configured from /home/linuxbrew/.linuxbrew/lib/cmake/llvm -- Selecting clang: /home/linuxbrew/.linuxbrew/Cellar/llvm/21.1.0-rc3/bin/clang++ CMake Error at CMakeLists.txt:459 (message): LLVM versions greater than 20 are not yet tested/supported, use -DACPP_EXPERIMENTAL_LLVM=ON if you still wish to try your luck. -- Using clang include directory: /home/linuxbrew/.linuxbrew/Cellar/llvm/21.1.0-rc3/lib/clang/21/include/.. -- Looking for C++ include filesystem -- Looking for C++ include filesystem - found -- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED -- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED - Success -- Performing Test HAS_MCPU_NATIVE -- Performing Test HAS_MCPU_NATIVE - Success -- Performing Test HAS_MARCH_NATIVE -- Performing Test HAS_MARCH_NATIVE - Success -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Found OpenMP_C: -fopenmp (found version "4.5") -- Found OpenMP_CXX: -fopenmp (found version "4.5") -- Found OpenMP: TRUE (found version "4.5") CMake Warning at src/runtime/CMakeLists.txt:364 (message): Could not find NUMA -- Default compilation target(s): generic -- Configuring incomplete, errors occurred! ==> Formula Path: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/a/adaptivecpp.rb ==> Configuration HOMEBREW_VERSION: 4.6.6-27-g566290d ORIGIN: https://github.com/Homebrew/brew HEAD: 566290dcbc776f6ba1a75bbfa16fe860cb821409 Last commit: 16 hours ago Branch: main Core tap HEAD: 693c3c7987414ccaeee290f5a2d93f5733d5b14f Core tap last commit: 6 hours ago Core tap JSON: 24 Aug 12:13 UTC HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew HOMEBREW_CASK_OPTS: [] HOMEBREW_COLOR: set HOMEBREW_CURL_PATH: /usr/bin/curl HOMEBREW_DOWNLOAD_CONCURRENCY: 16 HOMEBREW_FAIL_LOG_LINES: 150 HOMEBREW_FORBID_PACKAGES_FROM_PATHS: set HOMEBREW_GITHUB_API_TOKEN: set HOMEBREW_GIT_EMAIL: [email protected] HOMEBREW_GIT_NAME: BrewTestBot HOMEBREW_GIT_PATH: /usr/bin/git HOMEBREW_LOGS: /github/home/bottles/logs HOMEBREW_MAKE_JOBS: 8 HOMEBREW_NO_AUTO_UPDATE: set HOMEBREW_NO_EMOJI: set HOMEBREW_NO_ENV_HINTS: set HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: set HOMEBREW_NO_INSTALL_FROM_API: set HOMEBREW_SORBET_RUNTIME: set HOMEBREW_VERIFY_ATTESTATIONS: set Homebrew Ruby: 3.4.5 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/3.4.5/bin/ruby CPU: octa-core 64-bit zen2 Clang: 21.1.0 Git: 2.51.0 => /usr/bin/git Curl: 7.81.0 => /usr/bin/curl Kernel: Linux 6.8.0-1034-gcp x86_64 GNU/Linux OS: Ubuntu 22.04.5 LTS Host glibc: 2.35 /usr/bin/gcc: 11.4.0 /usr/bin/ruby: N/A glibc: N/A gcc@11: N/A gcc: N/A xorg: N/A ==> ENV HOMEBREW_CC: gcc-11 HOMEBREW_CXX: g++-11 MAKEFLAGS: -j8 CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew/opt/berkeley-db@5:/home/linuxbrew/.linuxbrew/opt/binutils:/home/linuxbrew/.linuxbrew PKG_CONFIG_PATH: /home/linuxbrew/.linuxbrew/opt/icu4c@77/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/xz/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/lz4/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/zlib/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/zstd/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/bzip2/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/mpdecimal/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/openssl@3/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/ncurses/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/readline/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/sqlite/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/expat/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/libedit/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/libffi/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/z3/lib/pkgconfig:/home/linuxbrew/.linuxbrew/opt/elfutils/lib/pkgconfig PKG_CONFIG_LIBDIR: HOMEBREW_MAKE_JOBS: 8 HOMEBREW_GIT: /usr/bin/git
args = []
if OS.mac?
libomp_root = Formula["libomp"].opt_prefix
Expand Down
1 change: 1 addition & 0 deletions Formula/a/afl++.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Aflxx < Formula
version "4.33c"
sha256 "98903c8036282c8908b1d8cc0d60caf3ea259db4339503a76449b47acce58d1d"
license "Apache-2.0"
revision 1

livecheck do
url :stable
Expand Down
8 changes: 7 additions & 1 deletion Formula/a/alive2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Alive2 < Formula
tag: "v21.0",
revision: "913e1556032ee70a9ebf147b5a0c7e10086b7490"
license "MIT"
revision 1
head "https://github.com/AliveToolkit/alive2.git", branch: "master"

bottle do
Expand All @@ -28,7 +29,12 @@ class Alive2 < Formula
def install
# Work around ir/state.cpp:730:40: error: reference to local binding
# 'src_data' declared in enclosing function 'IR::State::copyUBFromBB'
ENV.llvm_clang if OS.mac? && MacOS.version <= :ventura
if OS.mac? && MacOS.version <= :ventura
ENV.llvm_clang
# Also link to LLVM libc++ due to `std::__hash_memory` availability in newer header
# https://github.com/llvm/llvm-project/commit/17d05695388128353662fbb80bbb7a13d172b41d
ENV.prepend "LDFLAGS", "-L#{Formula["llvm"].opt_lib}/c++ -L#{Formula["llvm"].opt_lib}/unwind -lunwind"
end

system "cmake", "-S", ".", "-B", "build", "-DBUILD_LLVM_UTILS=ON", "-DBUILD_TV=ON", *std_cmake_args
system "cmake", "--build", "build"
Expand Down
19 changes: 16 additions & 3 deletions Formula/c/castxml.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
class Castxml < Formula
desc "C-family Abstract Syntax Tree XML Output"
homepage "https://github.com/CastXML/CastXML"
url "https://github.com/CastXML/CastXML/archive/refs/tags/v0.6.11.tar.gz"
sha256 "fc5b49f802b67f98ecea10564bc171c660020836a48cecefc416681a2d2e1d3d"
license "Apache-2.0"
revision 1
revision 2
head "https://github.com/CastXML/castxml.git", branch: "master"

stable do
url "https://github.com/CastXML/CastXML/archive/refs/tags/v0.6.11.tar.gz"
sha256 "fc5b49f802b67f98ecea10564bc171c660020836a48cecefc416681a2d2e1d3d"

# Backport support for LLVM 21
patch do
url "https://github.com/CastXML/CastXML/commit/f4fdb9eebe3a03c8c6479a1cf420761a97e86824.patch?full_index=1"
sha256 "33093a62dc22f98ab1f6b44a1eca7a668bc142e870069ea51fa5bbd44627dcae"
end
patch do
url "https://github.com/CastXML/CastXML/commit/e71d56d34d308f410ac6f5493c5622e9701e210f.patch?full_index=1"
sha256 "cab3ccec1795d8228a5f784c88b23846e2a90415d084513e9b8f237759a68da6"
end
end

livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
Expand Down
18 changes: 17 additions & 1 deletion Formula/c/ccls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Ccls < Formula
# https://github.com/MaskRay/ccls/issues/786
# https://github.com/MaskRay/ccls/issues/895
license "Apache-2.0"
revision 1
revision 2
head "https://github.com/MaskRay/ccls.git", branch: "master"

stable do
Expand All @@ -19,6 +19,22 @@ class Ccls < Formula
url "https://github.com/MaskRay/ccls/commit/4331c8958698d42933bf4e132f8a7d61f3cedb8c.patch?full_index=1"
sha256 "5420b53cf912268688953a2863e86f6b88334ed548852eaedb9f8ce4871ee034"
end

# Backport reformat commit to cleanly apply later patches
patch do
url "https://github.com/MaskRay/ccls/commit/48f1a006b78944a944cdc0c98fb4b447e19fce7d.patch?full_index=1"
sha256 "2fa14b78e00b455138324034f876979f40c34e253b5b254ea794e60a38ac657b"
end

# Backport support for LLVM 21
patch do
url "https://github.com/MaskRay/ccls/commit/44fb405d00dead04de43891c9818d798f10fc41e.patch?full_index=1"
sha256 "40229b6bc013a6daf510b980a7b032bad159f43e95796467705042beeb70fe49"
end
patch do
url "https://github.com/MaskRay/ccls/commit/4427527ed8107719457b5260443e8cad024e446f.patch?full_index=1"
sha256 "16ba1cd3c18441054fcc54716e44e013ee01c21b25b796adc480620df511abe0"
end
end

bottle do
Expand Down
1 change: 1 addition & 0 deletions Formula/c/clang-uml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ClangUml < Formula
url "https://github.com/bkryza/clang-uml/archive/refs/tags/0.6.2.tar.gz"
sha256 "004540c328699f81abebceb33a4661b548ab3a5f74096da2c025b9971b2b17ff"
license "Apache-2.0"
revision 1
head "https://github.com/bkryza/clang-uml.git", branch: "master"

bottle do
Expand Down
1 change: 1 addition & 0 deletions Formula/c/clazy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Clazy < Formula
url "https://download.kde.org/stable/clazy/1.15/src/clazy-1.15.tar.xz"
sha256 "43189460b366ea3126242878c36ee8a403e37ec4baef7e61ccfa124b1414e7a9"
license "LGPL-2.0-or-later"
revision 1
head "https://invent.kde.org/sdk/clazy.git", branch: "master"

livecheck do
Expand Down
7 changes: 7 additions & 0 deletions Formula/c/crystal.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class Crystal < Formula
desc "Fast and statically typed, compiled language with Ruby-like syntax"
homepage "https://crystal-lang.org/"
license "Apache-2.0"
revision 1

stable do
# TODO: Replace arm64 linux bootstrap with official when available
Expand All @@ -12,6 +13,12 @@
url "https://github.com/crystal-lang/shards/archive/refs/tags/v0.19.1.tar.gz"
sha256 "2a49e7ffa4025e0b3e8774620fa8dbc227d3d1e476211fefa2e8166dcabf82b5"
end

# Backport support for LLVM 21
patch do
url "https://github.com/crystal-lang/crystal/commit/0e3757edcf7f18c238841e2f2aa659ac302fee4a.patch?full_index=1"
sha256 "8f5f9682990a74405f7bbae3b20afcf6bd11f65826204fee77b52b69d0c34925"
end
end

livecheck do
Expand Down
1 change: 1 addition & 0 deletions Formula/c/crystalline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Crystalline < Formula
url "https://github.com/elbywan/crystalline/archive/refs/tags/v0.17.1.tar.gz"
sha256 "3e8f4c3f41830092300219ef91c3d03e15536774ef18a5395ff6a9fffc27be5b"
license "MIT"
revision 1

bottle do
sha256 arm64_sequoia: "87a66475cc7c310d5a9ca86451588753fa013793a29647adc860a722d44262b3"
Expand Down
1 change: 1 addition & 0 deletions Formula/e/enzyme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Enzyme < Formula
url "https://github.com/EnzymeAD/Enzyme/archive/refs/tags/v0.0.191.tar.gz"
sha256 "5832f70fdbebc922c45da9e1d49985d96b91d54d12eac8e3f96aee9d3b09eb86"
license "Apache-2.0" => { with: "LLVM-exception" }
revision 1
head "https://github.com/EnzymeAD/Enzyme.git", branch: "main"

bottle do
Expand Down
97 changes: 49 additions & 48 deletions Formula/f/flang.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class Flang < Formula
desc "LLVM Fortran Frontend"
homepage "https://flang.llvm.org/"
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/llvm-project-20.1.8.src.tar.xz"
sha256 "6898f963c8e938981e6c4a302e83ec5beb4630147c7311183cf61069af16333d"
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.0-rc3/llvm-project-21.1.0-rc3.src.tar.xz"
sha256 "7c61598f3902e61499b4a8d0302087ed2421c75bf504d084f2e6fa5450ab94d7"
# The LLVM Project is under the Apache License v2.0 with LLVM Exceptions
license "Apache-2.0" => { with: "LLVM-exception" }
head "https://github.com/llvm/llvm-project.git", branch: "main"
Expand All @@ -24,6 +24,9 @@ class Flang < Formula
depends_on "cmake" => :build
depends_on "llvm"

# Keep broken symlink if `llvm` has been unlinked on Linux.
skip_clean "lib/LLVMgold.so"

# Building with GCC fails at linking with an obscure error.
fails_with :gcc

Expand All @@ -32,68 +35,70 @@ def llvm
end

def install
# Generate omp_lib.h and omp_lib.F90 to be used by flang build
system "cmake", "-S", "openmp", "-B", "build/projects/openmp", *std_cmake_args
resource_dir = Pathname(Utils.safe_popen_read(llvm.opt_bin/"clang", "-print-resource-dir").chomp)
relative_resource_dir = resource_dir.relative_path_from(llvm.prefix.realpath)

common_args = %W[
-DBUILD_SHARED_LIBS=ON
-DLLVM_DIR=#{llvm.opt_lib}/cmake/llvm
-DLLVM_ENABLE_FATLTO=ON
-DLLVM_ENABLE_LTO=ON
]

args = %W[
flang_args = %W[
-DCLANG_DIR=#{llvm.opt_lib}/cmake/clang
-DFLANG_INCLUDE_TESTS=OFF
-DFLANG_REPOSITORY_STRING=#{tap&.issues_url}
-DFLANG_VENDOR=#{tap&.user}
-DLLVM_DIR=#{llvm.opt_lib}/cmake/llvm
-DLLVM_ENABLE_FATLTO=ON
-DLLVM_ENABLE_LTO=ON
-DLLVM_TOOL_OPENMP_BUILD=ON
-DLLVM_USE_SYMLINKS=ON
-DMLIR_DIR=#{llvm.opt_lib}/cmake/mlir
-DMLIR_LINK_MLIR_DYLIB=ON
]
args << "-DFLANG_VENDOR_UTI=sh.brew.flang" if tap&.official?
# FIXME: Setting `BUILD_SHARED_LIBS=ON` causes the just-built flang to throw ICE on macOS
args << "-DBUILD_SHARED_LIBS=ON" if OS.linux?
flang_args << "-DFLANG_VENDOR_UTI=sh.brew.flang" if tap&.official?

flang_rt_args = %W[
-DCMAKE_Fortran_COMPILER_WORKS=ON
-DCMAKE_Fortran_COMPILER=#{bin}/flang
-DFLANG_RT_ENABLE_SHARED=ON
-DFLANG_RT_ENABLE_STATIC=OFF
-DFLANG_RT_INCLUDE_TESTS=OFF
-DLLVM_BINARY_DIR=#{llvm.opt_prefix}
-DLLVM_ENABLE_RUNTIMES=flang-rt
]

# Generate omp_lib.h and omp_lib.F90 to be used by flang build
system "cmake", "-S", "openmp", "-B", "build/projects/openmp", *std_cmake_args

system "cmake", "-S", "flang", "-B", "build", *args, *std_cmake_args
system "cmake", "-S", "flang", "-B", "build", *flang_args, *common_args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
return if OS.linux?

system "cmake", "-S", "runtimes", "-B", "build-rt", *flang_rt_args, *common_args, *std_cmake_args
system "cmake", "--build", "build-rt"
system "cmake", "--install", "build-rt"

# Add symlink for runtime library as it won't be found when resource-dir is
# overridden by flang.cfg. This also allows shared `flang-rt` on Linux to
# avoid extra RPATH. See if the upstream provides a better way of handling:
# https://github.com/llvm/llvm-project/blob/main/flang-rt/CMakeLists.txt#L120-L130
lib.install_symlink (prefix/relative_resource_dir).glob("**/#{shared_library("*")}")

if OS.linux?
# Allow flang -flto to work on Linux as it expects library relative to driver.
# The HOMEBREW_PREFIX path is used so that `brew link` skips creating a symlink.
lib.install_symlink HOMEBREW_PREFIX/"lib/LLVMgold.so"
return
end

libexec.install bin.children
bin.install_symlink libexec.children

# Help `flang` driver find `libLTO.dylib` and runtime libraries
resource_dir = Utils.safe_popen_read(llvm.opt_bin/"clang", "-print-resource-dir").chomp
resource_dir.gsub!(llvm.prefix.realpath, llvm.opt_prefix)
(libexec/"flang.cfg").atomic_write <<~CONFIG
-Wl,-lto_library,#{llvm.opt_lib}/libLTO.dylib
-resource-dir=#{resource_dir}
-resource-dir=#{llvm.opt_prefix/relative_resource_dir}
CONFIG

# Convert LTO-generated bitcode in our static archives to MachO.
# Not needed on Linux because of `-ffat-lto-objects`
# See equivalent code in `llvm.rb`.
lib.glob("*.a").each do |static_archive|
mktemp do
system llvm.opt_bin/"llvm-ar", "x", static_archive
rebuilt_files = []

Pathname.glob("*.o").each do |bc_file|
file_type = Utils.safe_popen_read("file", "--brief", bc_file)
next unless file_type.match?(/^LLVM (IR )?bitcode/)

rebuilt_files << bc_file
system ENV.cc, "-fno-lto", "-Wno-unused-command-line-argument",
"-x", "ir", bc_file, "-c", "-o", bc_file
end

system llvm.opt_bin/"llvm-ar", "r", static_archive, *rebuilt_files if rebuilt_files.present?
end
end
end

def post_install
# Allow flang -flto to work on Linux as it expects library relative to driver.
# The HOMEBREW_PREFIX path is used so that `brew link` skips creating a symlink.
lib.install_symlink HOMEBREW_PREFIX/"lib/LLVMgold.so" if OS.linux?
end

test do
Expand Down Expand Up @@ -159,13 +164,9 @@ def post_install
system bin/"flang", "-v", "runtimes.f90"

return if OS.linux?
return unless (etc/"clang").exist? # https://github.com/Homebrew/homebrew-test-bot/issues/805

assert_match %r{^Configuration file: #{Regexp.escape(etc)}/clang/.*\.cfg$}i,
shell_output("#{bin}/flang --version")

system "ar", "x", lib/"libFortranCommon.a"
testpath.glob("*.o").each do |object_file|
refute_match(/LLVM (IR )?bitcode/, shell_output("file --brief #{object_file}"))
end
end
end
4 changes: 2 additions & 2 deletions Formula/l/lld.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class Lld < Formula
desc "LLVM Project Linker"
homepage "https://lld.llvm.org/"
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/llvm-project-20.1.8.src.tar.xz"
sha256 "6898f963c8e938981e6c4a302e83ec5beb4630147c7311183cf61069af16333d"
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.0-rc3/llvm-project-21.1.0-rc3.src.tar.xz"
sha256 "7c61598f3902e61499b4a8d0302087ed2421c75bf504d084f2e6fa5450ab94d7"
# The LLVM Project is under the Apache License v2.0 with LLVM Exceptions
license "Apache-2.0" => { with: "LLVM-exception" }
head "https://github.com/llvm/llvm-project.git", branch: "main"
Expand Down
14 changes: 11 additions & 3 deletions Formula/l/llvm.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Llvm < Formula
desc "Next-gen compiler infrastructure"
homepage "https://llvm.org/"
Expand All @@ -6,8 +6,8 @@
head "https://github.com/llvm/llvm-project.git", branch: "main"

stable do
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/llvm-project-20.1.8.src.tar.xz"
sha256 "6898f963c8e938981e6c4a302e83ec5beb4630147c7311183cf61069af16333d"
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.0-rc3/llvm-project-21.1.0-rc3.src.tar.xz"
sha256 "7c61598f3902e61499b4a8d0302087ed2421c75bf504d084f2e6fa5450ab94d7"

# Fix triple config loading for clang-cl
# https://github.com/llvm/llvm-project/pull/111397
Expand Down Expand Up @@ -64,6 +64,14 @@
end

def install
# Work around OOM error on arm64 linux runner by reducing number of jobs
github_arm64_linux = OS.linux? && Hardware::CPU.arm? &&
ENV["HOMEBREW_GITHUB_ACTIONS"].present? &&
ENV["GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED"].blank?
if github_arm64_linux && (jobs = ENV.make_jobs - 1).positive?
ENV["CMAKE_BUILD_PARALLEL_LEVEL"] = ENV["HOMEBREW_MAKE_JOBS"] = jobs.to_s
end

# The clang bindings need a little help finding our libclang.
inreplace "clang/bindings/python/clang/cindex.py",
/^(\s*library_path\s*=\s*)None$/,
Expand All @@ -80,7 +88,6 @@
libcxx
libcxxabi
libunwind
pstl
]

unless versioned_formula?
Expand Down Expand Up @@ -192,6 +199,7 @@
args << "-DLLVM_BINUTILS_INCDIR=#{Formula["binutils"].opt_include}"
# Parts of Polly fail to correctly build with PIC when being used for DSOs.
args << "-DCMAKE_POSITION_INDEPENDENT_CODE=ON"

runtimes_cmake_args += %w[
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
Expand Down
Loading
Loading