2
0
Эх сурвалжийг харах

Add `runtime._cleanup_runtime` internal call

gingerBill 4 жил өмнө
parent
commit
7aac8df2f2

+ 6 - 1
core/runtime/core.odin

@@ -384,7 +384,12 @@ Raw_Cstring :: struct {
 // This is probably only useful for freestanding targets
 // This is probably only useful for freestanding targets
 foreign {
 foreign {
 	@(link_name="__$startup_runtime")
 	@(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)
 }
 }
 
 
 
 

+ 1 - 1
src/checker.cpp

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

+ 4 - 1
src/llvm_backend.cpp

@@ -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) {
 	if (is_dll_main) {
 		LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_i32), 1, false));
 		LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_i32), 1, false));