zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit af40e3f54c12857bb5ac541f8a3e1a9b5f93a626 (tree)
parent 150515f44db9cecbda31d579861dc6f6080c2f75
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Tue, 22 Jun 2021 16:14:03 -0700

stage2: glue code to AstGen root source file when using stage1

Normally we rely on importing std to in turn import the root
in the start code, but when using the stage1 won't happen,
so in order to run AstGen on the root we put it into the
import_table here.

Diffstat:
Msrc/Compilation.zig | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/Compilation.zig b/src/Compilation.zig @@ -1639,6 +1639,14 @@ pub fn update(self: *Compilation) !void { const std_pkg = module.root_pkg.table.get("std").?; _ = try module.importPkg(std_pkg); + // Normally we rely on importing std to in turn import the root source file + // in the start code, but when using the stage1 backend that won't happen, + // so in order to run AstGen on the root source file we put it into the + // import_table here. + if (use_stage1) { + _ = try module.importPkg(module.root_pkg); + } + // Put a work item in for every known source file to detect if // it changed, and, if so, re-compute ZIR and then queue the job // to update it.