authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-07 18:17:31-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-19 16:45:15-07:00
log73bbd1069a993a0e663033ea3b8cd4ed1a123566
tree1e2b148425da2359d720d6d5048ad94151788bb9
parent39f43fea8d0f6aa1c69cb7c3209f57f5ce00b273

build: remove the option to omit stage2


6 files changed, 7 insertions(+), 52 deletions(-)

build.zig+5-9
...@@ -65,7 +65,6 @@ pub fn build(b: *Builder) !void {...@@ -65,7 +65,6 @@ pub fn build(b: *Builder) !void {
65 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;65 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
6666
67 const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false;67 const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false;
68 const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false;
69 const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;68 const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;
70 const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);69 const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);
71 const llvm_has_m68k = b.option(70 const llvm_has_m68k = b.option(
...@@ -361,7 +360,6 @@ pub fn build(b: *Builder) !void {...@@ -361,7 +360,6 @@ pub fn build(b: *Builder) !void {
361 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);360 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
362 exe_options.addOption(bool, "value_tracing", value_tracing);361 exe_options.addOption(bool, "value_tracing", value_tracing);
363 exe_options.addOption(bool, "is_stage1", is_stage1);362 exe_options.addOption(bool, "is_stage1", is_stage1);
364 exe_options.addOption(bool, "omit_stage2", omit_stage2);
365 if (tracy) |tracy_path| {363 if (tracy) |tracy_path| {
366 const client_cpp = fs.path.join(364 const client_cpp = fs.path.join(
367 b.allocator,365 b.allocator,
...@@ -397,7 +395,6 @@ pub fn build(b: *Builder) !void {...@@ -397,7 +395,6 @@ pub fn build(b: *Builder) !void {
397 test_cases_options.addOption(bool, "skip_non_native", skip_non_native);395 test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
398 test_cases_options.addOption(bool, "skip_stage1", skip_stage1);396 test_cases_options.addOption(bool, "skip_stage1", skip_stage1);
399 test_cases_options.addOption(bool, "is_stage1", is_stage1);397 test_cases_options.addOption(bool, "is_stage1", is_stage1);
400 test_cases_options.addOption(bool, "omit_stage2", omit_stage2);
401 test_cases_options.addOption(bool, "have_llvm", enable_llvm);398 test_cases_options.addOption(bool, "have_llvm", enable_llvm);
402 test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);399 test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
403 test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);400 test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
...@@ -457,7 +454,7 @@ pub fn build(b: *Builder) !void {...@@ -457,7 +454,7 @@ pub fn build(b: *Builder) !void {
457 skip_non_native,454 skip_non_native,
458 skip_libc,455 skip_libc,
459 skip_stage1,456 skip_stage1,
460 omit_stage2,457 false,
461 is_stage1,458 is_stage1,
462 ));459 ));
463460
...@@ -472,7 +469,7 @@ pub fn build(b: *Builder) !void {...@@ -472,7 +469,7 @@ pub fn build(b: *Builder) !void {
472 skip_non_native,469 skip_non_native,
473 true, // skip_libc470 true, // skip_libc
474 skip_stage1,471 skip_stage1,
475 omit_stage2 or true, // TODO get these all passing472 true, // TODO get these all passing
476 is_stage1,473 is_stage1,
477 ));474 ));
478475
...@@ -487,7 +484,7 @@ pub fn build(b: *Builder) !void {...@@ -487,7 +484,7 @@ pub fn build(b: *Builder) !void {
487 skip_non_native,484 skip_non_native,
488 true, // skip_libc485 true, // skip_libc
489 skip_stage1,486 skip_stage1,
490 omit_stage2 or true, // TODO get these all passing487 true, // TODO get these all passing
491 is_stage1,488 is_stage1,
492 ));489 ));
493490
...@@ -499,14 +496,13 @@ pub fn build(b: *Builder) !void {...@@ -499,14 +496,13 @@ pub fn build(b: *Builder) !void {
499 skip_non_native,496 skip_non_native,
500 enable_macos_sdk,497 enable_macos_sdk,
501 target,498 target,
502 omit_stage2,
503 b.enable_darling,499 b.enable_darling,
504 b.enable_qemu,500 b.enable_qemu,
505 b.enable_rosetta,501 b.enable_rosetta,
506 b.enable_wasmtime,502 b.enable_wasmtime,
507 b.enable_wine,503 b.enable_wine,
508 ));504 ));
509 toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, omit_stage2));505 toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk));
510 toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));506 toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
511 toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes));507 toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes));
512 toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));508 toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
...@@ -528,7 +524,7 @@ pub fn build(b: *Builder) !void {...@@ -528,7 +524,7 @@ pub fn build(b: *Builder) !void {
528 skip_non_native,524 skip_non_native,
529 skip_libc,525 skip_libc,
530 skip_stage1,526 skip_stage1,
531 omit_stage2 or true, // TODO get these all passing527 true, // TODO get these all passing
532 is_stage1,528 is_stage1,
533 );529 );
534530
ci/azure/build.zig-2
...@@ -38,7 +38,6 @@ pub fn build(b: *Builder) !void {...@@ -38,7 +38,6 @@ pub fn build(b: *Builder) !void {
38 docs_step.dependOn(&docgen_cmd.step);38 docs_step.dependOn(&docgen_cmd.step);
3939
40 const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false;40 const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false;
41 const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false;
42 const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;41 const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;
43 const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);42 const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);
44 const llvm_has_m68k = b.option(43 const llvm_has_m68k = b.option(
...@@ -300,7 +299,6 @@ pub fn build(b: *Builder) !void {...@@ -300,7 +299,6 @@ pub fn build(b: *Builder) !void {
300 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);299 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
301 exe_options.addOption(bool, "value_tracing", value_tracing);300 exe_options.addOption(bool, "value_tracing", value_tracing);
302 exe_options.addOption(bool, "is_stage1", is_stage1);301 exe_options.addOption(bool, "is_stage1", is_stage1);
303 exe_options.addOption(bool, "omit_stage2", omit_stage2);
304 if (tracy) |tracy_path| {302 if (tracy) |tracy_path| {
305 const client_cpp = fs.path.join(303 const client_cpp = fs.path.join(
306 b.allocator,304 b.allocator,
src/Compilation.zig+2-27
...@@ -1044,8 +1044,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1044,8 +1044,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1044 // Even though we may have no Zig code to compile (depending on `options.main_pkg`),1044 // Even though we may have no Zig code to compile (depending on `options.main_pkg`),
1045 // we may need to use stage1 for building compiler-rt and other dependencies.1045 // we may need to use stage1 for building compiler-rt and other dependencies.
10461046
1047 if (build_options.omit_stage2)
1048 break :blk true;
1049 if (options.use_llvm) |use_llvm| {1047 if (options.use_llvm) |use_llvm| {
1050 if (!use_llvm) {1048 if (!use_llvm) {
1051 break :blk false;1049 break :blk false;
...@@ -2213,8 +2211,7 @@ pub fn update(comp: *Compilation) !void {...@@ -2213,8 +2211,7 @@ pub fn update(comp: *Compilation) !void {
2213 comp.c_object_work_queue.writeItemAssumeCapacity(key);2211 comp.c_object_work_queue.writeItemAssumeCapacity(key);
2214 }2212 }
22152213
2216 const use_stage1 = build_options.omit_stage2 or2214 const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
2217 (build_options.is_stage1 and comp.bin_file.options.use_stage1);
2218 if (comp.bin_file.options.module) |module| {2215 if (comp.bin_file.options.module) |module| {
2219 module.compile_log_text.shrinkAndFree(module.gpa, 0);2216 module.compile_log_text.shrinkAndFree(module.gpa, 0);
2220 module.generation += 1;2217 module.generation += 1;
...@@ -2390,8 +2387,7 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -2390,8 +2387,7 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
2390 };2387 };
2391 comp.link_error_flags = comp.bin_file.errorFlags();2388 comp.link_error_flags = comp.bin_file.errorFlags();
23922389
2393 const use_stage1 = build_options.omit_stage2 or2390 const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
2394 (build_options.is_stage1 and comp.bin_file.options.use_stage1);
2395 if (!use_stage1) {2391 if (!use_stage1) {
2396 if (comp.bin_file.options.module) |module| {2392 if (comp.bin_file.options.module) |module| {
2397 try link.File.C.flushEmitH(module);2393 try link.File.C.flushEmitH(module);
...@@ -2952,9 +2948,6 @@ pub fn performAllTheWork(...@@ -2952,9 +2948,6 @@ pub fn performAllTheWork(
2952fn processOneJob(comp: *Compilation, job: Job) !void {2948fn processOneJob(comp: *Compilation, job: Job) !void {
2953 switch (job) {2949 switch (job) {
2954 .codegen_decl => |decl_index| {2950 .codegen_decl => |decl_index| {
2955 if (build_options.omit_stage2)
2956 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
2957
2958 const module = comp.bin_file.options.module.?;2951 const module = comp.bin_file.options.module.?;
2959 const decl = module.declPtr(decl_index);2952 const decl = module.declPtr(decl_index);
29602953
...@@ -2989,9 +2982,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -2989,9 +2982,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
2989 }2982 }
2990 },2983 },
2991 .codegen_func => |func| {2984 .codegen_func => |func| {
2992 if (build_options.omit_stage2)
2993 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
2994
2995 const named_frame = tracy.namedFrame("codegen_func");2985 const named_frame = tracy.namedFrame("codegen_func");
2996 defer named_frame.end();2986 defer named_frame.end();
29972987
...@@ -3002,9 +2992,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3002,9 +2992,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3002 };2992 };
3003 },2993 },
3004 .emit_h_decl => |decl_index| {2994 .emit_h_decl => |decl_index| {
3005 if (build_options.omit_stage2)
3006 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
3007
3008 const module = comp.bin_file.options.module.?;2995 const module = comp.bin_file.options.module.?;
3009 const decl = module.declPtr(decl_index);2996 const decl = module.declPtr(decl_index);
30102997
...@@ -3063,9 +3050,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3063,9 +3050,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3063 }3050 }
3064 },3051 },
3065 .analyze_decl => |decl_index| {3052 .analyze_decl => |decl_index| {
3066 if (build_options.omit_stage2)
3067 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
3068
3069 const module = comp.bin_file.options.module.?;3053 const module = comp.bin_file.options.module.?;
3070 module.ensureDeclAnalyzed(decl_index) catch |err| switch (err) {3054 module.ensureDeclAnalyzed(decl_index) catch |err| switch (err) {
3071 error.OutOfMemory => return error.OutOfMemory,3055 error.OutOfMemory => return error.OutOfMemory,
...@@ -3073,9 +3057,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3073,9 +3057,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3073 };3057 };
3074 },3058 },
3075 .update_embed_file => |embed_file| {3059 .update_embed_file => |embed_file| {
3076 if (build_options.omit_stage2)
3077 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
3078
3079 const named_frame = tracy.namedFrame("update_embed_file");3060 const named_frame = tracy.namedFrame("update_embed_file");
3080 defer named_frame.end();3061 defer named_frame.end();
30813062
...@@ -3086,9 +3067,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3086,9 +3067,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3086 };3067 };
3087 },3068 },
3088 .update_line_number => |decl_index| {3069 .update_line_number => |decl_index| {
3089 if (build_options.omit_stage2)
3090 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
3091
3092 const named_frame = tracy.namedFrame("update_line_number");3070 const named_frame = tracy.namedFrame("update_line_number");
3093 defer named_frame.end();3071 defer named_frame.end();
30943072
...@@ -3107,9 +3085,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3107,9 +3085,6 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3107 };3085 };
3108 },3086 },
3109 .analyze_pkg => |pkg| {3087 .analyze_pkg => |pkg| {
3110 if (build_options.omit_stage2)
3111 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
3112
3113 const named_frame = tracy.namedFrame("analyze_pkg");3088 const named_frame = tracy.namedFrame("analyze_pkg");
3114 defer named_frame.end();3089 defer named_frame.end();
31153090
src/Sema.zig-7
...@@ -27358,9 +27358,6 @@ pub fn resolveTypeLayout(...@@ -27358,9 +27358,6 @@ pub fn resolveTypeLayout(
27358 src: LazySrcLoc,27358 src: LazySrcLoc,
27359 ty: Type,27359 ty: Type,
27360) CompileError!void {27360) CompileError!void {
27361 if (build_options.omit_stage2)
27362 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
27363
27364 switch (ty.zigTypeTag()) {27361 switch (ty.zigTypeTag()) {
27365 .Struct => return sema.resolveStructLayout(block, src, ty),27362 .Struct => return sema.resolveStructLayout(block, src, ty),
27366 .Union => return sema.resolveUnionLayout(block, src, ty),27363 .Union => return sema.resolveUnionLayout(block, src, ty),
...@@ -27699,8 +27696,6 @@ fn resolveUnionFully(...@@ -27699,8 +27696,6 @@ fn resolveUnionFully(
27699}27696}
2770027697
27701pub fn resolveTypeFields(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!Type {27698pub fn resolveTypeFields(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!Type {
27702 if (build_options.omit_stage2)
27703 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
27704 switch (ty.tag()) {27699 switch (ty.tag()) {
27705 .@"struct" => {27700 .@"struct" => {
27706 const struct_obj = ty.castTag(.@"struct").?.data;27701 const struct_obj = ty.castTag(.@"struct").?.data;
...@@ -29323,8 +29318,6 @@ fn typePtrOrOptionalPtrTy(...@@ -29323,8 +29318,6 @@ fn typePtrOrOptionalPtrTy(
29323/// TODO merge these implementations together with the "advanced"/sema_kit pattern seen29318/// TODO merge these implementations together with the "advanced"/sema_kit pattern seen
29324/// elsewhere in value.zig29319/// elsewhere in value.zig
29325pub fn typeRequiresComptime(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool {29320pub fn typeRequiresComptime(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool {
29326 if (build_options.omit_stage2)
29327 @panic("sadly stage2 is omitted from this build to save memory on the CI server");
29328 return switch (ty.tag()) {29321 return switch (ty.tag()) {
29329 .u1,29322 .u1,
29330 .u8,29323 .u8,
src/config.zig.in-1
...@@ -10,4 +10,3 @@ pub const enable_tracy = false;...@@ -10,4 +10,3 @@ pub const enable_tracy = false;
10pub const value_tracing = false;10pub const value_tracing = false;
11pub const is_stage1 = true;11pub const is_stage1 = true;
12pub const skip_non_native = false;12pub const skip_non_native = false;
13pub const omit_stage2: bool = @ZIG_OMIT_STAGE2_BOOL@;
test/tests.zig-6
...@@ -462,7 +462,6 @@ pub fn addStandaloneTests(...@@ -462,7 +462,6 @@ pub fn addStandaloneTests(
462 skip_non_native: bool,462 skip_non_native: bool,
463 enable_macos_sdk: bool,463 enable_macos_sdk: bool,
464 target: std.zig.CrossTarget,464 target: std.zig.CrossTarget,
465 omit_stage2: bool,
466 enable_darling: bool,465 enable_darling: bool,
467 enable_qemu: bool,466 enable_qemu: bool,
468 enable_rosetta: bool,467 enable_rosetta: bool,
...@@ -479,7 +478,6 @@ pub fn addStandaloneTests(...@@ -479,7 +478,6 @@ pub fn addStandaloneTests(
479 .skip_non_native = skip_non_native,478 .skip_non_native = skip_non_native,
480 .enable_macos_sdk = enable_macos_sdk,479 .enable_macos_sdk = enable_macos_sdk,
481 .target = target,480 .target = target,
482 .omit_stage2 = omit_stage2,
483 .enable_darling = enable_darling,481 .enable_darling = enable_darling,
484 .enable_qemu = enable_qemu,482 .enable_qemu = enable_qemu,
485 .enable_rosetta = enable_rosetta,483 .enable_rosetta = enable_rosetta,
...@@ -497,7 +495,6 @@ pub fn addLinkTests(...@@ -497,7 +495,6 @@ pub fn addLinkTests(
497 test_filter: ?[]const u8,495 test_filter: ?[]const u8,
498 modes: []const Mode,496 modes: []const Mode,
499 enable_macos_sdk: bool,497 enable_macos_sdk: bool,
500 omit_stage2: bool,
501) *build.Step {498) *build.Step {
502 const cases = b.allocator.create(StandaloneContext) catch unreachable;499 const cases = b.allocator.create(StandaloneContext) catch unreachable;
503 cases.* = StandaloneContext{500 cases.* = StandaloneContext{
...@@ -509,7 +506,6 @@ pub fn addLinkTests(...@@ -509,7 +506,6 @@ pub fn addLinkTests(
509 .skip_non_native = true,506 .skip_non_native = true,
510 .enable_macos_sdk = enable_macos_sdk,507 .enable_macos_sdk = enable_macos_sdk,
511 .target = .{},508 .target = .{},
512 .omit_stage2 = omit_stage2,
513 };509 };
514 link.addCases(cases);510 link.addCases(cases);
515 return cases.step;511 return cases.step;
...@@ -978,7 +974,6 @@ pub const StandaloneContext = struct {...@@ -978,7 +974,6 @@ pub const StandaloneContext = struct {
978 skip_non_native: bool,974 skip_non_native: bool,
979 enable_macos_sdk: bool,975 enable_macos_sdk: bool,
980 target: std.zig.CrossTarget,976 target: std.zig.CrossTarget,
981 omit_stage2: bool,
982 enable_darling: bool = false,977 enable_darling: bool = false,
983 enable_qemu: bool = false,978 enable_qemu: bool = false,
984 enable_rosetta: bool = false,979 enable_rosetta: bool = false,
...@@ -1003,7 +998,6 @@ pub const StandaloneContext = struct {...@@ -1003,7 +998,6 @@ pub const StandaloneContext = struct {
1003 const b = self.b;998 const b = self.b;
1004999
1005 if (features.requires_macos_sdk and !self.enable_macos_sdk) return;1000 if (features.requires_macos_sdk and !self.enable_macos_sdk) return;
1006 if (features.requires_stage2 and self.omit_stage2) return;
10071001
1008 const annotated_case_name = b.fmt("build {s}", .{build_file});1002 const annotated_case_name = b.fmt("build {s}", .{build_file});
1009 if (self.test_filter) |filter| {1003 if (self.test_filter) |filter| {