Skip to content

Commit

Permalink
[Truffle] Updating RbConfig for mkmf Makefile usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Fish committed Oct 29, 2016
1 parent 56423ce commit 4ec2581
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/ruby/truffle/cext/ruby/defines.h
@@ -0,0 +1,3 @@
/*
* Intentionally blank for now to satisfy Makefile reference
*/
3 changes: 3 additions & 0 deletions lib/ruby/truffle/cext/ruby/intern.h
@@ -0,0 +1,3 @@
/*
* Intentionally blank for now to satisfy Makefile reference
*/
3 changes: 3 additions & 0 deletions lib/ruby/truffle/cext/ruby/missing.h
@@ -0,0 +1,3 @@
/*
* Intentionally blank for now to satisfy Makefile reference
*/
3 changes: 3 additions & 0 deletions lib/ruby/truffle/cext/ruby/ruby.h
@@ -0,0 +1,3 @@
/*
* Intentionally blank for now to satisfy Makefile reference
*/
3 changes: 3 additions & 0 deletions lib/ruby/truffle/cext/ruby/st.h
@@ -0,0 +1,3 @@
/*
* Intentionally blank for now to satisfy Makefile reference
*/
3 changes: 3 additions & 0 deletions lib/ruby/truffle/cext/ruby/subst.h
@@ -0,0 +1,3 @@
/*
* Intentionally blank for now to satisfy Makefile reference
*/
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/mkmf.rb
@@ -0,0 +1 @@
require_relative '../../stdlib/mkmf'
55 changes: 54 additions & 1 deletion truffle/src/main/ruby/core/rbconfig.rb
Expand Up @@ -30,11 +30,64 @@ module RbConfig
# 'RUBY_INSTALL_NAME' => 'jruby',
'ruby_version' => '2.2.0',
'OBJEXT' => 'll',
'DLEXT' => 'su'
'DLEXT' => 'su',
'rubyhdrdir' => "#{jruby_home}/lib/ruby/truffle/cext",
'topdir' => "#{jruby_home}/lib/ruby/stdlib",
"rubyarchhdrdir"=>"#{jruby_home}/lib/ruby/truffle/cext",
'includedir' => ''
}

MAKEFILE_CONFIG = {
'CC' => "mx -p #{ENV['SULONG_HOME']} su-clang -I#{ENV['SULONG_HOME']}/include",
'configure_args' => ' ',
'CFLAGS' => " -S -emit-llvm -I#{ENV['OPENSSL_HOME']}/include -DRUBY_EXTCONF_H=\"extconf.h\" -DHAVE_OPENSSL_110_THREADING_API -DHAVE_HMAC_CTX_COPY -DHAVE_EVP_CIPHER_CTX_COPY -DHAVE_BN_RAND_RANGE -DHAVE_BN_PSEUDO_RAND_RANGE -DHAVE_X509V3_EXT_NCONF_NID -Wall -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-unused-variable -Wno-uninitialized -Wno-unused-function -Werror ",
'ARCH_FLAG' => '',
'CPPFLAGS' => '',
'LDFLAGS' => '',
'DLDFLAGS' => '',
'DLEXT' => 'su',
'LIBEXT' => 'c',
'OBJEXT' => 'll',
'EXEEXT' => '',
'LIBS' => '',
'DLDLIBS' => '',
'LIBRUBYARG_STATIC' => '',
'LIBRUBYARG_SHARED' => '',
'libdirname' => 'libdir',
'LIBRUBY' => '',
'LIBRUBY_A' => '',
'LIBRUBYARG' => '',
'prefix' => '',
'ruby_install_name' => 'jruby-truffle',
'RUBY_SO_NAME' => '$(RUBY_BASE_NAME)',
'hdrdir' => "#{jruby_home}/lib/ruby/truffle/cext",
'COMPILE_C' => '$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$< -o $@',
'LINK_SO' => "mx -p #{ENV['SULONG_HOME']} su-link -o $@ $(OBJS)"
}

def self.ruby
# TODO (eregon, 30 Sep 2016): should be the one used by the launcher!
File.join CONFIG['bindir'], CONFIG['ruby_install_name'], CONFIG['exeext']
end

def RbConfig::expand(val, config = CONFIG)
newval = val.gsub(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) {
var = $&
if !(v = $1 || $2)
'$'
elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
pat, sub = $1, $2
config[v] = false
config[v] = RbConfig::expand(key, config)
key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
key
else
var
end
}
val.replace(newval) unless newval == val
val
end

This comment has been minimized.

Copy link
@eregon

eregon Oct 30, 2016

Member

Add the license if you import this from somewhere else.

This comment has been minimized.

Copy link
@bjfish

This comment has been minimized.

Copy link
@eregon

eregon Nov 1, 2016

Member

Ruby's BSDL seems appropriate here,

This comment has been minimized.

Copy link
@bjfish

bjfish Nov 1, 2016

Contributor

@eregon license added here: e93d9c7

end

CROSS_COMPILING = nil

1 comment on commit 4ec2581

@bjfish
Copy link
Contributor

@bjfish bjfish commented on 4ec2581 Oct 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an initial configuration which I was able to use to run extconf.rb and make for the minimum test gem. My usage was as follows:

cd ~/Documents/jruby/test/truffle/cexts/minimum/ext/minimum/
OPENSSL_HOME=/usr/local/opt/openssl SULONG_HOME=/Users/brandonfish/Documents/suparent/sulong ../../../../../../bin/jruby -X+T extconf.rb
make

with the following workarounds in place:
https://gist.github.com/bjfish/21fede4b4d77ec36d12a287aff8a4e45

Please sign in to comment.