Execute dsymutil on build on macOS#4969
Execute dsymutil on build on macOS#4969RX14 merged 3 commits intocrystal-lang:masterfrom asterite:feature/dsymutil
Conversation
| # Delete related dwarf generated by dsymutil, if any exists | ||
| {% if flag?(:darwin) %} | ||
| if compiler.generates_dsymutil? | ||
| File.delete("#{output_filename}.dwarf") rescue nil |
There was a problem hiding this comment.
Maybe deleting the file should happen even if --no-dsymutil is used.
So after some compilation in debug mode with default options, the next compilation in release (or debug with --no-dsymutil) won't have a misleading dwarf.
There was a problem hiding this comment.
execute is only invoked when you do crystal foo.cr and a temporary executable is created in the cache directory. So in this case I don't see a problem.
For the case where you do crystal build foo.cr and then crystal build foo.cr --no-debug I wouldn't delete the dwarf file because we don't know if we are the ones who generated it in a previous run. And in any case dwarf files have a UUID that relates them with the executable, so an old dwarf file won't cause problems.
| end | ||
|
|
||
| {% if flag?(:darwin) %} | ||
| opts.on("--no-dsymutil", "Don't invoke dsymutil") do |
There was a problem hiding this comment.
I don't find this description helpful.
Also, why not bunch this together with --no-debug
There was a problem hiding this comment.
Because --no-debug makes it impossible to debug with gdb or lldb. But even if passing --no-dsymutil you can debug with gdb or lldb.
But yes, I think we can just remove this option, I don't mind having this dwarf file generated every time.
| end | ||
|
|
||
| private def run_dsymutil(filename) | ||
| `which dsymutil` |
There was a problem hiding this comment.
You may:
return unless Process.find_executable("dsymutil")There was a problem hiding this comment.
Wow! What a great standard library :-)
|
I changed it so |
|
LGTM? |
Fixes #4186
I think better output on exceptions is worth it when the cost is just having a
.dwarffile sitting next to the executable (and in some cases you don't get to see that file if you runcrystal run file.cror justcrystal file.cr).Adds an option, only on Mac, to disable running
dsymutil.I ran
dsymutilon the compiler's executable and it takes about 1 second. I think it's acceptable, given that the compiler is relatively big, so for other projects it will be much less time. And there's always the option to disable this feature.