Add runtime._cleanup_runtime internal call

This commit is contained in:
gingerBill
2021-10-18 12:28:46 +01:00
parent e98e62ec13
commit 7aac8df2f2
3 changed files with 11 additions and 3 deletions

View File

@@ -384,7 +384,12 @@ Raw_Cstring :: struct {
// This is probably only useful for freestanding targets
foreign {
@(link_name="__$startup_runtime")
_startup_runtime :: proc "contextless" () ---
_startup_runtime :: proc() ---
}
@(link_name="__$cleanup_runtime")
_cleanup_runtime :: proc() {
default_temp_allocator_destroy(&global_default_temp_allocator_data)
}

View File

@@ -1967,6 +1967,7 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
str_lit("__init_context"),
str_lit("__type_info_of"),
str_lit("cstring_to_string"),
str_lit("_cleanup_runtime"),
// Pseudo-CRT required procedures
str_lit("memset"),
@@ -1993,7 +1994,6 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
str_lit("gnu_h2f_ieee"),
str_lit("gnu_f2h_ieee"),
str_lit("extendhfsf2"),
};
for (isize i = 0; i < gb_count_of(required_runtime_entities); i++) {
force_add_dependency_entity(c, c->info.runtime_package->scope, required_runtime_entities[i]);

View File

@@ -879,7 +879,10 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime)
}
}
lbValue cleanup_runtime_value = lb_find_runtime_value(m, str_lit("_cleanup_runtime"));
lb_emit_call(p, cleanup_runtime_value, {}, ProcInlining_none, false);
if (is_dll_main) {
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_i32), 1, false));