Skip to content

Commit 3515c7a

Browse files
Add build option to build Mac .dSYM debug symbol bundles (#100617)
This is a small workaround to allow developers working on Mac the ability to generate .dSYM bundles as part of inner-loop development, instead of the unsupported .dwarf files that are generated by default. A full solution to use .dSYM bundles everywhere on Mac, including packaging and symbol indexing, is tracked by #92911. To build .dSYM bundles instead of .dwarf files, invoke build.sh as follows: ```bash ./build.sh --subset clr --cmakeargs "-DCLR_CMAKE_APPLE_DSYM=TRUE" ```
1 parent 1f698e7 commit 3515c7a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

docs/workflow/building/coreclr/macos-instructions.md

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ It is possible to get a macOS ARM64 build using an Intel x64 Mac and vice versa,
3333

3434
The Core_Root provides one of the main ways to test your build. Full instructions on how to build it in the [CoreCLR testing doc](/docs/workflow/testing/coreclr/testing.md), and we also have a detailed guide on how to use it for your own testing in [its own dedicated doc](/docs/workflow/testing/using-corerun-and-coreroot.md).
3535

36+
## Debugging information
37+
38+
The build process puts native component symbol and debugging information into `.dwarf` files, one for each built binary. This is not the native format used by macOS, and debuggers like LLDB can't automatically find them. The native format used by macOS is `.dSYM` bundles. To build `.dSYM` bundles and get a better inner-loop developer experience on macOS (e.g., have the LLDB debugger automatically find program symbols and display source code lines, etc.), build as follows:
39+
40+
```bash
41+
./build.sh --subset clr --cmakeargs "-DCLR_CMAKE_APPLE_DSYM=TRUE"
42+
```
43+
44+
(Note: converting the entire build process to build and package `.dSYM` bundles on macOS by default is tracked by [this](https://github.com/dotnet/runtime/issues/92911) issue.)
45+
3646
## Native Sanitizers
3747

3848
CoreCLR can be built with native sanitizers like AddressSanitizer to help catch memory safety issues. To build the project with native sanitizers, add the `-fsanitize address` argument to the build script like the following:

eng/native/functions.cmake

+8-2
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,11 @@ endfunction()
378378
function (get_symbol_file_name targetName outputSymbolFilename)
379379
if (CLR_CMAKE_HOST_UNIX)
380380
if (CLR_CMAKE_TARGET_APPLE)
381-
set(strip_destination_file $<TARGET_FILE:${targetName}>.dwarf)
381+
if (CLR_CMAKE_APPLE_DSYM)
382+
set(strip_destination_file $<TARGET_FILE:${targetName}>.dSYM)
383+
else ()
384+
set(strip_destination_file $<TARGET_FILE:${targetName}>.dwarf)
385+
endif ()
382386
else ()
383387
set(strip_destination_file $<TARGET_FILE:${targetName}>.dbg)
384388
endif ()
@@ -425,7 +429,9 @@ function(strip_symbols targetName outputFilename)
425429
OUTPUT_VARIABLE DSYMUTIL_HELP_OUTPUT
426430
)
427431

428-
set(DSYMUTIL_OPTS "--flat")
432+
if (NOT CLR_CMAKE_APPLE_DSYM)
433+
set(DSYMUTIL_OPTS "--flat")
434+
endif ()
429435
if ("${DSYMUTIL_HELP_OUTPUT}" MATCHES "--minimize")
430436
list(APPEND DSYMUTIL_OPTS "--minimize")
431437
endif ()

0 commit comments

Comments
 (0)