diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-05-14 13:09:40 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2021-05-14 13:09:40 +0200 |
| commit | af9c6f2c696201e16d95f79a7275aae19b34cd59 (patch) | |
| tree | ebc0836bd9d1c185249b48e23ed581c38f93ffa5 | |
| parent | 00ebbe6df2249ba8201c0e5472d95022bf73e782 (diff) | |
| download | zig-af9c6f2c696201e16d95f79a7275aae19b34cd59.tar.gz zig-af9c6f2c696201e16d95f79a7275aae19b34cd59.zip | |
macho: put dSYM bundle in zig-cache
Originally, I thought that the dSYM bundle has to reside side-by-side
with the binary it carries the debugging information for. However, it
turns out macOS is clever enough that it auto-searches for matching
dSYM bundle based on the embedded UUID of the binary.
To verify this, run this on your macOS:
```
mdfind "com_apple_xcode_dsym_uuids == <UUID from LC_UUID>"
```
See [here] for more info.
[here]: https://developer.apple.com/documentation/xcode/adding-identifiable-symbol-names-to-a-crash-report
| -rw-r--r-- | src/link/MachO.zig | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 5a0deb67bc..0a4eb6da87 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -363,18 +363,30 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio self.base.file = file; // Create dSYM bundle. - const d_sym_path = try fmt.allocPrint(allocator, "{s}.dSYM/Contents/Resources/DWARF/", .{sub_path}); - defer allocator.free(d_sym_path); - var d_sym_bundle = try options.emit.?.directory.handle.makeOpenPath(d_sym_path, .{}); - defer d_sym_bundle.close(); - const d_sym_file = try d_sym_bundle.createFile(sub_path, .{ - .truncate = false, - .read = true, - }); - self.d_sym = .{ - .base = self, - .file = d_sym_file, - }; + if (options.module) |mod| { + const dir = mod.zig_cache_artifact_directory; + log.debug("creating {s}.dSYM bundle in {s}", .{ sub_path, dir.path }); + + const d_sym_path = try fmt.allocPrint( + allocator, + "{s}.dSYM" ++ fs.path.sep_str ++ "Contents" ++ fs.path.sep_str ++ "Resources" ++ fs.path.sep_str ++ "DWARF", + .{sub_path}, + ); + defer allocator.free(d_sym_path); + + var d_sym_bundle = try dir.handle.makeOpenPath(d_sym_path, .{}); + defer d_sym_bundle.close(); + + const d_sym_file = try d_sym_bundle.createFile(sub_path, .{ + .truncate = false, + .read = true, + }); + + self.d_sym = .{ + .base = self, + .file = d_sym_file, + }; + } // Index 0 is always a null symbol. try self.locals.append(allocator, .{ @@ -387,7 +399,7 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio switch (options.output_mode) { .Exe => {}, - .Obj => {}, + .Obj => return error.TODOImplementWritingObjFiles, .Lib => return error.TODOImplementWritingLibFiles, } |
