Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow for a binary llvm-config

Also cleans up the handling of flags for both the prebuilt and source
version and an existing LLVM installation through llvm-config. We store
the complete command to execute llvm-config and reuse that to setup the
necessary flags for LLVM.
  • Loading branch information...
commit abe162ebd3da12d1ab445f1025eaf4f84c099b93 1 parent 22accd5
@dbussink dbussink authored
Showing with 47 additions and 34 deletions.
  1. +25 −6 configure
  2. +22 −28 rakelib/blueprint.rb
View
31 configure
@@ -495,6 +495,7 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
if File.exists?(@llvm_include_path)
@llvm = :svn
+ @llvm_configure = llvm_config_cmd "#{@llvm_default}/Release/bin/llvm-config"
return true
else
@log.write " Code doesn't appear to be proper LLVM tree!"
@@ -576,6 +577,7 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
end
@log.write "done!"
@llvm = :prebuilt
+ @llvm_configure = llvm_config_cmd "#{dir}/Release/bin/llvm-config"
return true
end
end
@@ -591,8 +593,9 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
sub = File.join(@llvm_path, which, "bin")
if File.directory? sub
@log.write "Ok! Using #{which}"
- @llvm_configure = File.join(@llvm_path, which, "bin", "llvm-config")
+ config = File.join(@llvm_path, which, "bin", "llvm-config")
@llvm = :config
+ @llvm_configure = llvm_config_cmd config
return true
end
end
@@ -617,10 +620,11 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
def setup_auto
@log.print " Checking for existing LLVM library tree: "
if File.directory?("#{@llvm_default}/Release")
- version = `#{@perl} #{@llvm_default}/Release/bin/llvm-config --version`.strip
+ config = llvm_config_cmd "#{@llvm_default}/Release/bin/llvm-config"
+ version = `#{config} --version`.strip
if version == "3.0"
# See if this has rtti turned off and reject it.
- if `#{@perl} #{@llvm_default}/Release/bin/llvm-config --cxxflags`.index("-fno-rtti")
+ if `#{config} --cxxflags`.index("-fno-rtti")
@log.write "incorrectly configure (rtti is off)"
remove_default
else
@@ -631,6 +635,7 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
@llvm = :prebuilt
end
+ @llvm_configure = config
return
end
else
@@ -672,17 +677,17 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
end
if config
- version = `#{@perl} #{config} --version`.strip
+ version = `#{llvm_config_cmd config} --version`.strip
parts = version.sub(/svn$/, "").split(".").map { |i| i.to_i }
api_version = ("%d%02d" % parts[0..1]).to_i
- if `#{@perl} #{config} --cxxflags`.index("-fno-rtti")
+ if `#{llvm_config_cmd config} --cxxflags`.index("-fno-rtti")
@log.write "incorrectly configured llvm (rtti is off)"
elsif api_version != 300
@log.write "only LLVM 3.0 is supported"
else
@log.write "found! (version #{version} - api: #{api_version})"
- @llvm_configure = config
@llvm = :config
+ @llvm_configure = llvm_config_cmd config
@llvm_api_version = api_version
return true
end
@@ -1137,6 +1142,20 @@ int main() { return tgetnum(""); }
@build_ruby
end
+ # Checks whether the given config file is a Perl script by checking its first
+ # line for a Perl hashbang.
+ def llvm_config_cmd(config)
+ first_line = File.open(config).lines.first
+ if first_line =~ /^#! ?\/usr(\/local)?\/bin\/(env )?perl/
+ "#{@perl} #{config}"
+ else
+ config
+ end
+ rescue Errno::ENOENT, ArgumentError
+ # The file doesn't exist (ENOENT) or it's a binary file (ArgumentError).
+ config
+ end
+
def get_system_name
return unless @os =~ /linux/
return unless File.exists? "/etc/issue"
View
50 rakelib/blueprint.rb
@@ -190,45 +190,39 @@
case Rubinius::BUILD_CONFIG[:llvm]
when :prebuilt, :svn
llvm = i.external_lib "vendor/llvm" do |l|
- conf = "vendor/llvm/Release/bin/llvm-config"
- flags = `#{perl} #{conf} --cflags`.strip.split(/\s+/)
- flags.delete_if { |x| x.index("-O") == 0 || x.index("-I") == 0 }
- flags.delete_if { |x| x =~ /-D__STDC/ }
- flags.delete_if { |x| x == "-DNDEBUG" }
- flags.delete_if { |x| x == "-fomit-frame-pointer" }
-
- flags << "-Ivendor/llvm/include" << "-DENABLE_LLVM"
- l.cflags = flags
-
- ldflags = `#{perl} #{conf} --ldflags`.strip
- objects = `#{perl} #{conf} --libfiles`.strip.split(/\s+/)
-
- if Rubinius::BUILD_CONFIG[:windows]
- ldflags = ldflags.sub(%r[-L/([a-zA-Z])/], '-L\1:/')
-
- objects.select do |f|
- f.sub!(%r[^/([a-zA-Z])/], '\1:/')
- File.file? f
- end
- end
-
- l.ldflags = [ldflags]
- l.objects = objects
+ l.cflags = ["-Ivendor/llvm/include"]
+ l.objects = []
end
gcc.add_library llvm
- files << llvm
- when :config
+ end
+
+ case Rubinius::BUILD_CONFIG[:llvm]
+ when :config, :prebuilt, :svn
conf = Rubinius::BUILD_CONFIG[:llvm_configure]
- flags = `#{perl} #{conf} --cflags`.strip.split(/\s+/)
+ flags = `#{conf} --cflags`.strip.split(/\s+/)
flags.delete_if { |x| x.index("-O") == 0 }
flags.delete_if { |x| x =~ /-D__STDC/ }
flags.delete_if { |x| x == "-DNDEBUG" }
flags.delete_if { |x| x == "-fomit-frame-pointer" }
flags << "-DENABLE_LLVM"
+
+ ldflags = `#{conf} --ldflags`.strip.split(/\s+/)
+ objects = `#{conf} --libfiles`.strip.split(/\s+/)
+
+ if Rubinius::BUILD_CONFIG[:windows]
+ ldflags = ldflags.sub(%r[-L/([a-zA-Z])/], '-L\1:/')
+
+ objects.select do |f|
+ f.sub!(%r[^/([a-zA-Z])/], '\1:/')
+ File.file? f
+ end
+ end
+
gcc.cflags.concat flags
- gcc.ldflags.concat `#{perl} #{conf} --ldflags --libfiles`.strip.split(/\s+/)
+ gcc.ldflags.concat ldflags
+ gcc.ldflags.concat objects
when :no
# nothing, not using LLVM
else
Please sign in to comment.
Something went wrong with that request. Please try again.