correct startup logic for exporting libc main

This commit is contained in:
Andrew Kelley 2019-12-03 13:10:26 -05:00
parent a91f552393
commit 8db4d2332e
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -24,10 +24,10 @@ comptime {
@export("_DllMainCRTStartup", _DllMainCRTStartup, .Strong);
}
} else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
if (builtin.link_libc and @hasDecl(root, "main") and
@typeInfo(@typeOf(root.main)).Fn.calling_convention != .C)
{
@export("main", main, .Weak);
if (builtin.link_libc and @hasDecl(root, "main")) {
if (@typeInfo(@typeOf(root.main)).Fn.calling_convention != .C) {
@export("main", main, .Weak);
}
} else if (builtin.os == .windows) {
if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) {
@export("WinMainCRTStartup", WinMainCRTStartup, .Strong);