Skip to content

Commit

Permalink
build: remove the option to omit stage2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk authored and kristoff-it committed Aug 23, 2022
1 parent 5fe150c commit 8c3984e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 52 deletions.
14 changes: 5 additions & 9 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ pub fn build(b: *Builder) !void {
const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;

const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false;
const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false;
const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;
const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);
const llvm_has_m68k = b.option(
Expand Down Expand Up @@ -361,7 +360,6 @@ pub fn build(b: *Builder) !void {
exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
exe_options.addOption(bool, "value_tracing", value_tracing);
exe_options.addOption(bool, "is_stage1", is_stage1);
exe_options.addOption(bool, "omit_stage2", omit_stage2);
if (tracy) |tracy_path| {
const client_cpp = fs.path.join(
b.allocator,
Expand Down Expand Up @@ -397,7 +395,6 @@ pub fn build(b: *Builder) !void {
test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
test_cases_options.addOption(bool, "skip_stage1", skip_stage1);
test_cases_options.addOption(bool, "is_stage1", is_stage1);
test_cases_options.addOption(bool, "omit_stage2", omit_stage2);
test_cases_options.addOption(bool, "have_llvm", enable_llvm);
test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
Expand Down Expand Up @@ -457,7 +454,7 @@ pub fn build(b: *Builder) !void {
skip_non_native,
skip_libc,
skip_stage1,
omit_stage2,
false,
is_stage1,
));

Expand All @@ -472,7 +469,7 @@ pub fn build(b: *Builder) !void {
skip_non_native,
true, // skip_libc
skip_stage1,
omit_stage2 or true, // TODO get these all passing
true, // TODO get these all passing
is_stage1,
));

Expand All @@ -487,7 +484,7 @@ pub fn build(b: *Builder) !void {
skip_non_native,
true, // skip_libc
skip_stage1,
omit_stage2 or true, // TODO get these all passing
true, // TODO get these all passing
is_stage1,
));

Expand All @@ -499,14 +496,13 @@ pub fn build(b: *Builder) !void {
skip_non_native,
enable_macos_sdk,
target,
omit_stage2,
b.enable_darling,
b.enable_qemu,
b.enable_rosetta,
b.enable_wasmtime,
b.enable_wine,
));
toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, omit_stage2));
toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk));
toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes));
toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
Expand All @@ -528,7 +524,7 @@ pub fn build(b: *Builder) !void {
skip_non_native,
skip_libc,
skip_stage1,
omit_stage2 or true, // TODO get these all passing
true, // TODO get these all passing
is_stage1,
);

Expand Down
2 changes: 0 additions & 2 deletions ci/azure/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub fn build(b: *Builder) !void {
docs_step.dependOn(&docgen_cmd.step);

const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false;
const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false;
const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;
const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);
const llvm_has_m68k = b.option(
Expand Down Expand Up @@ -300,7 +299,6 @@ pub fn build(b: *Builder) !void {
exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
exe_options.addOption(bool, "value_tracing", value_tracing);
exe_options.addOption(bool, "is_stage1", is_stage1);
exe_options.addOption(bool, "omit_stage2", omit_stage2);
if (tracy) |tracy_path| {
const client_cpp = fs.path.join(
b.allocator,
Expand Down
29 changes: 2 additions & 27 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
// Even though we may have no Zig code to compile (depending on `options.main_pkg`),
// we may need to use stage1 for building compiler-rt and other dependencies.

if (build_options.omit_stage2)
break :blk true;
if (options.use_llvm) |use_llvm| {
if (!use_llvm) {
break :blk false;
Expand Down Expand Up @@ -2213,8 +2211,7 @@ pub fn update(comp: *Compilation) !void {
comp.c_object_work_queue.writeItemAssumeCapacity(key);
}

const use_stage1 = build_options.omit_stage2 or
(build_options.is_stage1 and comp.bin_file.options.use_stage1);
const use_stage1 = 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;
Expand Down Expand Up @@ -2390,8 +2387,7 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
};
comp.link_error_flags = comp.bin_file.errorFlags();

const use_stage1 = build_options.omit_stage2 or
(build_options.is_stage1 and comp.bin_file.options.use_stage1);
const use_stage1 = 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);
Expand Down Expand Up @@ -2952,9 +2948,6 @@ pub fn performAllTheWork(
fn processOneJob(comp: *Compilation, job: Job) !void {
switch (job) {
.codegen_decl => |decl_index| {
if (build_options.omit_stage2)
@panic("sadly stage2 is omitted from this build to save memory on the CI server");

const module = comp.bin_file.options.module.?;
const decl = module.declPtr(decl_index);

Expand Down Expand Up @@ -2989,9 +2982,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
}
},
.codegen_func => |func| {
if (build_options.omit_stage2)
@panic("sadly stage2 is omitted from this build to save memory on the CI server");

const named_frame = tracy.namedFrame("codegen_func");
defer named_frame.end();

Expand All @@ -3002,9 +2992,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
};
},
.emit_h_decl => |decl_index| {
if (build_options.omit_stage2)
@panic("sadly stage2 is omitted from this build to save memory on the CI server");

const module = comp.bin_file.options.module.?;
const decl = module.declPtr(decl_index);

Expand Down Expand Up @@ -3063,19 +3050,13 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
}
},
.analyze_decl => |decl_index| {
if (build_options.omit_stage2)
@panic("sadly stage2 is omitted from this build to save memory on the CI server");

const module = comp.bin_file.options.module.?;
module.ensureDeclAnalyzed(decl_index) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => return,
};
},
.update_embed_file => |embed_file| {
if (build_options.omit_stage2)
@panic("sadly stage2 is omitted from this build to save memory on the CI server");

const named_frame = tracy.namedFrame("update_embed_file");
defer named_frame.end();

Expand All @@ -3086,9 +3067,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
};
},
.update_line_number => |decl_index| {
if (build_options.omit_stage2)
@panic("sadly stage2 is omitted from this build to save memory on the CI server");

const named_frame = tracy.namedFrame("update_line_number");
defer named_frame.end();

Expand All @@ -3107,9 +3085,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
};
},
.analyze_pkg => |pkg| {
if (build_options.omit_stage2)
@panic("sadly stage2 is omitted from this build to save memory on the CI server");

const named_frame = tracy.namedFrame("analyze_pkg");
defer named_frame.end();

Expand Down
7 changes: 0 additions & 7 deletions src/Sema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27358,9 +27358,6 @@ 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),
Expand Down Expand Up @@ -27699,8 +27696,6 @@ 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;
Expand Down Expand Up @@ -29323,8 +29318,6 @@ 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,
Expand Down
1 change: 0 additions & 1 deletion src/config.zig.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ pub const enable_tracy = false;
pub const value_tracing = false;
pub const is_stage1 = true;
pub const skip_non_native = false;
pub const omit_stage2: bool = @ZIG_OMIT_STAGE2_BOOL@;
6 changes: 0 additions & 6 deletions test/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ pub fn addStandaloneTests(
skip_non_native: bool,
enable_macos_sdk: bool,
target: std.zig.CrossTarget,
omit_stage2: bool,
enable_darling: bool,
enable_qemu: bool,
enable_rosetta: bool,
Expand All @@ -479,7 +478,6 @@ pub fn addStandaloneTests(
.skip_non_native = skip_non_native,
.enable_macos_sdk = enable_macos_sdk,
.target = target,
.omit_stage2 = omit_stage2,
.enable_darling = enable_darling,
.enable_qemu = enable_qemu,
.enable_rosetta = enable_rosetta,
Expand All @@ -497,7 +495,6 @@ pub fn addLinkTests(
test_filter: ?[]const u8,
modes: []const Mode,
enable_macos_sdk: bool,
omit_stage2: bool,
) *build.Step {
const cases = b.allocator.create(StandaloneContext) catch unreachable;
cases.* = StandaloneContext{
Expand All @@ -509,7 +506,6 @@ pub fn addLinkTests(
.skip_non_native = true,
.enable_macos_sdk = enable_macos_sdk,
.target = .{},
.omit_stage2 = omit_stage2,
};
link.addCases(cases);
return cases.step;
Expand Down Expand Up @@ -978,7 +974,6 @@ pub const StandaloneContext = struct {
skip_non_native: bool,
enable_macos_sdk: bool,
target: std.zig.CrossTarget,
omit_stage2: bool,
enable_darling: bool = false,
enable_qemu: bool = false,
enable_rosetta: bool = false,
Expand All @@ -1003,7 +998,6 @@ pub const StandaloneContext = struct {
const b = self.b;

if (features.requires_macos_sdk and !self.enable_macos_sdk) return;
if (features.requires_stage2 and self.omit_stage2) return;

const annotated_case_name = b.fmt("build {s}", .{build_file});
if (self.test_filter) |filter| {
Expand Down

0 comments on commit 8c3984e

Please sign in to comment.