Skip to content

Commit 01318c0

Browse files
committed
Build improvements
* `jt build native` is removed and native-ruby link as well * instead `jt build --native` is added to build GVM with native ruby image * --graal and --no-graal options added to control compiler addition * by default the compiler is excluded * `--name` option added to specify the subdirectory in mxbuild * symlink the built ruby into rbenv and chruby * run ci with graal compiler enabled
1 parent d4650ef commit 01318c0

File tree

4 files changed

+40
-35
lines changed

4 files changed

+40
-35
lines changed

src/test/java/org/truffleruby/ContextPermissionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void testNoPermissions() throws Throwable {
3030
@Test
3131
public void testNativeNoThreads() throws Throwable {
3232
// TODO (eregon, 4 Feb 2019): This should run on GraalVM, not development jars
33-
String home = System.getProperty("user.dir") + "/mxbuild/graalvm/jre/languages/ruby";
33+
String home = System.getProperty("user.dir") + "/mxbuild/truffleruby-jvm/jre/languages/ruby";
3434
try (Context context = Context.newBuilder("ruby").allowNativeAccess(true).allowExperimentalOptions(true).option("ruby.home", home).build()) {
3535
Assert.assertEquals(3, context.eval("ruby", "1 + 2").asInt());
3636

test/truffle/ecosystem/blog.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ test "$(curl -s "$url")" = '[]'
6969
kill_server
7070

7171
# put back the original bin/rake, as it gets overwritten by bundle install
72-
cp $repo/bin/rake $repo/mxbuild/graalvm/bin/rake
73-
cp $repo/bin/rake $repo/mxbuild/graalvm/jre/bin/rake
74-
cp $repo/bin/rake $repo/mxbuild/graalvm/jre/languages/ruby/bin/rake
72+
cp $repo/bin/rake $repo/mxbuild/truffleruby-jvm/bin/rake
73+
cp $repo/bin/rake $repo/mxbuild/truffleruby-jvm/jre/bin/rake
74+
cp $repo/bin/rake $repo/mxbuild/truffleruby-jvm/jre/languages/ruby/bin/rake

tool/jt.rb

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ def find_mx
231231

232232
def find_launcher(use_native)
233233
if use_native
234-
ENV['AOT_BIN'] || "#{TRUFFLERUBY_DIR}/bin/native-ruby"
234+
ENV['AOT_BIN'] || "#{TRUFFLERUBY_DIR}/mxbuild/truffleruby-native/jre/languages/ruby/bin/ruby"
235235
else
236-
ENV['RUBY_BIN'] || "#{TRUFFLERUBY_DIR}/mxbuild/graalvm/jre/languages/ruby/bin/ruby"
236+
ENV['RUBY_BIN'] || "#{TRUFFLERUBY_DIR}/mxbuild/truffleruby-jvm/jre/languages/ruby/bin/ruby"
237237
end
238238
end
239239

@@ -519,17 +519,19 @@ module Commands
519519

520520
def help
521521
puts <<-TXT.gsub(/^#{' '*6}/, '')
522-
jt build [options] build
522+
jt build [what] [options] by default it builds graalvm
523+
--no-sforceimports do not run sforceimports before building
523524
parser build the parser
524525
options build the options
525526
cexts build only the C extensions (part of "jt build")
526-
graalvm [--graal] [--native] build a minimal JVM-only GraalVM containing only TruffleRuby
527-
--graal include the GraalVM Compiler in the build
528-
--native build native ruby image as well
529-
native [--no-sulong] [--no-tools] [extra mx image options]
530-
build a native image of TruffleRuby
531-
(--no-tools to exclude chromeinspector and profiler)
532-
--no-sforceimports
527+
graalvm build a minimal JVM-only GraalVM containing only TruffleRuby,
528+
available by default in mxbuild/truffleruby-jvm,
529+
the Ruby is symlinked into rbenv or chruby if available
530+
--graal include the GraalVM Compiler in the build
531+
--native build native ruby image as well, available in mxbuild/truffleruby-native
532+
--name NAME specify the name of the build "mxbuild/truffleruby-NAME"
533+
it is also linked in your ruby manager (if found) under the same name
534+
the named build stays until it is rebuilt or deleted manually
533535
jt build_stats [--json] <attribute> prints attribute's value from build process (e.g., binary size)
534536
jt clean clean
535537
jt env prints the current environment
@@ -1159,7 +1161,7 @@ def test_cexts(*args)
11591161

11601162
# Test that running the post-install hook works, even when opt &
11611163
# llvm-link are not on PATH, as it is the case on macOS.
1162-
sh({'TRUFFLERUBY_RECOMPILE_OPENSSL' => 'true'}, 'mxbuild/graalvm/jre/languages/ruby/lib/truffle/post_install_hook.sh')
1164+
sh({'TRUFFLERUBY_RECOMPILE_OPENSSL' => 'true'}, 'mxbuild/truffleruby-jvm/jre/languages/ruby/lib/truffle/post_install_hook.sh')
11631165

11641166
when 'gems'
11651167
# Test that we can compile and run some real C extensions
@@ -1932,6 +1934,12 @@ def build_graalvm(*options)
19321934

19331935
graal = options.delete('--graal')
19341936
native = options.delete('--native')
1937+
name = if (i = options.index('--name'))
1938+
options.delete_at(i)
1939+
options.delete_at(i)
1940+
else
1941+
native ? 'native' : 'jvm'
1942+
end
19351943

19361944
mx_args = ['-p', TRUFFLERUBY_DIR,
19371945
'--dynamicimports', '/vm',
@@ -1942,34 +1950,31 @@ def build_graalvm(*options)
19421950
mx(*mx_args, 'build')
19431951
build_dir = mx(*mx_args, 'graalvm-home', capture: true).lines.last.chomp
19441952

1945-
dest = "#{TRUFFLERUBY_DIR}/mxbuild/graalvm"
1953+
dest = "#{TRUFFLERUBY_DIR}/mxbuild/truffleruby-#{name}"
1954+
dest_ruby = "#{dest}/jre/languages/ruby"
1955+
dest_bin = "#{dest_ruby}/bin"
19461956
FileUtils.rm_rf dest
19471957
FileUtils.cp_r build_dir, dest
19481958

1959+
# Insert native wrapper around the bash launcher
1960+
# since nested shebang does not work on macOS when fish shell is used.
19491961
if MAC && !native
1950-
bin = "#{dest}/jre/languages/ruby/bin"
1951-
FileUtils.mv "#{bin}/truffleruby", "#{bin}/truffleruby.sh"
1952-
FileUtils.cp "#{TRUFFLERUBY_DIR}/tool/native_launcher_darwin", "#{bin}/truffleruby"
1962+
FileUtils.mv "#{dest_bin}/truffleruby", "#{dest_bin}/truffleruby.sh"
1963+
FileUtils.cp "#{TRUFFLERUBY_DIR}/tool/native_launcher_darwin", "#{dest_bin}/truffleruby"
19531964
end
1954-
end
1955-
1956-
def build_native_image(*options)
1957-
sforceimports = !options.delete("--no-sforceimports")
19581965

1959-
mx 'sforceimports' if sforceimports
1966+
# Symlink builds into version manager
1967+
rbenv_root = ENV['RBENV_ROOT']
1968+
rubies_dir = File.join(rbenv_root, 'versions') if rbenv_root && File.directory?(rbenv_root)
19601969

1961-
graal = checkout_or_update_graal_repo(sforceimports: sforceimports)
1970+
chruby_versions = File.expand_path('~/.rubies')
1971+
rubies_dir = chruby_versions if File.directory?(chruby_versions)
19621972

1963-
mx_args = %w[--dynamicimports /substratevm,truffleruby --disable-polyglot --disable-libpolyglot --force-bash-launchers=lli,native-image]
1964-
1965-
puts 'Building TruffleRuby native binary'
1966-
chdir("#{graal}/vm") do
1967-
mx *mx_args, 'build'
1973+
if rubies_dir
1974+
link_path = "#{rubies_dir}/#{name}"
1975+
File.delete link_path if File.exist? link_path
1976+
File.symlink dest_ruby, link_path
19681977
end
1969-
1970-
local_target = "#{TRUFFLERUBY_DIR}/bin/native-ruby"
1971-
built_bin = Dir.glob("#{graal}/vm/mxbuild/#{mx_os}-amd64/RUBY_STANDALONE_SVM/*/bin/ruby").first
1972-
FileUtils.ln_sf(built_bin, local_target)
19731978
end
19741979

19751980
def next(*args)

tool/sync.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
require 'fileutils'
1818

1919
FROM = File.expand_path('../..', File.realpath(__FILE__))
20-
TO = "#{FROM}/mxbuild/graalvm/jre/languages/ruby"
20+
TO = "#{FROM}/mxbuild/truffleruby-jvm/jre/languages/ruby"
2121

2222
# Must be consistent with TRUFFLERUBY_GRAALVM_SUPPORT in suite.py
2323
DIRS_TO_SYNC = %w[

0 commit comments

Comments
 (0)