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: c8d8226df1e3
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 061904632288
Choose a head ref
  • 5 commits
  • 1 file changed
  • 1 contributor

Commits on Jul 11, 2016

  1. Copy the full SHA
    b2f1872 View commit details
  2. Copy the full SHA
    25b47dc View commit details
  3. Copy the full SHA
    c28d9e0 View commit details
  4. Copy the full SHA
    c142c3a View commit details
  5. Copy the full SHA
    0619046 View commit details
Showing with 56 additions and 16 deletions.
  1. +56 −16 tool/jt.rb
72 changes: 56 additions & 16 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
require 'json'
require 'timeout'
require 'yaml'
require 'open3'

GRAALVM_VERSION = '0.12'

@@ -233,6 +234,7 @@ def raw_sh(*args)
continue_on_failure = options.delete :continue_on_failure
use_exec = options.delete :use_exec
timeout = options.delete :timeout
capture = options.delete :capture

unless options.delete :no_print_cmd
STDERR.puts "$ #{printable_cmd(args)}"
@@ -242,12 +244,19 @@ def raw_sh(*args)
result = exec(*args)
elsif timeout
result = system_timeout(timeout, *args)
elsif capture
out, err, status = Open3.capture3(*args)
result = status.exitstatus == 0
else
result = system(*args)
end

if result
true
if out && err
[out, err]
else
true
end
elsif continue_on_failure
false
else
@@ -317,6 +326,26 @@ def mx(dir, *args)
sh *command
end

def clang(*args)
if ENV['USE_SYSTEM_CLANG']
sh 'clang', *args
else
mx SULONG_DIR, 'su-clang', *args
end
end

def llvm_opt(*args)
if ENV['USE_SYSTEM_CLANG']
sh 'opt', *args
else
mx SULONG_DIR, 'su-opt', *args
end
end

def sulong_run(*args)
mx SULONG_DIR, 'su-run', *args
end

def mspec(command, *args)
env_vars = {}
if command.is_a?(Hash)
@@ -409,7 +438,8 @@ def help
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'
puts ' OPENSSL_HOME The location of OpenSSL (the directory containing include etc)'
puts ' OPENSSL_HOME The location of OpenSSL (the directory containing include etc)'
puts ' LIBXML_HOME The location of libxml2 (the directory containing include etc)'
end

def checkout(branch)
@@ -431,9 +461,11 @@ def build(*options)
mvn env, *maven_options, '-pl', 'truffle', 'package'
when 'cexts'
cextc "#{JRUBY_DIR}/truffle/src/main/c/cext"

openssl_home = ENV['OPENSSL_HOME'] || '/usr'

#cextc "#{JRUBY_DIR}/truffle/src/main/c/openssl",
# "-I#{ENV['OPENSSL_HOME']}/include",
# "-I#{openssl_home}/include",
# '-DRUBY_EXTCONF_H="extconf.h"',
# '-Werror=implicit-function-declaration'
when nil
@@ -575,17 +607,9 @@ def cextc(cext_dir, *clang_opts)
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', *config_cflags, *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

clang "-I#{SULONG_DIR}/include", '-Ilib/ruby/truffle/cext', '-S', '-emit-llvm', *config_cflags, *clang_opts, src, '-o', ll
llvm_opt '-S', '-mem2reg', ll, '-o', ll

lls.push ll
end

@@ -673,6 +697,21 @@ def test_compiler(*args)
private :test_compiler

def test_cexts(*args)
libxml_home = ENV['LIBXML_HOME'] || '/usr'
openssl_home = ENV['OPENSSL_HOME'] || '/usr'

# Test that we can compile and run some basic C code that uses libxml and openssl

clang '-S', '-emit-llvm', "-I#{libxml_home}/include/libxml2", 'test/truffle/cexts/xml/main.c', '-o', 'test/truffle/cexts/xml/main.ll'
out, _ = sulong_run("-l#{libxml_home}/lib/libxml2.dylib", 'test/truffle/cexts/xml/main.ll', {capture: true})
raise unless out == "7\n"

clang '-S', '-emit-llvm', "-I#{openssl_home}/include", 'test/truffle/cexts/openssl/main.c', '-o', 'test/truffle/cexts/openssl/main.ll'
out, _ = sulong_run("-l#{openssl_home}/lib/libssl.dylib", 'test/truffle/cexts/openssl/main.ll', {capture: true})
raise unless out == "7369676e616c2066756e6374696f6e20\n"

# Test that we can compile and run some very basic C extensions

begin
output_file = 'cext-output.txt'
['minimum', 'method', 'module'].each do |gem_name|
@@ -687,7 +726,9 @@ def test_cexts(*args)
ensure
File.delete output_file rescue nil
end


# Test that we can compile and run some real C extensions

[
['oily_png', ['chunky_png-1.3.6', 'oily_png-1.2.0'], ['oily_png']],
['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']],
@@ -696,7 +737,6 @@ def test_cexts(*args)
next if gem_name == 'nokogiri' # nokogiri totally excluded
config = "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}"
cextc config, '-Werror=implicit-function-declaration'
arguments = []
run '--graal',
*dependencies.map { |d| "-I#{ENV['GEM_HOME']}/gems/#{d}/lib" },
*libs.map { |l| "-I#{JRUBY_DIR}/test/truffle/cexts/#{l}/lib" },