Skip to content

Commit

Permalink
Add build option to build Mac .dSYM debug symbol bundles (dotnet#100617)
Browse files Browse the repository at this point in the history
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
dotnet#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"
```
  • Loading branch information
BruceForstall authored and matouskozak committed Apr 30, 2024
1 parent 281c200 commit 84cbf38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/workflow/building/coreclr/macos-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ It is possible to get a macOS ARM64 build using an Intel x64 Mac and vice versa,

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).

## Debugging information

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:

```bash
./build.sh --subset clr --cmakeargs "-DCLR_CMAKE_APPLE_DSYM=TRUE"
```

(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.)

## Native Sanitizers

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:
Expand Down
10 changes: 8 additions & 2 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ endfunction()
function (get_symbol_file_name targetName outputSymbolFilename)
if (CLR_CMAKE_HOST_UNIX)
if (CLR_CMAKE_TARGET_APPLE)
set(strip_destination_file $<TARGET_FILE:${targetName}>.dwarf)
if (CLR_CMAKE_APPLE_DSYM)
set(strip_destination_file $<TARGET_FILE:${targetName}>.dSYM)
else ()
set(strip_destination_file $<TARGET_FILE:${targetName}>.dwarf)
endif ()
else ()
set(strip_destination_file $<TARGET_FILE:${targetName}>.dbg)
endif ()
Expand Down Expand Up @@ -425,7 +429,9 @@ function(strip_symbols targetName outputFilename)
OUTPUT_VARIABLE DSYMUTIL_HELP_OUTPUT
)

set(DSYMUTIL_OPTS "--flat")
if (NOT CLR_CMAKE_APPLE_DSYM)
set(DSYMUTIL_OPTS "--flat")
endif ()
if ("${DSYMUTIL_HELP_OUTPUT}" MATCHES "--minimize")
list(APPEND DSYMUTIL_OPTS "--minimize")
endif ()
Expand Down

0 comments on commit 84cbf38

Please sign in to comment.