Skip to content

Commit d9ea70b

Browse files
danliew-appledelcypher
authored andcommitted
[Compiler-RT] On Apple Platforms switch to always emitting full debug info
Previously the build used `-gline-tables-only` when `COMPILER_RT_DEBUG` was off (default) and `-g` when `COMPILER_RT_DEBUG` was on. The end result of this meant that the release build of the Sanitizer runtimes were difficult to debug (e.g. information about variables and function arguments were missing). Presumably the reason for preferring `-gline-tables-only` for release builds was to save space. However, for Apple platforms this doesn't matter because debug info lives in separate `.dSYM` files (which aren't shipped) rather than in the shipped `.dylib` files. Now on Apple platforms we always emit full debug info if the compiler supports it and we emit a fatal error if `-g` isn't supported. rdar://79223184 Differential Revision: https://reviews.llvm.org/D107501 (cherry picked from commit fb0a929)
1 parent ff34548 commit d9ea70b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,13 @@ if(MSVC)
413413
string(REGEX REPLACE "(^| )/Z[i7I]($| )" " /Z7 "
414414
"${var_to_update}" "${${var_to_update}}")
415415
endforeach()
416+
elseif(APPLE)
417+
# On Apple platforms use full debug info (i.e. not `-gline-tables-only`)
418+
# for all build types so that the runtime can be debugged.
419+
if(NOT COMPILER_RT_HAS_G_FLAG)
420+
message(FATAL_ERROR "-g is not supported by host compiler")
421+
endif()
422+
list(APPEND SANITIZER_COMMON_CFLAGS -g)
416423
elseif(COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG AND NOT COMPILER_RT_DEBUG)
417424
list(APPEND SANITIZER_COMMON_CFLAGS -gline-tables-only)
418425
elseif(COMPILER_RT_HAS_G_FLAG)

0 commit comments

Comments
 (0)