Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make self-hosted the default compiler #12368

Merged
merged 24 commits into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
73bbd10
build: remove the option to omit stage2
andrewrk Aug 8, 2022
507aae4
make self-hosted the default compiler
andrewrk Aug 8, 2022
06c42a0
CI: test both stage3-debug and stage3-release on x86-linux
andrewrk Aug 8, 2022
a73b3a0
CI: simplify x86 linux test instructions
andrewrk Aug 9, 2022
09ec9b0
langref: update to new error message
andrewrk Aug 10, 2022
e3ccea7
CI: isolate zig-cache for parallel debug/release builds
andrewrk Aug 10, 2022
7346600
CI: avoid concurrent jobs tripping over each other
andrewrk Aug 10, 2022
d75d40d
build: make docs a separate step than test
andrewrk Aug 11, 2022
9f43ebd
CI: windows: build stage3 directly from dev kit
andrewrk Aug 11, 2022
7cf6930
CI: macos: set release mode for zig and simplify
andrewrk Aug 11, 2022
a8f8629
CI: update freebsd tarball
andrewrk Aug 11, 2022
5b486b1
CI: use zig build to produce release artifact
andrewrk Aug 11, 2022
28e95b3
CI: drone: simplify
andrewrk Aug 12, 2022
445b33c
fix std.os.windows.PathSpace.span
andrewrk Aug 18, 2022
5be2e8f
CI: update windows tarball
andrewrk Aug 17, 2022
c446649
build: hook up -Dskip-stage2-tests and remove test-toolchain
andrewrk Aug 18, 2022
35f62bc
CI: windows: don't create build directory
andrewrk Aug 18, 2022
4373117
LLVM: add DLL export attribute
andrewrk Aug 18, 2022
10b95d8
coff: change improperly used packed struct into extern struct
kubkon Aug 18, 2022
a85f41e
test-stack-traces: relax parsing rules
andrewrk Aug 19, 2022
4a27d2a
std.os.linux.bpf: fix compile error
andrewrk Aug 19, 2022
3ce8060
CI: update windows tarball
andrewrk Aug 19, 2022
e78e9f3
CI: update x86_64-linux tarball
andrewrk Aug 19, 2022
b75eeae
CI: x86_64-linux: avoid cmake ZIG_EXECUTABLE hack
andrewrk Aug 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage1" CACHE STRING
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage2" CACHE STRING
"Directory to install zig to" FORCE)
endif()

Expand Down
71 changes: 29 additions & 42 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const stack_size = 32 * 1024 * 1024;

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

const toolchain_step = b.step("test-toolchain", "Run the tests for the toolchain");

var test_cases = b.addTest("src/test.zig");
test_cases.stack_size = stack_size;
test_cases.setBuildMode(mode);
Expand All @@ -64,10 +63,9 @@ 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 have_stage1 = b.option(bool, "enable-stage1", "Include the stage1 compiler behind a feature flag") 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 enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (have_stage1 or static_llvm);
const llvm_has_m68k = b.option(
bool,
"llvm-has-m68k",
Expand Down Expand Up @@ -137,7 +135,7 @@ pub fn build(b: *Builder) !void {
};

const main_file: ?[]const u8 = mf: {
if (!is_stage1) break :mf "src/main.zig";
if (!have_stage1) break :mf "src/main.zig";
if (use_zig0) break :mf null;
break :mf "src/stage1.zig";
};
Expand All @@ -150,7 +148,7 @@ pub fn build(b: *Builder) !void {
exe.setBuildMode(mode);
exe.setTarget(target);
if (!skip_stage2_tests) {
toolchain_step.dependOn(&exe.step);
test_step.dependOn(&exe.step);
}

b.default_step.dependOn(&exe.step);
Expand Down Expand Up @@ -248,7 +246,7 @@ pub fn build(b: *Builder) !void {
}
};

if (is_stage1) {
if (have_stage1) {
const softfloat = b.addStaticLibrary("softfloat", null);
softfloat.setBuildMode(.ReleaseFast);
softfloat.setTarget(target);
Expand Down Expand Up @@ -360,8 +358,7 @@ pub fn build(b: *Builder) !void {
exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);
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);
exe_options.addOption(bool, "have_stage1", have_stage1);
if (tracy) |tracy_path| {
const client_cpp = fs.path.join(
b.allocator,
Expand Down Expand Up @@ -396,8 +393,7 @@ pub fn build(b: *Builder) !void {
test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
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_stage1", have_stage1);
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 All @@ -418,7 +414,7 @@ pub fn build(b: *Builder) !void {
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
test_cases_step.dependOn(&test_cases.step);
if (!skip_stage2_tests) {
toolchain_step.dependOn(test_cases_step);
test_step.dependOn(test_cases_step);
}

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

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

toolchain_step.dependOn(tests.addPkgTests(
test_step.dependOn(tests.addPkgTests(
b,
test_filter,
"test/behavior.zig",
Expand All @@ -457,11 +453,10 @@ pub fn build(b: *Builder) !void {
skip_non_native,
skip_libc,
skip_stage1,
omit_stage2,
is_stage1,
skip_stage2_tests,
));

toolchain_step.dependOn(tests.addPkgTests(
test_step.dependOn(tests.addPkgTests(
b,
test_filter,
"lib/compiler_rt.zig",
Expand All @@ -472,11 +467,10 @@ pub fn build(b: *Builder) !void {
skip_non_native,
true, // skip_libc
skip_stage1,
omit_stage2 or true, // TODO get these all passing
is_stage1,
skip_stage2_tests or true, // TODO get these all passing
));

toolchain_step.dependOn(tests.addPkgTests(
test_step.dependOn(tests.addPkgTests(
b,
test_filter,
"lib/c.zig",
Expand All @@ -487,37 +481,36 @@ pub fn build(b: *Builder) !void {
skip_non_native,
true, // skip_libc
skip_stage1,
omit_stage2 or true, // TODO get these all passing
is_stage1,
skip_stage2_tests or true, // TODO get these all passing
));

toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
toolchain_step.dependOn(tests.addStandaloneTests(
test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
test_step.dependOn(tests.addStandaloneTests(
b,
test_filter,
modes,
skip_non_native,
enable_macos_sdk,
target,
omit_stage2,
skip_stage2_tests,
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.addStackTraceTests(b, test_filter, modes));
toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes));
toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
toolchain_step.dependOn(tests.addTranslateCTests(b, test_filter));
test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests));
test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
test_step.dependOn(tests.addCliTests(b, test_filter, modes));
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
test_step.dependOn(tests.addTranslateCTests(b, test_filter));
if (!skip_run_translated_c) {
toolchain_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target));
test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target));
}
// tests for this feature are disabled until we have the self-hosted compiler available
// toolchain_step.dependOn(tests.addGenHTests(b, test_filter));
// test_step.dependOn(tests.addGenHTests(b, test_filter));

const std_step = tests.addPkgTests(
test_step.dependOn(tests.addPkgTests(
b,
test_filter,
"lib/std/std.zig",
Expand All @@ -528,14 +521,8 @@ pub fn build(b: *Builder) !void {
skip_non_native,
skip_libc,
skip_stage1,
omit_stage2 or true, // TODO get these all passing
is_stage1,
);

const test_step = b.step("test", "Run all the tests");
test_step.dependOn(toolchain_step);
test_step.dependOn(std_step);
test_step.dependOn(docs_step);
true, // TODO get these all passing
));
}

const exe_cflags = [_][]const u8{
Expand Down
Loading