Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 57706824206e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2ecbb0b3b0ce
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on Jul 4, 2016

  1. Copy the full SHA
    06e2e03 View commit details
  2. Copy the full SHA
    5bab7be View commit details
  3. Copy the full SHA
    b3de28f View commit details
  4. [Truffle] jt build cexts

    chrisseaton committed Jul 4, 2016
    Copy the full SHA
    2ecbb0b View commit details
77 changes: 0 additions & 77 deletions bin/jruby-cext-c

This file was deleted.

5 changes: 3 additions & 2 deletions ci.hocon
Original file line number Diff line number Diff line change
@@ -252,7 +252,7 @@ test-cexts: {
downloads: {
JVMCI_JAVA_HOME: {
name: labsjdk,
version: "8u92-jvmci-0.16",
version: "8u92-jvmci-0.17",
platformspecific: true
}
}
@@ -267,7 +267,8 @@ test-cexts: {
[mx, --java-home, "$JVMCI_JAVA_HOME", build],
[cd, ../..],
[mv, temp_mx, mx.jruby]
[mx, sclone, --kind, git, "https://github.com/jruby/jruby-truffle-gem-test-pack.git", jruby-truffle-gem-test-pack]
[mx, sclone, --kind, git, "https://github.com/jruby/jruby-truffle-gem-test-pack.git", jruby-truffle-gem-test-pack],
${jt} [build, cexts]
]

environment: {
Binary file removed lib/ruby/truffle/cext/ruby.su
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/ruby/optional/capi/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ def compile_extension_jruby_truffle(name)
f.puts "out: #{output_file}"
end

system "#{RbConfig::CONFIG['bindir']}/jruby", "#{RbConfig::CONFIG['bindir']}/jruby-cext-c", extension_path
system "#{RbConfig::CONFIG['bindir']}/jruby", "#{RbConfig::CONFIG['bindir']}/../tool/jt.rb", 'cextc', extension_path

output_file
ensure
68 changes: 61 additions & 7 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -16,11 +16,13 @@
require 'fileutils'
require 'json'
require 'timeout'
require 'yaml'

GRAALVM_VERSION = '0.12'

JRUBY_DIR = File.expand_path('../..', __FILE__)
M2_REPO = File.expand_path('~/.m2/repository')
SULONG_DIR = ENV['SULONG_DIR']

JDEBUG_PORT = 51819
JDEBUG = "-J-agentlib:jdwp=transport=dt_socket,server=y,address=#{JDEBUG_PORT},suspend=y"
@@ -307,6 +309,13 @@ def maven_options(*options)
end
return [maven_options, options]
end

def mx(dir, *args)
command = ['mx', '-p', dir]
command.push *['--java-home', ENV['JVMCI_JAVA_HOME']] if ENV['JVMCI_JAVA_HOME']
command.push *args
sh *command
end

def mspec(command, *args)
env_vars = {}
@@ -330,8 +339,9 @@ def help
puts 'jt checkout name checkout a different Git branch and rebuild'
puts 'jt bootstrap [options] run the build system\'s bootstrap phase'
puts 'jt build [options] build'
puts 'jt build truffle [options] build only the Truffle part, assumes the rest is up-to-date'
puts 'jt rebuild [options] clean and build'
puts ' truffle build only the Truffle part, assumes the rest is up-to-date'
puts ' cexts build the cext backend (set SULONG_DIR and mabye USE_SYSTEM_CLANG)'
puts ' --offline use the build pack to build offline'
puts 'jt clean clean'
puts 'jt irb irb'
@@ -348,7 +358,8 @@ def help
puts ' --exec use exec rather than system'
puts 'jt e 14 + 2 evaluate an expression'
puts 'jt puts 14 + 2 evaluate and print an expression'
puts 'jt test run all mri tests, specs and integration tests'
puts 'jt cextc directory clang-args compile the C extension in directory, with optional extra clang arguments'
puts 'jt test run all mri tests, specs and integration tests (set SULONG_DIR, and maybe USE_SYSTEM_CLANG)'
puts 'jt test tck [--jdebug] run the Truffle Compatibility Kit tests'
puts 'jt test mri run mri tests'
puts 'jt test specs run all specs'
@@ -393,7 +404,8 @@ def help
puts ' JVMCI_JAVA_HOME The Java with JVMCI to use with GRAAL_HOME'
puts ' GRAALVM_RELEASE_BIN Default GraalVM executable when using a released version of Truffle (such as on master)'
puts ' GRAAL_HOME_TRUFFLE_HEAD Default Graal directory when using a snapshot version of Truffle (such as on truffle-head)'
puts ' SULONG_DIR The Sulong source repository, if you want to run bin/jruby-cext-c'
puts ' SULONG_DIR The Sulong source repository, if you want to run cextc'
puts ' USE_SYSTEM_CLANG Use the system clang rather than Sulong\'s when compiling C extensions'
puts ' GRAAL_JS_JAR The location of trufflejs.jar'
puts ' SL_JAR The location of truffle-sl.jar'
end
@@ -415,6 +427,8 @@ def build(*options)
case project
when 'truffle'
mvn env, *maven_options, '-pl', 'truffle', 'package'
when 'cexts'
cextc "#{JRUBY_DIR}/truffle/src/main/c/cext"
when nil
mvn env, *maven_options, 'package'
else
@@ -520,6 +534,45 @@ def command_puts(*args)
def command_p(*args)
e 'p begin', *args, 'end'
end

def cextc(cext_dir, *clang_opts)
config_file = File.join(cext_dir, '.jruby-cext-build.yml')

unless File.exist?(config_file)
abort "There is no .jruby-cext-build.yml in #{cext_dir} at the moment - I don't know how to build it"
end

config = YAML.load_file(config_file)
config_src = config['src']

if config_src.start_with?('$GEM_HOME/')
src = Dir[ENV['GEM_HOME'] + config_src['$GEM_HOME'.size..-1]]
else
src = Dir[File.join(cext_dir, config_src)]
end

out = File.expand_path(config['out'], cext_dir)
lls = []

src.each do |src|
ll = File.join(File.dirname(out), File.basename(src, '.*') + '.ll')

clang_args = ["-I#{SULONG_DIR}/include", '-Ilib/ruby/truffle/cext', '-S', '-emit-llvm', *clang_opts, src, '-o', ll]
opt_args = ['-S', '-mem2reg', ll, '-o', ll]

if ENV['USE_SYSTEM_CLANG']
sh 'clang', *clang_args
sh 'opt', *opt_args
else
mx SULONG_DIR, 'su-clang', *clang_args
mx SULONG_DIR, 'su-opt', *opt_args
end

lls.push ll
end

mx SULONG_DIR, 'su-link', '-o', out, *lls
end

def test(*args)
path, *rest = args
@@ -606,7 +659,7 @@ def test_cexts(*args)
output_file = 'cext-output.txt'
['minimum', 'method', 'module'].each do |gem_name|
dir = "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}"
sh Utilities.find_jruby, "#{JRUBY_DIR}/bin/jruby-cext-c", dir
cextc dir
name = File.basename(dir)
run '--graal', '-I', "#{dir}/lib", "#{dir}/bin/#{name}", :out => output_file
unless File.read(output_file) == File.read("#{dir}/expected.txt")
@@ -622,7 +675,7 @@ def test_cexts(*args)
['psd_native', ['chunky_png-1.3.6', 'oily_png-1.2.0', 'bindata-2.3.1', 'hashie-3.4.4', 'psd-enginedata-1.1.1', 'psd-2.1.2', 'psd_native-1.1.3'], ['oily_png', 'psd_native']]
].each do |gem_name, dependencies, libs|
config = "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}"
sh Utilities.find_jruby, "#{JRUBY_DIR}/bin/jruby-cext-c", config, '-Werror=implicit-function-declaration'
cextc config, '-Werror=implicit-function-declaration'
arguments = []
run '--graal',
*(dependencies.map { |d| ['-I', "#{ENV['GEM_HOME']}/gems/#{d}/lib"] }.flatten),
@@ -1026,8 +1079,9 @@ def main(args)
send(args.shift)
when "build"
command = [args.shift]
command << args.shift if args.first == "truffle"
command << args.shift if args.first == "--offline"
while ['truffle', 'cexts', '--offline'].include?(args.first)
command << args.shift
end
send(*command)
end

10 changes: 0 additions & 10 deletions truffle/src/main/c/cext/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import org.jruby.truffle.RubyLanguage;
import org.jruby.truffle.core.array.ArrayOperations;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.truffle.language.control.RaiseException;

public class FeatureLoader {

@@ -130,6 +131,11 @@ public void ensureCExtImplementationLoaded(VirtualFrame frame, IndirectCallNode
@TruffleBoundary
private CallTarget getCExtLibRuby() {
final String path = context.getJRubyRuntime().getJRubyHome() + "/lib/ruby/truffle/cext/ruby.su";

if (!new File(path).exists()) {
throw new RaiseException(context.getCoreExceptions().internalError("This JRuby distribution does not have the C extension implementation file ruby.su", null));
}

try {
return parseSource(context.getSourceLoader().load(path));
} catch (IOException e) {