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: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 37f15dbe96be
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b353cc7945fa
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Jun 11, 2016

  1. Copy the full SHA
    29e1973 View commit details
  2. Copy the full SHA
    441d165 View commit details

Commits on Jun 12, 2016

  1. Merge pull request #2807 from jhass/remove_cross_compile_flags

    Remove --cross-compile flags
    jhass authored Jun 12, 2016
    Copy the full SHA
    b353cc7 View commit details
Showing with 13 additions and 10 deletions.
  1. +2 −2 src/compiler/crystal/command.cr
  2. +10 −7 src/compiler/crystal/compiler.cr
  3. +1 −1 src/llvm/target.cr
4 changes: 2 additions & 2 deletions src/compiler/crystal/command.cr
Original file line number Diff line number Diff line change
@@ -485,8 +485,8 @@ class Crystal::Command

unless no_codegen
unless run
opts.on("--cross-compile flags", "cross-compile") do |cross_compile|
compiler.cross_compile_flags = cross_compile
opts.on("--cross-compile", "cross-compile") do |cross_compile|
compiler.cross_compile = true
end
end
opts.on("-d", "--debug", "Add symbolic debug info") do
17 changes: 10 additions & 7 deletions src/compiler/crystal/compiler.cr
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ module Crystal
node : ASTNode,
original_node : ASTNode

property cross_compile_flags : String?
property cross_compile : Bool
property flags : Array(String)
property? debug : Bool
property? dump_ll : Bool
@@ -45,6 +45,7 @@ module Crystal
@module_pass_manager : LLVM::ModulePassManager?

def initialize
@cross_compile = false
@debug = false
@dump_ll = false
@color = true
@@ -87,9 +88,6 @@ module Crystal
program = Program.new
program.cache_dir = CacheDir.instance.directory_for(sources)
program.target_machine = target_machine
if cross_compile_flags = @cross_compile_flags
program.flags = cross_compile_flags
end
program.flags << "release" if @release
program.flags.merge @flags
program.wants_doc = wants_doc?
@@ -159,12 +157,12 @@ module Crystal
lib_flags = program.lib_flags

llvm_modules = timing("Codegen (crystal)") do
program.codegen node, debug: @debug, single_module: @single_module || @release || @cross_compile_flags || @emit, expose_crystal_main: false
program.codegen node, debug: @debug, single_module: @single_module || @release || @cross_compile || @emit, expose_crystal_main: false
end

cache_dir = CacheDir.instance

if @cross_compile_flags
if @cross_compile
output_dir = "."
else
output_dir = cache_dir.directory_for(sources)
@@ -176,7 +174,7 @@ module Crystal
CompilationUnit.new(self, type_name, llvm_mod, output_dir, bc_flags_changed)
end

if @cross_compile_flags
if @cross_compile
cross_compile program, units, lib_flags, output_filename
else
codegen program, units, lib_flags, output_filename, output_dir
@@ -294,6 +292,11 @@ module Crystal
triple = @target_triple || LLVM.default_target_triple
TargetMachine.create(triple, @mcpu || "", @release)
end
rescue ex : ArgumentError
print colorize("Error: ").red.bold
print "llc: "
puts "#{ex.message}"
exit 1
end

def optimize(llvm_mod)
2 changes: 1 addition & 1 deletion src/llvm/target.cr
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ struct LLVM::Target

def self.from_triple(triple) : self
return_code = LibLLVM.get_target_from_triple triple, out target, out error
raise LLVM.string_and_dispose(error) unless return_code == 0
raise ArgumentError.new(LLVM.string_and_dispose(error)) unless return_code == 0
new target
end