Skip to content

Commit

Permalink
Merge pull request #190873 from Homebrew/openjdk-11-17-o1
Browse files Browse the repository at this point in the history
openjdk@11: use `llvm` to avoid Apple clang 16 failure
  • Loading branch information
BrewTestBot authored Sep 30, 2024
2 parents 1cb5751 + f460fcd commit 9c42914
Showing 1 changed file with 54 additions and 15 deletions.
69 changes: 54 additions & 15 deletions Formula/o/openjdk@11.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class OpenjdkAT11 < Formula

depends_on "autoconf" => :build
depends_on "pkg-config" => :build
depends_on "freetype"
depends_on "giflib"
depends_on "harfbuzz"
depends_on "jpeg-turbo"
Expand All @@ -35,10 +36,35 @@ class OpenjdkAT11 < Formula
uses_from_macos "zip"
uses_from_macos "zlib"

on_macos do
if DevelopmentTools.clang_build_version == 1600
depends_on "llvm" => :build

fails_with :clang do
cause "fatal error while optimizing exploded image for BUILD_JIGSAW_TOOLS"
end

# Backport fix for UB that errors on LLVM 19
patch do
url "https://github.com/openjdk/jdk/commit/51be7db96f3fc32a7ddb24f8af19fb4fc0577aaf.patch?full_index=1"
sha256 "7fb09ce74a1cf534c976d0ea8aec285c86a832fe4fa016bdf79870ac5574b9a7"
end

# Apply FreeBSD workaround to avoid UB causing failure on recent Clang.
# A proper fix requires backport of 8229258[^1] which was previously attempted[^2].
#
# [^1]: https://bugs.openjdk.org/browse/JDK-8229258
# [^2]: https://github.com/openjdk/jdk11u/pull/23
patch do
url "https://github.com/battleblow/jdk11u/commit/305a68a90c722aa7a7b75589e24d5b5d554c96c1.patch?full_index=1"
sha256 "5327c249c379a8db6a9e844e4fb32471506db8b8e3fef1f62f5c0c892684fe15"
end
end
end

on_linux do
depends_on "alsa-lib"
depends_on "fontconfig"
depends_on "freetype"
depends_on "libx11"
depends_on "libxext"
depends_on "libxi"
Expand Down Expand Up @@ -74,6 +100,16 @@ class OpenjdkAT11 < Formula
end

def install
if DevelopmentTools.clang_build_version == 1600
ENV.llvm_clang
ENV.remove "HOMEBREW_LIBRARY_PATHS", Formula["llvm"].opt_lib
# ptrauth.h is not available in brew LLVM
inreplace "src/hotspot/os_cpu/bsd_aarch64/pauth_bsd_aarch64.inline.hpp" do |s|
s.sub! "#include <ptrauth.h>", ""
s.sub! "return ptrauth_strip(ptr, ptrauth_key_asib);", "return ptr;"
end
end

boot_jdk = buildpath/"boot-jdk"
resource("boot-jdk").stage boot_jdk
boot_jdk /= "Contents/Home" if OS.mac? && !Hardware::CPU.arm?
Expand All @@ -96,6 +132,7 @@ def install
--with-vendor-vm-bug-url=#{tap.issues_url}
--without-version-opt
--without-version-pre
--with-freetype=system
--with-giflib=system
--with-harfbuzz=system
--with-lcms=system
Expand All @@ -108,16 +145,20 @@ def install
args += if OS.mac?
ldflags << "-headerpad_max_install_names"

# Allow unbundling `freetype` on macOS
inreplace "make/autoconf/lib-freetype.m4", '= "xmacosx"', '= ""'

%W[
--enable-dtrace
--with-freetype-include=#{Formula["freetype"].opt_include}
--with-freetype-lib=#{Formula["freetype"].opt_lib}
--with-sysroot=#{MacOS.sdk_path}
]
else
%W[
--with-x=#{HOMEBREW_PREFIX}
--with-cups=#{HOMEBREW_PREFIX}
--with-fontconfig=#{HOMEBREW_PREFIX}
--with-freetype=system
--with-stdc++lib=dynamic
]
end
Expand All @@ -128,20 +169,18 @@ def install
ENV["MAKEFLAGS"] = "JOBS=#{ENV.make_jobs}"
system "make", "images", "CONF=release"

cd "build/release/images" do
jdk = libexec
if OS.mac?
libexec.install Dir["jdk-bundle/*"].first => "openjdk.jdk"
jdk /= "openjdk.jdk/Contents/Home"
else
libexec.install Dir["jdk/*"]
end

bin.install_symlink Dir[jdk/"bin/*"]
include.install_symlink Dir[jdk/"include/*.h"]
include.install_symlink Dir[jdk/"include/*/*.h"]
man1.install_symlink Dir[jdk/"man/man1/*"]
jdk = libexec
if OS.mac?
libexec.install Dir["build/release/images/jdk-bundle/*"].first => "openjdk.jdk"
jdk /= "openjdk.jdk/Contents/Home"
else
libexec.install Dir["build/release/images/jdk/*"]
end

bin.install_symlink Dir[jdk/"bin/*"]
include.install_symlink Dir[jdk/"include/*.h"]
include.install_symlink Dir[jdk/"include"/OS.kernel_name.downcase/"*.h"]
man1.install_symlink Dir[jdk/"man/man1/*"]
end

def caveats
Expand Down

0 comments on commit 9c42914

Please sign in to comment.