mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 04:50:29 +00:00
Correct linkage for entry point procedures on Windows
This commit is contained in:
@@ -2113,11 +2113,15 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
|
||||
case Entity_Variable:
|
||||
if (e->Variable.is_export) {
|
||||
add_dependency_to_set(c, e);
|
||||
} else if (e->flags & EntityFlag_Require) {
|
||||
add_dependency_to_set(c, e);
|
||||
}
|
||||
break;
|
||||
case Entity_Procedure:
|
||||
if (e->Procedure.is_export) {
|
||||
add_dependency_to_set(c, e);
|
||||
} else if (e->flags & EntityFlag_Require) {
|
||||
add_dependency_to_set(c, e);
|
||||
}
|
||||
if (e->flags & EntityFlag_Init) {
|
||||
Type *t = base_type(e->type);
|
||||
@@ -5440,7 +5444,9 @@ void check_parsed_files(Checker *c) {
|
||||
Ast *node = nullptr;
|
||||
while (mpmc_dequeue(&c->info.intrinsics_entry_point_usage, &node)) {
|
||||
if (c->info.entry_point == nullptr && node != nullptr) {
|
||||
warning(node, "usage of intrinsics.__entry_point will be a no-op");
|
||||
if (node->file()->pkg->kind != Package_Runtime) {
|
||||
warning(node, "usage of intrinsics.__entry_point will be a no-op");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1405,7 +1405,6 @@ void lb_generate_code(lbGenerator *gen) {
|
||||
|
||||
|
||||
isize global_variable_max_count = 0;
|
||||
Entity *entry_point = info->entry_point;
|
||||
bool already_has_entry_point = false;
|
||||
|
||||
for_array(i, info->entities) {
|
||||
@@ -1416,14 +1415,17 @@ void lb_generate_code(lbGenerator *gen) {
|
||||
global_variable_max_count++;
|
||||
} else if (e->kind == Entity_Procedure) {
|
||||
if ((e->scope->flags&ScopeFlag_Init) && name == "main") {
|
||||
GB_ASSERT(e == entry_point);
|
||||
// entry_point = e;
|
||||
GB_ASSERT(e == info->entry_point);
|
||||
}
|
||||
if (e->Procedure.is_export ||
|
||||
(e->Procedure.link_name.len > 0) ||
|
||||
((e->scope->flags&ScopeFlag_File) && e->Procedure.link_name.len > 0)) {
|
||||
String link_name = e->Procedure.link_name;
|
||||
if (link_name == "main" || link_name == "DllMain" || link_name == "WinMain" || link_name == "mainCRTStartup") {
|
||||
if (link_name == "main" ||
|
||||
link_name == "DllMain" ||
|
||||
link_name == "WinMain" ||
|
||||
link_name == "wWinMain" ||
|
||||
link_name == "mainCRTStartup") {
|
||||
already_has_entry_point = true;
|
||||
}
|
||||
}
|
||||
@@ -1562,6 +1564,11 @@ void lb_generate_code(lbGenerator *gen) {
|
||||
}
|
||||
}
|
||||
|
||||
TIME_SECTION("LLVM Runtime Type Information Creation");
|
||||
lbProcedure *startup_type_info = lb_create_startup_type_info(default_module);
|
||||
|
||||
TIME_SECTION("LLVM Runtime Startup Creation (Global Variables)");
|
||||
lbProcedure *startup_runtime = lb_create_startup_runtime(default_module, startup_type_info, global_variables);
|
||||
|
||||
TIME_SECTION("LLVM Global Procedures and Types");
|
||||
for_array(i, info->entities) {
|
||||
@@ -1621,14 +1628,6 @@ void lb_generate_code(lbGenerator *gen) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TIME_SECTION("LLVM Runtime Type Information Creation");
|
||||
lbProcedure *startup_type_info = lb_create_startup_type_info(default_module);
|
||||
|
||||
TIME_SECTION("LLVM Runtime Startup Creation (Global Variables)");
|
||||
lbProcedure *startup_runtime = lb_create_startup_runtime(default_module, startup_type_info, global_variables);
|
||||
|
||||
|
||||
TIME_SECTION("LLVM Procedure Generation");
|
||||
for_array(j, gen->modules.entries) {
|
||||
lbModule *m = gen->modules.entries[j].value;
|
||||
|
||||
@@ -304,7 +304,7 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body)
|
||||
lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type) {
|
||||
{
|
||||
lbValue *found = string_map_get(&m->members, link_name);
|
||||
GB_ASSERT(found == nullptr);
|
||||
GB_ASSERT_MSG(found == nullptr, "failed to create dummy procedure for: %.*s", LIT(link_name));
|
||||
}
|
||||
|
||||
lbProcedure *p = gb_alloc_item(permanent_allocator(), lbProcedure);
|
||||
|
||||
Reference in New Issue
Block a user