Skip to content

Commit

Permalink
llvm 15.0.2
Browse files Browse the repository at this point in the history
* llvm 15.0.2
* llvm: improve `install` method
  - define an `lto_build` variable per feedback from #112154
  - move the runtimes build from `stage2-profdata` to `stage2`. Building
  the runtimes is not useful with the `stage2-profdata` compiler, but
  doing it in `stage2` means that the runtimes will be built with our
  instrumented compiler.
  • Loading branch information
carlocab authored and BrewTestBot committed Oct 6, 2022
1 parent 4b14798 commit 9ba2a11
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions Formula/llvm.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class Llvm < Formula
desc "Next-gen compiler infrastructure"
homepage "https://llvm.org/"
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.1/llvm-project-15.0.1.src.tar.xz"
sha256 "f25ce2d4243bebf527284eb7be7f6f56ef454fca8b3de9523f7eb4efb8d26218"
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.2/llvm-project-15.0.2.src.tar.xz"
sha256 "7877cd67714728556a79e5ec0cc72d66b6926448cf73b12b2cb901b268f7a872"
# 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 Expand Up @@ -142,12 +142,6 @@ def install
runtimes_cmake_args = []
builtins_cmake_args = []

# Skip the PGO build on HEAD installs or non-bottle source builds
# Catalina and earlier requires too many hacks to build with PGO.
# FIXME: The Linux build appears to have a parallelisation issue,
# so avoid a painfully slow serial build until that's resolved.
pgo_build = build.stable? && build.bottle? && (MacOS.version > :catalina)

if OS.mac?
args << "-DLLVM_BUILD_LLVM_C_DYLIB=ON"
args << "-DLLVM_ENABLE_LIBCXX=ON"
Expand Down Expand Up @@ -204,6 +198,13 @@ def install
builtins_cmake_args << "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
end

# Skip the PGO build on HEAD installs or non-bottle source builds
# Catalina and earlier requires too many hacks to build with PGO.
# FIXME: The Linux build appears to have a parallelisation issue,
# so avoid a painfully slow serial build until that's resolved.
pgo_build = build.stable? && build.bottle? && (MacOS.version > :catalina)
lto_build = pgo_build && OS.mac?

if ENV.cflags.present?
args << "-DCMAKE_C_FLAGS=#{ENV.cflags}" unless pgo_build
runtimes_cmake_args << "-DCMAKE_C_FLAGS=#{ENV.cflags}"
Expand Down Expand Up @@ -250,9 +251,7 @@ def install
extra_args << "-DCMAKE_LINKER=ld"
extra_args += clt_sdk_support_flags

# NOTE: do not enable LTO on Linux, because this creates static archives that are not portable.
# This is not an issue on macOS, where bottles are built and installed on the same version.
args << "-DLLVM_ENABLE_LTO=Thin"
args << "-DLLVM_ENABLE_LTO=Thin" if lto_build
# LTO creates object files not recognised by Apple libtool.
args << "-DCMAKE_LIBTOOL=#{llvmpath}/stage1/bin/llvm-libtool-darwin"

Expand Down Expand Up @@ -336,7 +335,7 @@ def install
"-DCMAKE_C_FLAGS=#{instrumented_cflags.join(" ")}",
"-DCMAKE_CXX_FLAGS=#{instrumented_cxxflags.join(" ")}",
*instrumented_extra_args, *std_cmake_args
system "cmake", "--build", ".", "--target", "clang", "lld"
system "cmake", "--build", ".", "--target", "clang", "lld", "runtimes"

# We run some `check-*` targets to increase profiling
# coverage. These do not need to succeed.
Expand All @@ -352,6 +351,7 @@ def install
system "cmake", "-G", "Unix Makefiles", "..",
"-DCMAKE_C_COMPILER=#{llvmpath}/stage2/bin/clang",
"-DCMAKE_CXX_COMPILER=#{llvmpath}/stage2/bin/clang++",
"-DLLVM_BUILD_RUNTIMES=OFF",
*extra_args.reject { |s| s["TABLEGEN"] },
*std_cmake_args

Expand Down Expand Up @@ -434,7 +434,7 @@ def install
# Install Emacs modes
elisp.install llvmpath.glob("utils/emacs/*.el") + share.glob("clang/*.el")

return if OS.linux? || !pgo_build
return unless lto_build

# Convert LTO-generated bitcode in our static archives to MachO. Adapted from Fedora:
# https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/rawhide/f/brp-llvm-compile-lto-elf
Expand Down

0 comments on commit 9ba2a11

Please sign in to comment.