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: 44e9778ef649
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f5ef89024c37
Choose a head ref
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Jul 22, 2016

  1. Copy the full SHA
    d1d6d5b View commit details
  2. Copy the full SHA
    93e013f View commit details
  3. Copy the full SHA
    b6544c3 View commit details
  4. Copy the full SHA
    f5ef890 View commit details
5 changes: 3 additions & 2 deletions ci.hocon
Original file line number Diff line number Diff line change
@@ -286,7 +286,7 @@ test-cexts: {
[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],
${jt} [build, cexts]
${jt} [build, cexts, --no-openssl]
]

environment: {
@@ -295,13 +295,14 @@ test-cexts: {
SULONG_HOME: sulong-workspace/sulong,
SULONG_NO_LIBRARY: "true",
USE_SYSTEM_CLANG: "true",
LIBXML_LIB: "$HOME/libxml2.so",
HOST_VM: server,
HOST_VM_CONFIG: graal-core
}

run: [
${jt} [test, specs, --graal, ":capi"],
${jt} [test, cexts]
${jt} [test, cexts, --no-libxml, --no-openssl]
]
}

4 changes: 2 additions & 2 deletions test/truffle/cexts/nokogiri/.jruby-cext-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
src: $GEM_HOME/gems/nokogiri-1.6.8/ext/nokogiri/*.c
cflags: -I$GEM_HOME/gems/nokogiri-1.6.8/ext/nokogiri -I$LIBXML_HOME/include/libxml2
libs: $LIBXML_HOME/lib/libxml2.dylib
cflags: -I$GEM_HOME/gems/nokogiri-1.6.8/ext/nokogiri -I$LIBXML_INCLUDE
libs: $LIBXML_LIB
out: lib/nokogiri/nokogiri.su
4 changes: 2 additions & 2 deletions test/truffle/cexts/xml/.jruby-cext-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
src: ext/xml/*.c
cflags: -I$LIBXML_HOME/include/libxml2
libs: $LIBXML_LIB_HOME/libxml2.so
cflags: -I$LIBXML_INCLUDE
libs: $LIBXML_LIB
out: lib/xml/xml.su
4 changes: 2 additions & 2 deletions test/truffle/cexts/xopenssl/.jruby-cext-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
src: ext/xopenssl/*.c
cflags: -I$OPENSSL_HOME/include
libs: $OPENSSL_LIB_HOME/libssl.so
cflags: -I$OPENSSL_INCLUDE
libs: $OPENSSL_LIB
out: lib/xopenssl/xopenssl.su
80 changes: 51 additions & 29 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -31,13 +31,23 @@
JEXCEPTION = "-Xtruffle.exceptions.print_java=true"
METRICS_REPS = 10

MAC = `uname -a`.include?('Darwin')

if MAC
SO = 'dylib'
else
SO = 'so'
end

LIBXML_HOME = ENV['LIBXML_HOME'] = ENV['LIBXML_HOME'] || '/usr'
LIBXML_LIB_HOME = ENV['LIBXML_LIB_HOME'] = ENV['LIBXML_LIB_HOME'] || "#{LIBXML_HOME}/lib"
LIBXML_INCLUDE = ENV['LIBXML_INCLUDE'] = ENV['LIBXML_INCLUDE'] || "#{LIBXML_HOME}/include/libxml2"
LIBXML_LIB = ENV['LIBXML_LIB'] = ENV['LIBXML_LIB'] || "#{LIBXML_LIB_HOME}/libxml2.#{SO}"

OPENSSL_HOME = ENV['OPENSSL_HOME'] = ENV['OPENSSL_HOME'] || '/usr'
OPENSSL_LIB_HOME = ENV['OPENSSL_LIB_HOME'] = ENV['OPENSSL_LIB_HOME'] || "#{OPENSSL_HOME}/lib"

MAC = `uname -a`.include?('Darwin')
OPENSSL_INCLUDE = ENV['OPENSSL_INCLUDE'] = ENV['OPENSSL_INCLUDE'] || "#{OPENSSL_HOME}/include"
OPENSSL_LIB = ENV['OPENSSL_LIB'] = ENV['OPENSSL_LIB'] || "#{OPENSSL_LIB_HOME}/libssl.#{SO}"

# wait for sub-processes to handle the interrupt
trap(:INT) {}
@@ -337,7 +347,6 @@ def maven_options(*options)
def mx(dir, *args)
command = ['mx', '-p', dir]
command.push *['--java-home', ENV['JVMCI_JAVA_HOME']] if ENV['JVMCI_JAVA_HOME']
command.push '-v'
command.push *args
sh *command
end
@@ -390,7 +399,7 @@ def help
puts 'jt build [options] build'
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_HOME and mabye USE_SYSTEM_CLANG)'
puts ' cexts [--no-openssl] build the cext backend (set SULONG_HOME and maybe USE_SYSTEM_CLANG)'
puts ' --offline use the build pack to build offline'
puts 'jt clean clean'
puts 'jt irb irb'
@@ -423,7 +432,7 @@ def help
puts 'jt test gems tests using gems'
puts 'jt test ecosystem [--offline] tests using the wider ecosystem such as bundler, Rails, etc'
puts ' (when --offline it will not use rubygems.org)'
puts 'jt test cexts run C extension tests'
puts 'jt test cexts [--no-libxml --no-openssl] run C extension tests'
puts ' (implies --graal, where Graal needs to include Sulong, set SULONG_HOME to a built checkout of Sulong, and set GEM_HOME)'
puts 'jt test report :language build a report on language specs'
puts ' :core (results go into test/target/mspec-html-report)'
@@ -459,8 +468,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 ' LIBXML_HOME The location of libxml2 (the directory containing include etc)'
puts ' LIBXML_HOME, LIBXML_INCLUDE, LIBXML_LIB The location of libxml2 (the directory containing include etc), and the direct include directory and library file'
puts ' OPENSSL_HOME, OPENSSL_INCLUDE, OPENSSL_LIB ... OpenSSL ...'
end

def checkout(branch)
@@ -481,14 +490,17 @@ def build(*options)
when 'truffle'
mvn env, *maven_options, '-pl', 'truffle', 'package'
when 'cexts'
no_openssl = options.delete('--no-openssl')

cextc "#{JRUBY_DIR}/truffle/src/main/c/cext"

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

#cextc "#{JRUBY_DIR}/truffle/src/main/c/openssl",
# "-I#{openssl_home}/include",
# '-DRUBY_EXTCONF_H="extconf.h"',
# '-Werror=implicit-function-declaration'
unless no_openssl
#cextc "#{JRUBY_DIR}/truffle/src/main/c/openssl",
# '-DRUBY_EXTCONF_H="extconf.h"',
# '-Werror=implicit-function-declaration'
end
when nil
mvn env, *maven_options, 'package'
else
@@ -639,7 +651,9 @@ def cextc(cext_dir, *clang_opts)

if MAC
config_libs.each do |lib|
lib['.so'] = '.dylib'
if lib.include?('.so')
lib['.so'] = '.dylib'
end
end
end

@@ -727,37 +741,44 @@ def test_compiler(*args)
private :test_compiler

def test_cexts(*args)
if MAC
so = 'dylib'
else
so = 'so'
end
no_libxml = args.delete('--no-libxml')
no_openssl = args.delete('--no-openssl')

# 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_LIB_HOME}/libxml2.#{so}", 'test/truffle/cexts/xml/main.ll', {capture: true})
raise unless out == "7\n"
unless no_libxml
clang '-S', '-emit-llvm', "-I#{LIBXML_INCLUDE}", 'test/truffle/cexts/xml/main.c', '-o', 'test/truffle/cexts/xml/main.ll'
out, _ = sulong_run("-l#{LIBXML_LIB}", 'test/truffle/cexts/xml/main.ll', {capture: true})
raise unless out == "7\n"
end

clang '-S', '-emit-llvm', "-I#{OPENSSL_HOME}/include", 'test/truffle/cexts/xopenssl/main.c', '-o', 'test/truffle/cexts/xopenssl/main.ll'
out, _ = sulong_run("-l#{OPENSSL_LIB_HOME}/libssl.#{so}", 'test/truffle/cexts/xopenssl/main.ll', {capture: true})
raise unless out == "5d41402abc4b2a76b9719d911017c592\n"
unless no_openssl
clang '-S', '-emit-llvm', "-I#{OPENSSL_INCLUDE}", 'test/truffle/cexts/xopenssl/main.c', '-o', 'test/truffle/cexts/xopenssl/main.ll'
out, _ = sulong_run("-l#{OPENSSL_LIB}", 'test/truffle/cexts/xopenssl/main.ll', {capture: true})
raise unless out == "5d41402abc4b2a76b9719d911017c592\n"
end

# Test that we can run those same test when they're build as a .su and we load the code and libraries from that

sulong_link '-o', 'test/truffle/cexts/xml/main.su', '-l', "#{LIBXML_LIB_HOME}/libxml2.#{so}", 'test/truffle/cexts/xml/main.ll'
out, _ = sulong_run('test/truffle/cexts/xml/main.su', {capture: true})
raise unless out == "7\n"
unless no_libxml
sulong_link '-o', 'test/truffle/cexts/xml/main.su', '-l', "#{LIBXML_LIB}", 'test/truffle/cexts/xml/main.ll'
out, _ = sulong_run('test/truffle/cexts/xml/main.su', {capture: true})
raise unless out == "7\n"
end

sulong_link '-o', 'test/truffle/cexts/xopenssl/main.su', '-l', "#{OPENSSL_LIB_HOME}/libssl.#{so}", 'test/truffle/cexts/xopenssl/main.ll'
out, _ = sulong_run('test/truffle/cexts/xopenssl/main.su', {capture: true})
raise unless out == "5d41402abc4b2a76b9719d911017c592\n"
unless no_openssl
sulong_link '-o', 'test/truffle/cexts/xopenssl/main.su', '-l', "#{OPENSSL_LIB}", 'test/truffle/cexts/xopenssl/main.ll'
out, _ = sulong_run('test/truffle/cexts/xopenssl/main.su', {capture: true})
raise unless out == "5d41402abc4b2a76b9719d911017c592\n"
end

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

begin
output_file = 'cext-output.txt'
['minimum', 'method', 'module', 'globals', 'xml', 'xopenssl'].each do |gem_name|
next if gem_name == 'xml' && no_libxml
next if gem_name == 'xopenssl' && no_openssl
dir = "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}"
cextc dir
name = File.basename(dir)
@@ -779,6 +800,7 @@ def test_cexts(*args)
['nokogiri', [], ['nokogiri']]
].each do |gem_name, dependencies, libs|
next if gem_name == 'nokogiri' # nokogiri totally excluded
next if gem_name == 'nokogiri' && no_libxml
config = "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}"
cextc config, '-Werror=implicit-function-declaration'
next if gem_name == 'psd_native' # psd_native is excluded just for running
4 changes: 2 additions & 2 deletions truffle/src/main/c/openssl/.jruby-cext-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
src: ./*.c
cflags: -I$OPENSSL_HOME/include
libs: $OPENSSL_LIB_HOME/libssl.so
cflags: -I$OPENSSL_INCLUDE
libs: $OPENSSL_LIB
out: ../../../../../lib/ruby/truffle/openssl/openssl.su