Skip to content
Permalink
Browse files
Execute dsymutil on build on macOS (#4969)
* Execute dsymutil on build on macOS

* Use `Process.find_executable` instead of `which`

* Let `--no-debug` imply not running dsymutil
  • Loading branch information
asterite authored and RX14 committed Sep 14, 2017
1 parent 464268b commit 429bda355d59ac50b2693b9e38c1bdad88ab2ca7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
@@ -192,7 +192,10 @@ class Crystal::Command
output_filename = Crystal.tempfile(config.output_filename)

result = config.compile output_filename
execute output_filename, config.arguments unless config.compiler.no_codegen?

unless config.compiler.no_codegen?
execute output_filename, config.arguments, config.compiler
end
end

private def types
@@ -211,7 +214,7 @@ class Crystal::Command
{config, result}
end

private def execute(output_filename, run_args)
private def execute(output_filename, run_args, compiler)
time? = @time && !@progress_tracker.stats?
status, elapsed_time = @progress_tracker.stage("Execute") do
begin
@@ -224,6 +227,13 @@ class Crystal::Command
{$?, Time.now - start_time}
ensure
File.delete(output_filename) rescue nil

# Delete related dwarf generated by dsymutil, if any exists
{% if flag?(:darwin) %}
unless compiler.debug.none?
File.delete("#{output_filename}.dwarf") rescue nil
end
{% end %}
end
end

@@ -27,6 +27,6 @@ class Crystal::Command
output_filename = Crystal.tempfile "eval"

result = compiler.compile sources, output_filename
execute output_filename, program_args
execute output_filename, program_args, compiler
end
end
@@ -68,6 +68,6 @@ class Crystal::Command
output_filename = Crystal.tempfile "spec"

result = compiler.compile sources, output_filename
execute output_filename, options
execute output_filename, options, compiler
end
end
@@ -254,13 +254,26 @@ module Crystal
cross_compile program, units, output_filename
else
result = codegen program, units, output_filename, output_dir

{% if flag?(:darwin) %}
run_dsymutil(output_filename) unless debug.none?
{% end %}
end

CacheDir.instance.cleanup if @cleanup

result
end

private def run_dsymutil(filename)
dsymutil = Process.find_executable("dsymutil")
return unless dsymutil

@progress_tracker.stage("dsymutil") do
Process.run(dsymutil, ["--flat", filename])
end
end

private def cross_compile(program, units, output_filename)
llvm_mod = units.first.llvm_mod
object_name = "#{output_filename}.o"

0 comments on commit 429bda3

Please sign in to comment.