Skip to content
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

macOS: Need to run dsymutil for debug builds #4006

Open
JohanEngelen opened this issue Jun 26, 2022 · 2 comments
Open

macOS: Need to run dsymutil for debug builds #4006

JohanEngelen opened this issue Jun 26, 2022 · 2 comments

Comments

@JohanEngelen
Copy link
Member

When creating an executable with debug information (-g), we need to run dsymutil afterwards to create the correct debuginformation on macOS.

Not running dsymutil resulted in a strange bug, which could have been very confusing for larger source files.
It happened while working on the LSan testcase.

  1. The source did not contain //CHECK: lines yet. Compiled with -g and ran test. LSan detects memory leak, and reports it is on line 14.
  2. I added //CHECK: lines, effectively changing the line of malloc (i.e. the line on which the leaked memory was allocated).
  3. Reran the testcase. LSan still reported the old line!
  4. Running dsymutil on the executable --> now LSan reports the correct line of malloc.

AFAICT, other compilers all run dsymutil after linking for -g invocations of the compiler (e.g. clang, nim, rustc).
Note it is nice to include an option to turn default running dsymutil off (see: rust-lang/rust#79361).

Reference: https://stackoverflow.com/a/32299029

@kinke
Copy link
Member

kinke commented Jul 30, 2022

We invoke clang for linking, so I assume forwarding the -g would be enough? And I guess some -Xcc option could be used to prevent clang from running that extra tool, without introducing any extra Mac-specific cmdline options.

@JohanEngelen
Copy link
Member Author

We invoke clang for linking, so I assume forwarding the -g would be enough?

Very good point, I'll try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants