commit 463186e8565c717049fabd4ff1c2442053c8ba9a (tree)
parent f84232714791137ab0e3f457b0eed773e476f293
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 2 Dec 2020 14:51:22 -0700
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.
Diffstat:
3 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/build.zig b/build.zig
@@ -83,6 +83,7 @@ pub fn build(b: *Builder) !void {
test_step.dependOn(&exe.step);
b.default_step.dependOn(&exe.step);
+ exe.addBuildOption(bool, "skip_non_native", skip_non_native);
exe.addBuildOption(bool, "have_llvm", enable_llvm);
if (enable_llvm) {
const config_h_text = if (config_h_path_option) |config_h_path|
@@ -166,6 +167,7 @@ pub fn build(b: *Builder) !void {
const is_wasmtime_enabled = b.option(bool, "enable-wasmtime", "Use Wasmtime to enable and run WASI libstd tests") orelse false;
const glibc_multi_dir = b.option([]const u8, "enable-foreign-glibc", "Provide directory with glibc installations to run cross compiled tests that link glibc");
+ test_stage2.addBuildOption(bool, "skip_non_native", skip_non_native);
test_stage2.addBuildOption(bool, "is_stage1", false);
test_stage2.addBuildOption(bool, "have_llvm", enable_llvm);
test_stage2.addBuildOption(bool, "enable_qemu", is_qemu_enabled);
diff --git a/src/codegen.zig b/src/codegen.zig
@@ -16,6 +16,7 @@ const trace = @import("tracy.zig").trace;
const DW = std.dwarf;
const leb128 = std.leb;
const log = std.log.scoped(.codegen);
+const build_options = @import("build_options");
/// The codegen-related data that is stored in `ir.Inst.Block` instructions.
pub const BlockData = struct {
@@ -427,6 +428,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
code: *std.ArrayList(u8),
debug_output: DebugInfoOutput,
) GenerateSymbolError!Result {
+ if (build_options.skip_non_native and std.Target.current.cpu.arch != arch) {
+ @panic("Attempted to compile for architecture that was disabled by build configuration");
+ }
+
const module_fn = typed_value.val.cast(Value.Payload.Function).?.func;
const fn_type = module_fn.owner_decl.typed_value.most_recent.typed_value.ty;
diff --git a/src/config.zig.in b/src/config.zig.in
@@ -4,3 +4,4 @@ pub const log_scopes: []const []const u8 = &[_][]const u8{};
pub const zir_dumps: []const []const u8 = &[_][]const u8{};
pub const enable_tracy = false;
pub const is_stage1 = true;
+pub const skip_non_native = false;