diff --git a/src/Compilation.zig b/src/Compilation.zig index d62856b0111be20def4ebf322ee0f58831995161..df6fc7b06b192553ca5faed923c4a9b4406814f5 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2134,6 +2134,9 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, comp.config.any_fuzz = any_fuzz; if (opt_zcu) |zcu| { + // Finish initializing the `zcu` after the fields on `comp` have been initialized. + zcu.initAfterCompilation(); + // Populate `zcu.module_roots`. const active = zcu.acquire(); defer active.release(); diff --git a/src/Zcu.zig b/src/Zcu.zig index d3c180b63eb8854ec8598cdb3099bba7a41fb2b3..d71d8ecf80ef074a1800c9d637744a023523fede 100644 --- a/src/Zcu.zig +++ b/src/Zcu.zig @@ -2825,6 +2825,11 @@ pub const CompileError = error{ pub fn init(zcu: *Zcu, gpa: Allocator, io: Io, thread_count: usize) !void { try zcu.intern_pool.init(gpa, io, thread_count); +} + +/// It is valid to not call this function before `deinit` in error paths. +/// Requires the fields on `zcu.comp` to already be initialized. +pub fn initAfterCompilation(zcu: *Zcu) void { zcu.initTracyPlots(); }