/
openj9.rb
197 lines (172 loc) 路 6.39 KB
/
openj9.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
class Openj9 < Formula
desc "High performance, scalable, Java virtual machine"
homepage "https://www.eclipse.org/openj9/"
url "https://github.com/eclipse-openj9/openj9.git",
tag: "openj9-0.40.0",
revision: "d12d10c9ea2de2cf363095e609536ffe451bd25f"
license any_of: [
"EPL-2.0",
"Apache-2.0",
{ "GPL-2.0-only" => { with: "Classpath-exception-2.0" } },
{ "GPL-2.0-only" => { with: "OpenJDK-assembly-exception-1.0" } },
]
livecheck do
url :stable
regex(/^openj9-(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "aed97a9ad250d831d56e98fe4cc42a04accc9573105d35b720786e97615f53f9"
sha256 cellar: :any, arm64_big_sur: "6c138a8cb5d443c3f3fedf74a820cfe7dacc8c3f1dd8fdd633cd3bbf93a829a1"
sha256 cellar: :any, sonoma: "f9abe0dc7f76e36e776d7302990c61b857407f12004d7b6afe4d75f9a3275978"
sha256 cellar: :any, ventura: "d03b9d60f11cd19ccb14438849675d1314c2306a7091b6d6ca16a2d1c9d6bd72"
sha256 cellar: :any, monterey: "506c3ce6be273f87b953d5b7820aa567e29693e39243ed120f9d06c0031c8cda"
sha256 cellar: :any, big_sur: "bd6cfe66db144260f4d961b4a462414de966f5ab585c05b2850ab9c1d99db65b"
end
keg_only :shadowed_by_macos
depends_on "autoconf" => :build
depends_on "bash" => :build
depends_on "cmake" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "fontconfig"
depends_on "giflib"
depends_on "harfbuzz"
depends_on "jpeg-turbo"
depends_on "libpng"
depends_on "little-cms2"
uses_from_macos "m4" => :build
uses_from_macos "cups"
uses_from_macos "libffi"
uses_from_macos "unzip"
uses_from_macos "zip"
uses_from_macos "zlib"
on_linux do
keg_only "it conflicts with openjdk"
depends_on "alsa-lib"
depends_on "libx11"
depends_on "libxext"
depends_on "libxrandr"
depends_on "libxrender"
depends_on "libxt"
depends_on "libxtst"
depends_on "numactl"
end
on_intel do
depends_on "nasm" => :build
end
# From https://github.com/eclipse-openj9/openj9/blob/openj9-#{version}/doc/build-instructions/
# We use JDK 20 to bootstrap.
resource "boot-jdk" do
on_macos do
on_arm do
url "https://github.com/AdoptOpenJDK/semeru20-binaries/releases/download/jdk-20.0.2%2B9_openj9-0.40.0/ibm-semeru-open-jdk_aarch64_mac_20.0.2_9_openj9-0.40.0.tar.gz"
sha256 "e9c7df3897877350b577d80a47cbc9a7b4589419ca0c2df7c185a20bca8423dd"
end
on_intel do
url "https://github.com/AdoptOpenJDK/semeru20-binaries/releases/download/jdk-20.0.2%2B9_openj9-0.40.0/ibm-semeru-open-jdk_x64_mac_20.0.2_9_openj9-0.40.0.tar.gz"
sha256 "ece0d6e2a5cd07b2e0e05a6361026c73838cfd14556c0aeb7f9367a13d19de38"
end
end
on_linux do
url "https://github.com/AdoptOpenJDK/semeru20-binaries/releases/download/jdk-20.0.2%2B9_openj9-0.40.0/ibm-semeru-open-jdk_x64_linux_20.0.2_9_openj9-0.40.0.tar.gz"
sha256 "925b555050eb3ad9bcb444c4713f5bb221025ba9c309e95235d4b2e060c84ee0"
end
end
resource "omr" do
url "https://github.com/eclipse-openj9/openj9-omr.git",
tag: "openj9-0.40.0",
revision: "e80bff83b7fda8875071d89de7c73184d847085d"
end
resource "openj9-openjdk-jdk" do
url "https://github.com/ibmruntimes/openj9-openjdk-jdk20.git",
tag: "openj9-0.40.0",
revision: "19eb54abdace78d5009138c6e27457dfe2df6cf1"
end
def install
openj9_files = buildpath.children
(buildpath/"openj9").install openj9_files
resource("openj9-openjdk-jdk").stage buildpath
resource("omr").stage buildpath/"omr"
boot_jdk = buildpath/"boot-jdk"
resource("boot-jdk").stage boot_jdk
boot_jdk /= "Contents/Home" if OS.mac?
java_options = ENV.delete("_JAVA_OPTIONS")
config_args = %W[
--disable-warnings-as-errors-omr
--disable-warnings-as-errors-openj9
--with-boot-jdk-jvmargs=#{java_options}
--with-boot-jdk=#{boot_jdk}
--with-debug-level=release
--with-jvm-variants=server
--with-native-debug-symbols=none
--with-vendor-bug-url=#{tap.issues_url}
--with-vendor-name=#{tap.user}
--with-vendor-url=#{tap.issues_url}
--with-vendor-version-string=#{tap.user}
--with-vendor-vm-bug-url=#{tap.issues_url}
--with-version-build=#{revision}
--without-version-opt
--without-version-pre
--with-giflib=system
--with-harfbuzz=system
--with-lcms=system
--with-libjpeg=system
--with-libpng=system
--with-zlib=system
--enable-ddr=no
--enable-full-docs=no
]
config_args += if OS.mac?
%W[
--enable-dtrace
--with-sysroot=#{MacOS.sdk_path}
]
else
# Override hardcoded /usr/include directory when checking for numa headers
inreplace "closed/autoconf/custom-hook.m4", "/usr/include/numa", Formula["numactl"].opt_include/"numa"
%W[
--with-x=#{HOMEBREW_PREFIX}
--with-cups=#{Formula["cups"].opt_prefix}
--with-fontconfig=#{Formula["fontconfig"].opt_prefix}
]
end
# Ref: https://github.com/eclipse-openj9/openj9/issues/13767
# TODO: Remove once compressed refs mode is supported on Apple Silicon
config_args << "--with-noncompressedrefs" if OS.mac? && Hardware::CPU.arm?
ENV["CMAKE_CONFIG_TYPE"] = "Release"
system "bash", "./configure", *config_args
system "make", "all", "-j"
jdk = libexec
if OS.mac?
libexec.install Dir["build/*/images/jdk-bundle/*"].first => "openj9.jdk"
jdk /= "openj9.jdk/Contents/Home"
rm jdk/"lib/src.zip"
rm_rf Dir.glob(jdk/"**/*.dSYM")
else
libexec.install Dir["build/linux-x86_64-server-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
on_macos do
<<~EOS
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn #{opt_libexec}/openj9.jdk /Library/Java/JavaVirtualMachines/openj9.jdk
EOS
end
end
test do
(testpath/"HelloWorld.java").write <<~EOS
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
system bin/"javac", "HelloWorld.java"
assert_match "Hello, world!", shell_output("#{bin}/java HelloWorld")
end
end