Enable -g1 in CMake release build to produce source and line number in stack trace #64705
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.
Summary
Build "Enable -g1 in CMake release build to produce source and line number in stack trace"
Purpose of change
So that crash logs generated by self-compiled versions of the game using CMake contain more accurate debug information. It slightly increases the target binary size but it's still way smaller than the size of the actual build directory so I think it's fine to enable it by default.
Describe the solution
Add "-g1" to the default c++ flags. Chang "-g" to "-g2" in the debug c++ flags to restore the default behavior.
Describe alternatives you've considered
Add this as a suggestion to the compile docs for people to not read.
Testing
Tested locally with the debug menu's test crash option and the game generated a crash log with source and line number information:
Example crash log
Additional context
I haven't tested with other compilers but Clang seems to provide the "-g1" and "-g2" options according to its docs.
I didn't test the debug build but according to CMake docs,
CMAKE_CXX_FLAGS_DEBUG
is added afterCATA_OTHER_FLAGS
and according to gcc docs,"-g<level>"
that comes last in the command line options takes effect, so I think debug build is unaffected.