Skip to content

Commit e6b04d8

Browse files
committed
[GR-29847] Symlink instead of copying the built GraalVM
PullRequest: truffleruby/2477
2 parents 9ea824c + a0b93fe commit e6b04d8

File tree

2 files changed

+18
-31
lines changed

2 files changed

+18
-31
lines changed

ci.jsonnet

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ local part_definitions = {
7575
environment+: { path+:: ["$MAVEN_HOME/bin"] },
7676
},
7777

78-
build_no_clean: {
78+
build: {
7979
setup+: [["mx", "sversions"]] +
8080
# aot-build.log is used for the build-stats metrics, in other cases it does no harm
8181
jt(["build", "--env", self.mx_env, "--"] + self.mx_build_options + ["|", "tee", "aot-build.log"]) +
@@ -85,13 +85,6 @@ local part_definitions = {
8585
],
8686
},
8787

88-
clean: {
89-
# Clean build results to make sure nothing refers to them while testing
90-
setup+: [["mx", "--env", self.mx_env, "clean"]],
91-
},
92-
93-
build: $.use.build_no_clean + $.use.clean,
94-
9588
truffleruby: {
9689
"$.benchmark.server":: { options: [] },
9790
environment+: {
@@ -294,13 +287,7 @@ local part_definitions = {
294287
},
295288

296289
run: {
297-
clean: {
298-
# $.use.clean but as run instead of setup
299-
run+: [["mx", "--env", self.mx_env, "clean"]],
300-
},
301-
302290
test_unit_tck: {
303-
# Run unittests first before cleaning, they need a full non-cleaned build
304291
run+: jt(["test", "unit", "--verbose"]) +
305292
jt(["test", "tck"])
306293
},
@@ -324,7 +311,7 @@ local part_definitions = {
324311
},
325312

326313
lint: {
327-
is_after:: ["$.use.build_no_clean"],
314+
is_after:: ["$.use.build"],
328315
downloads+: {
329316
JDT: { name: "ecj", version: "4.14.0", platformspecific: false },
330317
ECLIPSE: { version: "4.5.2", name: "eclipse", platformspecific: true },
@@ -482,7 +469,7 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
482469

483470
test_builds:
484471
{
485-
"ruby-lint": $.platform.linux + $.cap.gate + $.jdk.v11 + $.use.common + $.env.jvm + $.use.build_no_clean + $.run.lint + { timelimit: "30:00" },
472+
"ruby-lint": $.platform.linux + $.cap.gate + $.jdk.v11 + $.use.common + $.env.jvm + $.use.build + $.run.lint + { timelimit: "30:00" },
486473
# Run specs on MRI to make sure new specs are compatible and have the needed version guards
487474
"ruby-test-specs-mri": $.platform.linux + $.cap.gate + $.use.common + $.run.test_specs_mri + { timelimit: "30:00" },
488475
} +
@@ -494,10 +481,10 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
494481
local native_tests = $.run.testdownstream_aot + $.run.test_integration + $.run.test_compiler,
495482

496483
// Order: platform, jdk, mx_env. Keep aligned for an easy visual comparison.
497-
"ruby-test-specs-linux-8": $.platform.linux + $.jdk.v8 + $.env.jvm + gate_no_build + $.use.build_no_clean + $.run.test_unit_tck + native_config + $.run.clean + $.run.test_specs + { timelimit: "50:00" },
498-
"ruby-test-specs-linux-11": $.platform.linux + $.jdk.v11 + $.env.jvm + gate_no_build + $.use.build_no_clean + $.run.test_unit_tck + native_config + $.run.clean + $.run.test_specs + { timelimit: "50:00" },
499-
"ruby-test-specs-darwin-8": $.platform.darwin + $.jdk.v8 + $.env.jvm + gate_no_build + $.use.build_no_clean + $.run.test_unit_tck + native_config + $.run.clean + $.run.test_specs + { timelimit: "01:35:00" },
500-
"ruby-test-specs-darwin-11": $.platform.darwin + $.jdk.v11 + $.env.jvm + gate_no_build + $.use.build_no_clean + $.run.test_unit_tck + native_config + $.run.clean + $.run.test_specs + { timelimit: "01:35:00" },
484+
"ruby-test-specs-linux-8": $.platform.linux + $.jdk.v8 + $.env.jvm + gate_no_build + $.use.build + $.run.test_unit_tck + native_config + $.run.test_specs + { timelimit: "50:00" },
485+
"ruby-test-specs-linux-11": $.platform.linux + $.jdk.v11 + $.env.jvm + gate_no_build + $.use.build + $.run.test_unit_tck + native_config + $.run.test_specs + { timelimit: "50:00" },
486+
"ruby-test-specs-darwin-8": $.platform.darwin + $.jdk.v8 + $.env.jvm + gate_no_build + $.use.build + $.run.test_unit_tck + native_config + $.run.test_specs + { timelimit: "01:35:00" },
487+
"ruby-test-specs-darwin-11": $.platform.darwin + $.jdk.v11 + $.env.jvm + gate_no_build + $.use.build + $.run.test_unit_tck + native_config + $.run.test_specs + { timelimit: "01:35:00" },
501488
"ruby-test-fast-linux-arm64": $.platform.linux_arm64 + $.jdk.v11 + $.env.jvm + gate + $.run.test_fast + native_config + { timelimit: "30:00" },
502489
"ruby-test-fast-linux": $.platform.linux + $.jdk.v11 + $.env.jvm + gate + $.run.test_fast + { timelimit: "30:00" }, # To catch missing slow tags
503490
"ruby-test-mri-linux": $.platform.linux + $.jdk.v11 + $.env.jvm + gate + $.run.test_mri + { timelimit: "45:00" },

tool/jt.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,18 @@ def ruby_launcher
195195
@ruby_name ||= ENV['RUBY_BIN'] || 'jvm'
196196
ruby_launcher = if @ruby_name == 'ruby'
197197
ENV['RBENV_ROOT'] ? `rbenv which ruby`.chomp : which('ruby')
198-
elsif File.executable?(@ruby_name) and File.file?(@ruby_name)
199-
@ruby_name
200-
elsif @ruby_name.start_with?('/') and File.directory?(@ruby_name)
201-
"#{@ruby_name}/bin/ruby"
198+
elsif @ruby_name.start_with?('/')
199+
File.directory?(@ruby_name) ? "#{@ruby_name}/bin/ruby" : @ruby_name
202200
else
203201
graalvm = "#{TRUFFLERUBY_DIR}/mxbuild/truffleruby-#{@ruby_name}"
204202
"#{graalvm}/#{language_dir(graalvm)}/ruby/bin/ruby"
205203
end
206204

207205
raise "The Ruby executable #{ruby_launcher} does not exist" unless File.exist?(ruby_launcher)
208-
ruby_launcher = File.realpath(ruby_launcher)
209-
210206
raise "The Ruby executable #{ruby_launcher} is not executable" unless File.executable?(ruby_launcher)
207+
211208
@ruby_launcher = ruby_launcher
209+
@ruby_launcher_realpath = File.realpath(ruby_launcher)
212210

213211
unless @silent
214212
shortened_path = @ruby_launcher.sub(%r[^#{Regexp.escape TRUFFLERUBY_DIR}/], '').sub(%r[/bin/(ruby|truffleruby)$], '')
@@ -222,13 +220,14 @@ def ruby_launcher
222220

223221
# use same ruby_launcher in subprocess jt instances
224222
# cannot be set while building
225-
ENV['RUBY_BIN'] = ruby_launcher
223+
ENV['RUBY_BIN'] = @ruby_launcher
226224
@ruby_launcher
227225
end
228226
alias_method :require_ruby_launcher!, :ruby_launcher
229227

230228
def ruby_home
231-
File.expand_path('../..', ruby_launcher)
229+
require_ruby_launcher!
230+
File.expand_path('../..', @ruby_launcher_realpath)
232231
end
233232

234233
def graalvm_home
@@ -280,7 +279,8 @@ def truffleruby?
280279
end
281280

282281
def truffleruby_launcher_path
283-
@truffleruby_launcher_path ||= File.join File.dirname(ruby_launcher), 'truffleruby'
282+
require_ruby_launcher!
283+
@truffleruby_launcher_path ||= File.expand_path('../truffleruby', @ruby_launcher_realpath)
284284
end
285285

286286
def truffleruby!
@@ -2170,11 +2170,11 @@ def bootstrap_toolchain
21702170
dest_ruby = "#{dest}/#{language_dir(build_dir)}/ruby"
21712171
dest_bin = "#{dest_ruby}/bin"
21722172
FileUtils.rm_rf dest
2173-
FileUtils.cp_r build_dir, dest
2173+
File.symlink(build_dir, dest)
21742174

21752175
# Insert native wrapper around the bash launcher
21762176
# since nested shebang does not work on macOS when fish shell is used.
2177-
if darwin? && !truffleruby_native?
2177+
if darwin? && File.binread(truffleruby_launcher_path)[2] == '#!'
21782178
FileUtils.mv "#{dest_bin}/truffleruby", "#{dest_bin}/truffleruby.sh"
21792179
FileUtils.cp "#{TRUFFLERUBY_DIR}/tool/native_launcher_darwin", "#{dest_bin}/truffleruby"
21802180
end

0 commit comments

Comments
 (0)