[strip -ST] Disable runtime stack trace dumping on Darwin when assert… #9311
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation: This PR changes the dladdr based backtraces to only be emitted when the standard library is compiled with assertions enabled. This restores the dladdr backtraces to their original purpose, namely as a tool meant for compiler authors. It additionally has a build system unit test to ensure that no parts of the runtime refer to dladdr. The reason we are doing this is so that we can safely strip -ST the swift standard library.
Scope: Without this, a stdlib that has strip -ST performed upon it will print out incorrect backtraces.
Radar: rdar://31372220
Risk: Minimal. This code only gets triggered upon a program already crashing. So only programs that are already crashing can be affected by a bug in this change. That being said, I think the testing here is relatively comprehensive, so I feel very confidant in this change.
Testing: I added compiler tests that verify that we produce correctly formed stack traces when the relevant settings are enabled and that we do not emit any stack traces when they are disabled. I tested with/without stdlib assertions locally and tested with assertions on the bots. The normal bots will double check the no-assertions case as well. I also added a build system unit test that ensures that no object files reference dladdr.