Skip to content

Commit fd7654e

Browse files
committed
build-exe allows direct export of WinMainCRTStartup
1 parent f54aff4 commit fd7654e

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/all_types.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,7 @@ struct CodeGen {
14551455
bool have_pub_main;
14561456
bool have_c_main;
14571457
bool have_winmain;
1458+
bool have_winmain_crt_startup;
14581459
bool have_pub_panic;
14591460
Buf *libc_lib_dir;
14601461
Buf *libc_static_lib_dir;

src/analyze.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,6 +3196,10 @@ ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *a
31963196
g->have_winmain = true;
31973197
g->windows_subsystem_windows = true;
31983198
g->windows_subsystem_console = false;
3199+
} else if (proto_node->data.fn_proto.visib_mod == VisibModExport &&
3200+
buf_eql_str(proto_name, "WinMainCRTStartup") && g->zig_target.os == ZigLLVM_Win32)
3201+
{
3202+
g->have_winmain_crt_startup = true;
31993203
}
32003204

32013205
}

src/codegen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5213,7 +5213,8 @@ static void gen_root_source(CodeGen *g) {
52135213
assert(g->root_out_name);
52145214
assert(g->out_type != OutTypeUnknown);
52155215

5216-
if (!g->is_test_build && g->zig_target.os != ZigLLVM_UnknownOS && !g->have_c_main && !g->have_winmain &&
5216+
if (!g->is_test_build && g->zig_target.os != ZigLLVM_UnknownOS &&
5217+
!g->have_c_main && !g->have_winmain && !g->have_winmain_crt_startup &&
52175218
((g->have_pub_main && g->out_type == OutTypeObj) || g->out_type == OutTypeExe))
52185219
{
52195220
g->bootstrap_import = add_special_code(g, create_bootstrap_pkg(g, g->root_package), "bootstrap.zig");

0 commit comments

Comments
 (0)