diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-23 13:02:42 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-23 13:24:55 -0700 |
| commit | 2f9264d8dcedba3a75dcf9d6a31b82447dfc57e8 (patch) | |
| tree | e99e6840d2b53f7bbbc20480eac2ec4bec0afe9e /src | |
| parent | 2e0de0b4e20794c07fad76c657ad2c33f1928562 (diff) | |
| download | zig-2f9264d8dcedba3a75dcf9d6a31b82447dfc57e8.tar.gz zig-2f9264d8dcedba3a75dcf9d6a31b82447dfc57e8.zip | |
stage2: fix -Domit-stage2 regression
This flag is used when building stage1 to omit the stage2 backends from
the compiler to save memory on the CI server. It regressed with the
merging of e8813b296bc55a13b534bd9b2a03e1f6af366915 because Value
functions started calling into Sema functions.
The end goal for this build option is to eliminate it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 6 | ||||
| -rw-r--r-- | src/Sema.zig | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index e8b1ebb145..6487273e1f 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2042,7 +2042,8 @@ pub fn update(comp: *Compilation) !void { comp.c_object_work_queue.writeItemAssumeCapacity(key); } - const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1; + const use_stage1 = build_options.omit_stage2 or + (build_options.is_stage1 and comp.bin_file.options.use_stage1); if (comp.bin_file.options.module) |module| { module.compile_log_text.shrinkAndFree(module.gpa, 0); module.generation += 1; @@ -2198,7 +2199,8 @@ fn flush(comp: *Compilation) !void { try comp.bin_file.flush(comp); // This is needed before reading the error flags. comp.link_error_flags = comp.bin_file.errorFlags(); - const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1; + const use_stage1 = build_options.omit_stage2 or + (build_options.is_stage1 and comp.bin_file.options.use_stage1); if (!use_stage1) { if (comp.bin_file.options.module) |module| { try link.File.C.flushEmitH(module); diff --git a/src/Sema.zig b/src/Sema.zig index ab73c55369..7fdf384904 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -89,6 +89,7 @@ const RangeSet = @import("RangeSet.zig"); const target_util = @import("target.zig"); const Package = @import("Package.zig"); const crash_report = @import("crash_report.zig"); +const build_options = @import("build_options"); pub const InstMap = std.AutoHashMapUnmanaged(Zir.Inst.Index, Air.Inst.Ref); @@ -20808,6 +20809,9 @@ pub fn resolveTypeLayout( src: LazySrcLoc, ty: Type, ) CompileError!void { + if (build_options.omit_stage2) + @panic("sadly stage2 is omitted from this build to save memory on the CI server"); + switch (ty.zigTypeTag()) { .Struct => return sema.resolveStructLayout(block, src, ty), .Union => return sema.resolveUnionLayout(block, src, ty), @@ -20974,6 +20978,8 @@ fn resolveUnionFully( } pub fn resolveTypeFields(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!Type { + if (build_options.omit_stage2) + @panic("sadly stage2 is omitted from this build to save memory on the CI server"); switch (ty.tag()) { .@"struct" => { const struct_obj = ty.castTag(.@"struct").?.data; @@ -22256,6 +22262,8 @@ fn typePtrOrOptionalPtrTy( /// TODO merge these implementations together with the "advanced"/sema_kit pattern seen /// elsewhere in value.zig pub fn typeRequiresComptime(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool { + if (build_options.omit_stage2) + @panic("sadly stage2 is omitted from this build to save memory on the CI server"); return switch (ty.tag()) { .u1, .u8, |
