mirror of
https://github.com/ziglang/zig.git
synced 2025-12-17 11:43:16 +00:00
Merge pull request #9717 from SpexGuy/stage2-start-windows
Make stage2 start.zig work on Windows
This commit is contained in:
commit
0ec01e58b4
@ -115,6 +115,7 @@ pub fn build(b: *Builder) !void {
|
|||||||
if (target.isWindows() and target.getAbi() == .gnu) {
|
if (target.isWindows() and target.getAbi() == .gnu) {
|
||||||
// LTO is currently broken on mingw, this can be removed when it's fixed.
|
// LTO is currently broken on mingw, this can be removed when it's fixed.
|
||||||
exe.want_lto = false;
|
exe.want_lto = false;
|
||||||
|
test_stage2.want_lto = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const exe_options = b.addOptions();
|
const exe_options = b.addOptions();
|
||||||
@ -501,6 +502,7 @@ fn addStaticLlvmOptionsToExe(
|
|||||||
if (exe.target.getOs().tag == .windows) {
|
if (exe.target.getOs().tag == .windows) {
|
||||||
exe.linkSystemLibrary("version");
|
exe.linkSystemLibrary("version");
|
||||||
exe.linkSystemLibrary("uuid");
|
exe.linkSystemLibrary("uuid");
|
||||||
|
exe.linkSystemLibrary("ole32");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,8 @@ comptime {
|
|||||||
if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
|
if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
|
||||||
@export(main2, .{ .name = "main" });
|
@export(main2, .{ .name = "main" });
|
||||||
}
|
}
|
||||||
|
} else if (builtin.os.tag == .windows) {
|
||||||
|
@export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });
|
||||||
} else {
|
} else {
|
||||||
if (!@hasDecl(root, "_start")) {
|
if (!@hasDecl(root, "_start")) {
|
||||||
@export(_start2, .{ .name = "_start" });
|
@export(_start2, .{ .name = "_start" });
|
||||||
@ -96,6 +98,11 @@ fn callMain2() noreturn {
|
|||||||
exit2(0);
|
exit2(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn wWinMainCRTStartup2() callconv(.C) noreturn {
|
||||||
|
root.main();
|
||||||
|
exit2(0);
|
||||||
|
}
|
||||||
|
|
||||||
fn exit2(code: usize) noreturn {
|
fn exit2(code: usize) noreturn {
|
||||||
switch (native_os) {
|
switch (native_os) {
|
||||||
.linux => switch (builtin.stage2_arch) {
|
.linux => switch (builtin.stage2_arch) {
|
||||||
@ -148,11 +155,16 @@ fn exit2(code: usize) noreturn {
|
|||||||
},
|
},
|
||||||
else => @compileError("TODO"),
|
else => @compileError("TODO"),
|
||||||
},
|
},
|
||||||
|
.windows => {
|
||||||
|
ExitProcess(@truncate(u32, code));
|
||||||
|
},
|
||||||
else => @compileError("TODO"),
|
else => @compileError("TODO"),
|
||||||
}
|
}
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.C) noreturn;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
fn _DllMainCRTStartup(
|
fn _DllMainCRTStartup(
|
||||||
|
|||||||
@ -3758,13 +3758,6 @@ pub fn clearDecl(
|
|||||||
dep.removeDependency(decl);
|
dep.removeDependency(decl);
|
||||||
if (outdated_decls) |map| {
|
if (outdated_decls) |map| {
|
||||||
map.putAssumeCapacity(dep, {});
|
map.putAssumeCapacity(dep, {});
|
||||||
} else if (std.debug.runtime_safety) {
|
|
||||||
// If `outdated_decls` is `null`, it means we're being called from
|
|
||||||
// `Compilation` after `performAllTheWork` and we cannot queue up any
|
|
||||||
// more work. `dep` must necessarily be another Decl that is no longer
|
|
||||||
// being referenced, and will be in the `deletion_set`. Otherwise,
|
|
||||||
// something has gone wrong.
|
|
||||||
assert(mod.deletion_set.contains(dep));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
decl.dependants.clearRetainingCapacity();
|
decl.dependants.clearRetainingCapacity();
|
||||||
|
|||||||
@ -1336,6 +1336,8 @@ pub const Type = extern union {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// For structs and unions, if the type does not have their fields resolved
|
||||||
|
/// this will return `false`.
|
||||||
pub fn hasCodeGenBits(self: Type) bool {
|
pub fn hasCodeGenBits(self: Type) bool {
|
||||||
return switch (self.tag()) {
|
return switch (self.tag()) {
|
||||||
.u1,
|
.u1,
|
||||||
@ -1400,14 +1402,10 @@ pub const Type = extern union {
|
|||||||
=> true,
|
=> true,
|
||||||
|
|
||||||
.@"struct" => {
|
.@"struct" => {
|
||||||
// TODO introduce lazy value mechanism
|
|
||||||
const struct_obj = self.castTag(.@"struct").?.data;
|
const struct_obj = self.castTag(.@"struct").?.data;
|
||||||
if (struct_obj.known_has_bits) {
|
if (struct_obj.known_has_bits) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
assert(struct_obj.status == .have_field_types or
|
|
||||||
struct_obj.status == .layout_wip or
|
|
||||||
struct_obj.status == .have_layout);
|
|
||||||
for (struct_obj.fields.values()) |value| {
|
for (struct_obj.fields.values()) |value| {
|
||||||
if (value.ty.hasCodeGenBits())
|
if (value.ty.hasCodeGenBits())
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
var case = ctx.exe("hello world with updates", linux_x64);
|
var case = ctx.exe("hello world with updates", linux_x64);
|
||||||
|
|
||||||
case.addError("", &[_][]const u8{
|
case.addError("", &[_][]const u8{
|
||||||
":95:9: error: struct 'tmp.tmp' has no member named 'main'",
|
":97:9: error: struct 'tmp.tmp' has no member named 'main'",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Incorrect return type
|
// Incorrect return type
|
||||||
|
|||||||
@ -14,7 +14,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
{
|
{
|
||||||
var case = ctx.exe("darwin hello world with updates", target);
|
var case = ctx.exe("darwin hello world with updates", target);
|
||||||
case.addError("", &[_][]const u8{
|
case.addError("", &[_][]const u8{
|
||||||
":95:9: error: struct 'tmp.tmp' has no member named 'main'",
|
":97:9: error: struct 'tmp.tmp' has no member named 'main'",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Incorrect return type
|
// Incorrect return type
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user