authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-02 14:51:22-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-02 14:52:56-07:00
log463186e8565c717049fabd4ff1c2442053c8ba9a
tree953c1f5f517efbd1b34fd4392e397a6d627bc416
parentf84232714791137ab0e3f457b0eed773e476f293

stage2: wire up -Dskip-non-native

The purpose of this is to save time in the edit-compile-test cycle when working on stage2 code.

3 files changed, 8 insertions(+), 0 deletions(-)

build.zig+2
...@@ -83,6 +83,7 @@ pub fn build(b: *Builder) !void {...@@ -83,6 +83,7 @@ pub fn build(b: *Builder) !void {
83 test_step.dependOn(&exe.step);83 test_step.dependOn(&exe.step);
84 b.default_step.dependOn(&exe.step);84 b.default_step.dependOn(&exe.step);
8585
86 exe.addBuildOption(bool, "skip_non_native", skip_non_native);
86 exe.addBuildOption(bool, "have_llvm", enable_llvm);87 exe.addBuildOption(bool, "have_llvm", enable_llvm);
87 if (enable_llvm) {88 if (enable_llvm) {
88 const config_h_text = if (config_h_path_option) |config_h_path|89 const config_h_text = if (config_h_path_option) |config_h_path|
...@@ -166,6 +167,7 @@ pub fn build(b: *Builder) !void {...@@ -166,6 +167,7 @@ pub fn build(b: *Builder) !void {
166 const is_wasmtime_enabled = b.option(bool, "enable-wasmtime", "Use Wasmtime to enable and run WASI libstd tests") orelse false;167 const is_wasmtime_enabled = b.option(bool, "enable-wasmtime", "Use Wasmtime to enable and run WASI libstd tests") orelse false;
167 const glibc_multi_dir = b.option([]const u8, "enable-foreign-glibc", "Provide directory with glibc installations to run cross compiled tests that link glibc");168 const glibc_multi_dir = b.option([]const u8, "enable-foreign-glibc", "Provide directory with glibc installations to run cross compiled tests that link glibc");
168169
170 test_stage2.addBuildOption(bool, "skip_non_native", skip_non_native);
169 test_stage2.addBuildOption(bool, "is_stage1", false);171 test_stage2.addBuildOption(bool, "is_stage1", false);
170 test_stage2.addBuildOption(bool, "have_llvm", enable_llvm);172 test_stage2.addBuildOption(bool, "have_llvm", enable_llvm);
171 test_stage2.addBuildOption(bool, "enable_qemu", is_qemu_enabled);173 test_stage2.addBuildOption(bool, "enable_qemu", is_qemu_enabled);
src/codegen.zig+5
...@@ -16,6 +16,7 @@ const trace = @import("tracy.zig").trace;...@@ -16,6 +16,7 @@ const trace = @import("tracy.zig").trace;
16const DW = std.dwarf;16const DW = std.dwarf;
17const leb128 = std.leb;17const leb128 = std.leb;
18const log = std.log.scoped(.codegen);18const log = std.log.scoped(.codegen);
19const build_options = @import("build_options");
1920
20/// The codegen-related data that is stored in `ir.Inst.Block` instructions.21/// The codegen-related data that is stored in `ir.Inst.Block` instructions.
21pub const BlockData = struct {22pub const BlockData = struct {
...@@ -427,6 +428,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -427,6 +428,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
427 code: *std.ArrayList(u8),428 code: *std.ArrayList(u8),
428 debug_output: DebugInfoOutput,429 debug_output: DebugInfoOutput,
429 ) GenerateSymbolError!Result {430 ) GenerateSymbolError!Result {
431 if (build_options.skip_non_native and std.Target.current.cpu.arch != arch) {
432 @panic("Attempted to compile for architecture that was disabled by build configuration");
433 }
434
430 const module_fn = typed_value.val.cast(Value.Payload.Function).?.func;435 const module_fn = typed_value.val.cast(Value.Payload.Function).?.func;
431436
432 const fn_type = module_fn.owner_decl.typed_value.most_recent.typed_value.ty;437 const fn_type = module_fn.owner_decl.typed_value.most_recent.typed_value.ty;
src/config.zig.in+1
...@@ -4,3 +4,4 @@ pub const log_scopes: []const []const u8 = &[_][]const u8{};...@@ -4,3 +4,4 @@ pub const log_scopes: []const []const u8 = &[_][]const u8{};
4pub const zir_dumps: []const []const u8 = &[_][]const u8{};4pub const zir_dumps: []const []const u8 = &[_][]const u8{};
5pub const enable_tracy = false;5pub const enable_tracy = false;
6pub const is_stage1 = true;6pub const is_stage1 = true;
7pub const skip_non_native = false;