Some Windows improvements
This commit is contained in:
parent
1e7248ab0a
commit
23399c5ea6
@ -2769,6 +2769,7 @@ const Arch = enum {
|
||||
const Os = enum {
|
||||
linux,
|
||||
macos,
|
||||
windows,
|
||||
};
|
||||
|
||||
const Abi = enum {
|
||||
@ -2795,6 +2796,11 @@ pub fn buildExecutable(context: *const Context, arguments: []const []const u8, o
|
||||
os = .macos;
|
||||
abi = .none;
|
||||
},
|
||||
.windows => {
|
||||
arch = .x86_64;
|
||||
os = .windows;
|
||||
abi = .gnu;
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
|
||||
@ -2983,6 +2989,7 @@ pub fn buildExecutable(context: *const Context, arguments: []const []const u8, o
|
||||
.link_libc = switch (os) {
|
||||
.linux => link_libc,
|
||||
.macos => true,
|
||||
.windows => link_libc,
|
||||
// .windows => link_libc,
|
||||
// else => unreachable,
|
||||
},
|
||||
@ -3066,7 +3073,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, return_
|
||||
write(.panic, "\nPANIC: ") catch {};
|
||||
write(.panic, message) catch {};
|
||||
write(.panic, "\n") catch {};
|
||||
@breakpoint();
|
||||
if (@import("builtin").os.tag != .windows) @breakpoint();
|
||||
std.posix.abort();
|
||||
},
|
||||
}
|
||||
@ -3277,7 +3284,7 @@ pub const Type = union(enum) {
|
||||
polymorphic: Type.Polymorphic,
|
||||
|
||||
pub const @"usize" = _usize;
|
||||
pub const @"ssize" = _ssize;
|
||||
pub const ssize = _ssize;
|
||||
|
||||
pub const Polymorphic = struct {
|
||||
parameters: []const Token.Index,
|
||||
@ -8787,7 +8794,6 @@ pub const Builder = struct {
|
||||
|
||||
const phi = &unit.instructions.get(builder.return_phi).phi;
|
||||
|
||||
|
||||
switch (return_type.*) {
|
||||
.void => unreachable,
|
||||
.noreturn => unreachable,
|
||||
@ -16724,5 +16730,3 @@ pub fn write(kind: LogKind, string: []const u8) !void {
|
||||
try std.io.getStdOut().writeAll(string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2363,7 +2363,6 @@ pub const LLVM = struct {
|
||||
.function_definition => {},
|
||||
else => |t| @panic(@tagName(t)),
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@ -3247,13 +3246,14 @@ pub fn codegen(unit: *Compilation.Unit, context: *const Compilation.Context) !vo
|
||||
arch.initializeTargetMC();
|
||||
arch.initializeAsmPrinter();
|
||||
arch.initializeAsmParser();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// TODO: proper target selection
|
||||
const target_triple = switch (unit.descriptor.os) {
|
||||
.linux => "x86_64-linux-none",
|
||||
.macos => "aarch64-apple-macosx-none",
|
||||
.windows => "x86_64-windows-gnu",
|
||||
};
|
||||
const cpu = "generic";
|
||||
const features = "";
|
||||
|
18
build.zig
18
build.zig
@ -23,12 +23,13 @@ pub fn build(b: *std.Build) !void {
|
||||
const self_hosted_ci = b.option(bool, "self_hosted_ci", "This option enables the self-hosted CI behavior") orelse false;
|
||||
const third_party_ci = b.option(bool, "third_party_ci", "This option enables the third-party CI behavior") orelse false;
|
||||
const is_ci = self_hosted_ci or third_party_ci;
|
||||
const print_stack_trace = b.option(bool, "print_stack_trace", "This option enables printing stack traces inside the compiler") orelse is_ci or os == .macos;
|
||||
const print_stack_trace = b.option(bool, "print_stack_trace", "This option enables printing stack traces inside the compiler") orelse is_ci or os == .macos or os == .windows;
|
||||
const native_target = b.resolveTargetQuery(.{});
|
||||
const optimization = b.standardOptimizeOption(.{});
|
||||
const use_debug = b.option(bool, "use_debug", "This option enables the LLVM debug build in the development PC") orelse false;
|
||||
const static = b.option(bool, "static", "This option enables the compiler to be built statically") orelse switch (@import("builtin").os.tag) {
|
||||
else => use_debug,
|
||||
.windows => true,
|
||||
.macos => true,
|
||||
};
|
||||
const compiler_options = b.addOptions();
|
||||
@ -42,7 +43,17 @@ pub fn build(b: *std.Build) !void {
|
||||
.single_threaded = true,
|
||||
});
|
||||
|
||||
var target_query = b.standardTargetOptionsQueryOnly(.{});
|
||||
var target_query = b.standardTargetOptionsQueryOnly(switch (@import("builtin").os.tag) {
|
||||
else => .{},
|
||||
.windows => .{
|
||||
.default_target = .{
|
||||
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .windows,
|
||||
.abi = .gnu,
|
||||
},
|
||||
},
|
||||
});
|
||||
const abi = b.option(std.Target.Abi, "abi", "This option modifies the ABI used for the compiler") orelse if (static) switch (target_query.os_tag orelse @import("builtin").os.tag) {
|
||||
else => target_query.abi,
|
||||
.linux => b: {
|
||||
@ -62,6 +73,7 @@ pub fn build(b: *std.Build) !void {
|
||||
break :b if (std.mem.eql(u8, value, "arch") or std.mem.eql(u8, value, "endeavouros")) .musl else target_query.abi;
|
||||
},
|
||||
} else target_query.abi;
|
||||
|
||||
target_query.abi = abi;
|
||||
const target = b.resolveTargetQuery(target_query);
|
||||
|
||||
@ -107,7 +119,7 @@ pub fn build(b: *std.Build) !void {
|
||||
compiler.want_lto = false;
|
||||
|
||||
compiler.linkLibC();
|
||||
if (target.result.os.tag == .windows) compiler.linkage = .dynamic;
|
||||
//if (target.result.os.tag == .windows) compiler.linkage = .dynamic;
|
||||
|
||||
const zstd = if (target.result.os.tag == .windows) "zstd.lib" else "libzstd.a";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user