-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execute dsymutil on build on macOS #4969
Conversation
src/compiler/crystal/command.cr
Outdated
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙆♂️
src/compiler/crystal/command.cr
Outdated
@@ -298,6 +308,12 @@ class Crystal::Command | |||
opts.on("--no-debug", "Skip any symbolic debug info") do | |||
compiler.debug = Crystal::Debug::None | |||
end | |||
|
|||
{% if flag?(:darwin) %} | |||
opts.on("--no-dsymutil", "Don't invoke dsymutil") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't find this description helpful.
Also, why not bunch this together with --no-debug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/compiler/crystal/compiler.cr
Outdated
end | ||
|
||
CacheDir.instance.cleanup if @cleanup | ||
|
||
result | ||
end | ||
|
||
private def run_dsymutil(filename) | ||
`which dsymutil` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may:
return unless Process.find_executable("dsymutil")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.dwarf
file sitting next to the executable (and in some cases you don't get to see that file if you runcrystal run file.cr
or justcrystal file.cr
).Adds an option, only on Mac, to disable running
dsymutil
.I ran
dsymutil
on 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.