Skip to content

Commit e5e6eb9

Browse files
authored
Merge pull request #12368 from ziglang/stage3-default
make self-hosted the default compiler
2 parents 39f43fe + b75eeae commit e5e6eb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+484
-1507
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE)
1212
endif()
1313

1414
if(NOT CMAKE_INSTALL_PREFIX)
15-
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage1" CACHE STRING
15+
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage2" CACHE STRING
1616
"Directory to install zig to" FORCE)
1717
endif()
1818

build.zig

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const stack_size = 32 * 1024 * 1024;
1515

1616
pub fn build(b: *Builder) !void {
1717
b.setPreferredReleaseMode(.ReleaseFast);
18+
const test_step = b.step("test", "Run all the tests");
1819
const mode = b.standardReleaseOptions();
1920
const target = b.standardTargetOptions(.{});
2021
const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
@@ -39,8 +40,6 @@ pub fn build(b: *Builder) !void {
3940
const docs_step = b.step("docs", "Build documentation");
4041
docs_step.dependOn(&docgen_cmd.step);
4142

42-
const toolchain_step = b.step("test-toolchain", "Run the tests for the toolchain");
43-
4443
var test_cases = b.addTest("src/test.zig");
4544
test_cases.stack_size = stack_size;
4645
test_cases.setBuildMode(mode);
@@ -64,10 +63,9 @@ pub fn build(b: *Builder) !void {
6463

6564
const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
6665

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;
66+
const have_stage1 = b.option(bool, "enable-stage1", "Include the stage1 compiler behind a feature flag") orelse false;
6967
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);
68+
const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (have_stage1 or static_llvm);
7169
const llvm_has_m68k = b.option(
7270
bool,
7371
"llvm-has-m68k",
@@ -137,7 +135,7 @@ pub fn build(b: *Builder) !void {
137135
};
138136

139137
const main_file: ?[]const u8 = mf: {
140-
if (!is_stage1) break :mf "src/main.zig";
138+
if (!have_stage1) break :mf "src/main.zig";
141139
if (use_zig0) break :mf null;
142140
break :mf "src/stage1.zig";
143141
};
@@ -150,7 +148,7 @@ pub fn build(b: *Builder) !void {
150148
exe.setBuildMode(mode);
151149
exe.setTarget(target);
152150
if (!skip_stage2_tests) {
153-
toolchain_step.dependOn(&exe.step);
151+
test_step.dependOn(&exe.step);
154152
}
155153

156154
b.default_step.dependOn(&exe.step);
@@ -248,7 +246,7 @@ pub fn build(b: *Builder) !void {
248246
}
249247
};
250248

251-
if (is_stage1) {
249+
if (have_stage1) {
252250
const softfloat = b.addStaticLibrary("softfloat", null);
253251
softfloat.setBuildMode(.ReleaseFast);
254252
softfloat.setTarget(target);
@@ -360,8 +358,7 @@ pub fn build(b: *Builder) !void {
360358
exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);
361359
exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
362360
exe_options.addOption(bool, "value_tracing", value_tracing);
363-
exe_options.addOption(bool, "is_stage1", is_stage1);
364-
exe_options.addOption(bool, "omit_stage2", omit_stage2);
361+
exe_options.addOption(bool, "have_stage1", have_stage1);
365362
if (tracy) |tracy_path| {
366363
const client_cpp = fs.path.join(
367364
b.allocator,
@@ -396,8 +393,7 @@ pub fn build(b: *Builder) !void {
396393
test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
397394
test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
398395
test_cases_options.addOption(bool, "skip_stage1", skip_stage1);
399-
test_cases_options.addOption(bool, "is_stage1", is_stage1);
400-
test_cases_options.addOption(bool, "omit_stage2", omit_stage2);
396+
test_cases_options.addOption(bool, "have_stage1", have_stage1);
401397
test_cases_options.addOption(bool, "have_llvm", enable_llvm);
402398
test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
403399
test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
@@ -418,7 +414,7 @@ pub fn build(b: *Builder) !void {
418414
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
419415
test_cases_step.dependOn(&test_cases.step);
420416
if (!skip_stage2_tests) {
421-
toolchain_step.dependOn(test_cases_step);
417+
test_step.dependOn(test_cases_step);
422418
}
423419

424420
var chosen_modes: [4]builtin.Mode = undefined;
@@ -442,11 +438,11 @@ pub fn build(b: *Builder) !void {
442438
const modes = chosen_modes[0..chosen_mode_index];
443439

444440
// run stage1 `zig fmt` on this build.zig file just to make sure it works
445-
toolchain_step.dependOn(&fmt_build_zig.step);
441+
test_step.dependOn(&fmt_build_zig.step);
446442
const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");
447443
fmt_step.dependOn(&fmt_build_zig.step);
448444

449-
toolchain_step.dependOn(tests.addPkgTests(
445+
test_step.dependOn(tests.addPkgTests(
450446
b,
451447
test_filter,
452448
"test/behavior.zig",
@@ -457,11 +453,10 @@ pub fn build(b: *Builder) !void {
457453
skip_non_native,
458454
skip_libc,
459455
skip_stage1,
460-
omit_stage2,
461-
is_stage1,
456+
skip_stage2_tests,
462457
));
463458

464-
toolchain_step.dependOn(tests.addPkgTests(
459+
test_step.dependOn(tests.addPkgTests(
465460
b,
466461
test_filter,
467462
"lib/compiler_rt.zig",
@@ -472,11 +467,10 @@ pub fn build(b: *Builder) !void {
472467
skip_non_native,
473468
true, // skip_libc
474469
skip_stage1,
475-
omit_stage2 or true, // TODO get these all passing
476-
is_stage1,
470+
skip_stage2_tests or true, // TODO get these all passing
477471
));
478472

479-
toolchain_step.dependOn(tests.addPkgTests(
473+
test_step.dependOn(tests.addPkgTests(
480474
b,
481475
test_filter,
482476
"lib/c.zig",
@@ -487,37 +481,36 @@ pub fn build(b: *Builder) !void {
487481
skip_non_native,
488482
true, // skip_libc
489483
skip_stage1,
490-
omit_stage2 or true, // TODO get these all passing
491-
is_stage1,
484+
skip_stage2_tests or true, // TODO get these all passing
492485
));
493486

494-
toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
495-
toolchain_step.dependOn(tests.addStandaloneTests(
487+
test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
488+
test_step.dependOn(tests.addStandaloneTests(
496489
b,
497490
test_filter,
498491
modes,
499492
skip_non_native,
500493
enable_macos_sdk,
501494
target,
502-
omit_stage2,
495+
skip_stage2_tests,
503496
b.enable_darling,
504497
b.enable_qemu,
505498
b.enable_rosetta,
506499
b.enable_wasmtime,
507500
b.enable_wine,
508501
));
509-
toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, omit_stage2));
510-
toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
511-
toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes));
512-
toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
513-
toolchain_step.dependOn(tests.addTranslateCTests(b, test_filter));
502+
test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests));
503+
test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
504+
test_step.dependOn(tests.addCliTests(b, test_filter, modes));
505+
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
506+
test_step.dependOn(tests.addTranslateCTests(b, test_filter));
514507
if (!skip_run_translated_c) {
515-
toolchain_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target));
508+
test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target));
516509
}
517510
// tests for this feature are disabled until we have the self-hosted compiler available
518-
// toolchain_step.dependOn(tests.addGenHTests(b, test_filter));
511+
// test_step.dependOn(tests.addGenHTests(b, test_filter));
519512

520-
const std_step = tests.addPkgTests(
513+
test_step.dependOn(tests.addPkgTests(
521514
b,
522515
test_filter,
523516
"lib/std/std.zig",
@@ -528,14 +521,8 @@ pub fn build(b: *Builder) !void {
528521
skip_non_native,
529522
skip_libc,
530523
skip_stage1,
531-
omit_stage2 or true, // TODO get these all passing
532-
is_stage1,
533-
);
534-
535-
const test_step = b.step("test", "Run all the tests");
536-
test_step.dependOn(toolchain_step);
537-
test_step.dependOn(std_step);
538-
test_step.dependOn(docs_step);
524+
true, // TODO get these all passing
525+
));
539526
}
540527

541528
const exe_cflags = [_][]const u8{

0 commit comments

Comments
 (0)