From d0dceae736edb43d4c217306a2b0445277f184ce Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 14 Oct 2021 13:50:10 +0200 Subject: macho: dump linker's state as JSON Each element of the output JSON has the VM address of the generated binary nondecreasing (some elements might occupy the same VM address for example the atom and the relocation might coincide in the address space). The generated JSON can be inspected manually or via a preview tool `zig-snapshots` that I am currently working on and will allow the user to inspect interactively the state of the linker together with the positioning of sections, symbols, atoms and relocations within each snapshot state, and in the future, between snapshots too. This should allow for quicker debugging of the linker which is nontrivial when run in the incremental mode. Note that the state will only be dumped if the compiler is built with `-Dlink-snapshot` flag on, and then the compiler is passed `--debug-link-snapshot` flag upon compiling a source/project. --- src/Compilation.zig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 63a6b50d5b..a7a76633ab 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -757,6 +757,8 @@ pub const InitOptions = struct { subsystem: ?std.Target.SubSystem = null, /// WASI-only. Type of WASI execution model ("command" or "reactor"). wasi_exec_model: ?std.builtin.WasiExecModel = null, + /// (Zig compiler development) Enable dumping linker's state as JSON. + enable_link_snapshots: bool = false, }; fn addPackageTableToCacheHash( @@ -1438,6 +1440,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { .is_test = options.is_test, .wasi_exec_model = wasi_exec_model, .use_stage1 = use_stage1, + .enable_link_snapshots = options.enable_link_snapshots, }); errdefer bin_file.destroy(); comp.* = .{ -- cgit v1.2.3