Skip to content

Commit 2f9264d

Browse files
committed
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 e8813b2 because Value functions started calling into Sema functions. The end goal for this build option is to eliminate it.
1 parent 2e0de0b commit 2f9264d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Compilation.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,8 @@ pub fn update(comp: *Compilation) !void {
20422042
comp.c_object_work_queue.writeItemAssumeCapacity(key);
20432043
}
20442044

2045-
const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
2045+
const use_stage1 = build_options.omit_stage2 or
2046+
(build_options.is_stage1 and comp.bin_file.options.use_stage1);
20462047
if (comp.bin_file.options.module) |module| {
20472048
module.compile_log_text.shrinkAndFree(module.gpa, 0);
20482049
module.generation += 1;
@@ -2198,7 +2199,8 @@ fn flush(comp: *Compilation) !void {
21982199
try comp.bin_file.flush(comp); // This is needed before reading the error flags.
21992200
comp.link_error_flags = comp.bin_file.errorFlags();
22002201

2201-
const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
2202+
const use_stage1 = build_options.omit_stage2 or
2203+
(build_options.is_stage1 and comp.bin_file.options.use_stage1);
22022204
if (!use_stage1) {
22032205
if (comp.bin_file.options.module) |module| {
22042206
try link.File.C.flushEmitH(module);

src/Sema.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ const RangeSet = @import("RangeSet.zig");
8989
const target_util = @import("target.zig");
9090
const Package = @import("Package.zig");
9191
const crash_report = @import("crash_report.zig");
92+
const build_options = @import("build_options");
9293

9394
pub const InstMap = std.AutoHashMapUnmanaged(Zir.Inst.Index, Air.Inst.Ref);
9495

@@ -20808,6 +20809,9 @@ pub fn resolveTypeLayout(
2080820809
src: LazySrcLoc,
2080920810
ty: Type,
2081020811
) CompileError!void {
20812+
if (build_options.omit_stage2)
20813+
@panic("sadly stage2 is omitted from this build to save memory on the CI server");
20814+
2081120815
switch (ty.zigTypeTag()) {
2081220816
.Struct => return sema.resolveStructLayout(block, src, ty),
2081320817
.Union => return sema.resolveUnionLayout(block, src, ty),
@@ -20974,6 +20978,8 @@ fn resolveUnionFully(
2097420978
}
2097520979

2097620980
pub fn resolveTypeFields(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!Type {
20981+
if (build_options.omit_stage2)
20982+
@panic("sadly stage2 is omitted from this build to save memory on the CI server");
2097720983
switch (ty.tag()) {
2097820984
.@"struct" => {
2097920985
const struct_obj = ty.castTag(.@"struct").?.data;
@@ -22256,6 +22262,8 @@ fn typePtrOrOptionalPtrTy(
2225622262
/// TODO merge these implementations together with the "advanced"/sema_kit pattern seen
2225722263
/// elsewhere in value.zig
2225822264
pub fn typeRequiresComptime(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool {
22265+
if (build_options.omit_stage2)
22266+
@panic("sadly stage2 is omitted from this build to save memory on the CI server");
2225922267
return switch (ty.tag()) {
2226022268
.u1,
2226122269
.u8,

0 commit comments

Comments
 (0)