commit 2f9264d8dcedba3a75dcf9d6a31b82447dfc57e8 (tree)
parent 2e0de0b4e20794c07fad76c657ad2c33f1928562
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 23 Mar 2022 13:02:42 -0700
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:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git 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
@@ -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,