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

mysql: use llvm on Ventura #206095

Merged
merged 2 commits into from
Feb 1, 2025
Merged
Changes from 1 commit
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
45 changes: 15 additions & 30 deletions Formula/m/mysql.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class Mysql < Formula
desc "Open source relational database management system"
homepage "https://dev.mysql.com/doc/refman/9.2/en/"
# FIXME: Actual homepage fails audit due to Homebrew's user-agent
# homepage "https://dev.mysql.com/doc/refman/9.2/en/"
homepage "https://github.com/mysql/mysql-server"
url "https://cdn.mysql.com/Downloads/MySQL-9.2/mysql-9.2.0.tar.gz"
sha256 "a39d11fdf6cf8d1b03b708d537a9132de4b99a9eb4d610293937f0687cd37a12"
license "GPL-2.0-only" => { with: "Universal-FOSS-exception-1.0" }
Expand Down Expand Up @@ -34,11 +36,14 @@ class Mysql < Formula
uses_from_macos "cyrus-sasl"
uses_from_macos "libedit"

# std::string_view is not fully compatible with the libc++ shipped
# with ventura, so we need to use the LLVM libc++ instead.
on_ventura :or_older do
depends_on "llvm@18"
fails_with :clang
depends_on "llvm"
fails_with :clang do
cause <<~EOS
std::string_view is not fully compatible with the libc++ shipped
with ventura, so we need to use the LLVM libc++ instead.
EOS
end
end

on_linux do
Expand Down Expand Up @@ -73,18 +78,11 @@ def install
# Disable ABI checking
inreplace "cmake/abi_check.cmake", "RUN_ABI_CHECK 1", "RUN_ABI_CHECK 0"
elsif MacOS.version <= :ventura
ENV["CC"] = Formula["llvm@18"].opt_bin/"clang"
ENV["CXX"] = Formula["llvm@18"].opt_bin/"clang++"

# The dependencies need to be explicitly added to the environment
deps.each do |dep|
next if dep.build? || dep.test?

ENV.append "CXXFLAGS", "-I#{dep.to_formula.opt_include}"
ENV.append "LDFLAGS", "-L#{dep.to_formula.opt_lib}"
end

ENV.append "LDFLAGS", "-L#{Formula["llvm@18"].opt_lib}/c++ -L#{Formula["llvm@18"].opt_lib} -lunwind"
ENV.llvm_clang
ENV.append "LDFLAGS", "-L#{Formula["llvm"].opt_lib}/unwind -lunwind"
# When using Homebrew's superenv shims, we need to use HOMEBREW_LIBRARY_PATHS
# rather than LDFLAGS for libc++ in order to correctly link to LLVM's libc++.
ENV.prepend_path "HOMEBREW_LIBRARY_PATHS", Formula["llvm"].opt_lib/"c++"
end

icu4c = deps.find { |dep| dep.name.match?(/^icu4c(@\d+)?$/) }
Expand Down Expand Up @@ -115,19 +113,6 @@ def install
-DWITH_UNIT_TESTS=OFF
]

# Add the dependencies to the CMake args
if OS.mac? && MacOS.version <=(:ventura)
args += %W[
-DABSL_INCLUDE_DIR=#{Formula["abseil"].opt_include}
-DICU_ROOT=#{Formula["icu4c@76"].opt_prefix}
-DLZ4_INCLUDE_DIR=#{Formula["lz4"].opt_include}
-DOPENSSL_INCLUDE_DIR=#{Formula["openssl@3"].opt_include}
-DPROTOBUF_INCLUDE_DIR=#{Formula["protobuf"].opt_include}
-DZLIB_INCLUDE_DIR=#{Formula["zlib"].opt_include}
-DZSTD_INCLUDE_DIR=#{Formula["zstd"].opt_include}
]
end

system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
Expand Down
Loading