Skip to content

Commit

Permalink
[Truffle] Tidy up finding clang and opt.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Nov 29, 2016
1 parent 65d6d5d commit a4c8e7b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions tool/jt.rb
Expand Up @@ -392,11 +392,13 @@ def mx_sulong(*args)
end

def clang(*args)
sh 'clang-3.3', *args
clang = ENV['JT_CLANG'] || 'clang'
sh clang, *args
end

def llvm_opt(*args)
sh 'opt-3.3', *args
opt = ENV['JT_OPT'] || 'opt'
sh opt, *args
end

def sulong_run(*args)
Expand Down Expand Up @@ -514,6 +516,7 @@ def help
SL_JAR The location of truffle-sl.jar
LIBXML_HOME, LIBXML_INCLUDE, LIBXML_LIB The location of libxml2 (the directory containing include etc), and the direct include directory and library file
OPENSSL_HOME, OPENSSL_INCLUDE, OPENSSL_LIB ... OpenSSL ...
JT_CLANG, JT_OPT LLVM binaries to use
TXT
end

Expand Down
3 changes: 3 additions & 0 deletions truffle/README.md
Expand Up @@ -223,6 +223,9 @@ $ export SULONG_HOME=.../sulong
$ export GRAAL_HOME=$SULONG_HOME
```

You need LLVM installed. Version 3.3 seems to work best. You can set `JT_CLANG`
and `JT_OPT` to those binaries if you need to use a non-system version.

You can now build the C extension support. Building the OpenSSL C extension is
incomplete, so most people probably want to disable that.

Expand Down
8 changes: 5 additions & 3 deletions truffle/src/main/ruby/core/rbconfig.rb
Expand Up @@ -89,16 +89,18 @@ module RbConfig
}

if Truffle::Safe.memory_safe? && Truffle::Safe.processes_safe?
cc = "clang-3.3 -I#{ENV['SULONG_HOME']}/include"
clang = ENV['JT_CLANG'] || 'clang'
opt = ENV['JT_OPT'] || 'opt'
cc = "#{clang} -I#{ENV['SULONG_HOME']}/include"
cpp = cc

MAKEFILE_CONFIG.merge!({
'CC' => cc,
'CPP' => cpp,
'COMPILE_C' => "$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$< -o $@ && opt-3.3 -always-inline -mem2reg $@ -o $@",
'COMPILE_C' => "$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$< -o $@ && #{opt} -always-inline -mem2reg $@ -o $@",
'CFLAGS' => "-c -emit-llvm",
'LINK_SO' => "mx -v -p #{ENV['SULONG_HOME']} su-link -o $@ $(OBJS) $(LIBS)",
'TRY_LINK' => "clang-3.3 $(src) $(INCFLAGS) $(CFLAGS) -I#{ENV['SULONG_HOME']}/include $(LIBS)"
'TRY_LINK' => "#{clang} $(src) $(INCFLAGS) $(CFLAGS) -I#{ENV['SULONG_HOME']}/include $(LIBS)"
})

CONFIG.merge!({
Expand Down

0 comments on commit a4c8e7b

Please sign in to comment.