From 292354a484c6ae576977aecc88b72cda3d993128 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 4 May 2021 18:17:36 +0100 Subject: [PATCH] llvm: fix llvm-config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `llvm-config` relies on a versioned `libLLVM` (e.g. `libLLVM-12`), but their build system does not install one for some reason. With the symlink: ❯ llvm-config --libs -lLLVM-12 Without: ❯ llvm-config --libs -lLLVMWindowsManifest -lLLVMXRay -lLLVMLibDriver -lLLVMDlltoolDriver ... -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMTableGen -lLLVMSupport -lLLVMDemangle This deviates from the intended behaviour, as seen on Linux, where `llvm-config --libs` returns the output shown above with the symlink. Attempting to link against the libraries shown by `llvm-config` without this fix is also leads to build failures due to missing symbols. This will also allow Julia to use brewed `llvm` instead of a vendored one. (#76527) Closes #76798. --- Formula/llvm.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Formula/llvm.rb b/Formula/llvm.rb index f320da725393c..305f3ca461e7b 100644 --- a/Formula/llvm.rb +++ b/Formula/llvm.rb @@ -5,6 +5,7 @@ class Llvm < Formula sha256 "9ed1688943a4402d7c904cc4515798cdb20080066efa010fe7e1f2551b423628" # The LLVM Project is under the Apache License v2.0 with LLVM Exceptions license "Apache-2.0" => { with: "LLVM-exception" } + revision 1 head "https://github.com/llvm/llvm-project.git", branch: "main" livecheck do @@ -141,6 +142,11 @@ def install system "cmake", "--build", ".", "--target", "install-xcode-toolchain" if MacOS::Xcode.installed? end + on_macos do + # Install versioned symlink, or else `llvm-config` doesn't work properly + lib.install_symlink "libLLVM.dylib" => "libLLVM-#{version.major}.dylib" unless build.head? + end + # Install LLVM Python bindings # Clang Python bindings are installed by CMake (lib/site_packages).install llvmpath/"bindings/python/llvm" @@ -158,6 +164,9 @@ def caveats test do assert_equal prefix.to_s, shell_output("#{bin}/llvm-config --prefix").chomp + assert_equal "-lLLVM-#{version.major}", shell_output("#{bin}/llvm-config --libs").chomp + assert_equal (lib/shared_library("libLLVM-#{version.major}")).to_s, + shell_output("#{bin}/llvm-config --libfiles").chomp (testpath/"omptest.c").write <<~EOS #include