mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Minor improvements to -use-separate-modules
This commit is contained in:
@@ -413,7 +413,7 @@ type_info_core :: proc "contextless" (info: ^Type_Info) -> ^Type_Info {
|
|||||||
}
|
}
|
||||||
type_info_base_without_enum :: type_info_core;
|
type_info_base_without_enum :: type_info_core;
|
||||||
|
|
||||||
__type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info {
|
__type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info #no_bounds_check {
|
||||||
MASK :: 1<<(8*size_of(typeid) - 8) - 1;
|
MASK :: 1<<(8*size_of(typeid) - 8) - 1;
|
||||||
data := transmute(uintptr)id;
|
data := transmute(uintptr)id;
|
||||||
n := int(data & MASK);
|
n := int(data & MASK);
|
||||||
|
|||||||
+25
-6
@@ -2819,7 +2819,12 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body)
|
|||||||
char const *export_name = alloc_cstring(permanent_allocator(), p->name);
|
char const *export_name = alloc_cstring(permanent_allocator(), p->name);
|
||||||
LLVMAddTargetDependentFunctionAttr(p->value, "wasm-export-name", export_name);
|
LLVMAddTargetDependentFunctionAttr(p->value, "wasm-export-name", export_name);
|
||||||
}
|
}
|
||||||
|
} else if (!p->is_foreign) {
|
||||||
|
if (!USE_SEPARTE_MODULES) {
|
||||||
|
LLVMSetLinkage(p->value, LLVMInternalLinkage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->is_foreign) {
|
if (p->is_foreign) {
|
||||||
if (is_arch_wasm()) {
|
if (is_arch_wasm()) {
|
||||||
char const *import_name = alloc_cstring(permanent_allocator(), p->name);
|
char const *import_name = alloc_cstring(permanent_allocator(), p->name);
|
||||||
@@ -6066,6 +6071,23 @@ lbValue lb_find_procedure_value_from_entity(lbModule *m, Entity *e) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lb_set_entity_from_other_modules_linkage_correctly(lbModule *other_module, Entity *e, String const &name) {
|
||||||
|
if (other_module == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
char const *cname = alloc_cstring(temporary_allocator(), name);
|
||||||
|
|
||||||
|
LLVMValueRef other_global = nullptr;
|
||||||
|
if (e->kind == Entity_Variable) {
|
||||||
|
other_global = LLVMGetNamedGlobal(other_module->mod, cname);
|
||||||
|
} else if (e->kind == Entity_Procedure) {
|
||||||
|
other_global = LLVMGetNamedFunction(other_module->mod, cname);
|
||||||
|
}
|
||||||
|
if (other_global) {
|
||||||
|
LLVMSetLinkage(other_global, LLVMExternalLinkage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lbValue lb_find_value_from_entity(lbModule *m, Entity *e) {
|
lbValue lb_find_value_from_entity(lbModule *m, Entity *e) {
|
||||||
e = strip_entity_wrapping(e);
|
e = strip_entity_wrapping(e);
|
||||||
GB_ASSERT(e != nullptr);
|
GB_ASSERT(e != nullptr);
|
||||||
@@ -6106,12 +6128,7 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e) {
|
|||||||
|
|
||||||
LLVMSetLinkage(g.value, LLVMExternalLinkage);
|
LLVMSetLinkage(g.value, LLVMExternalLinkage);
|
||||||
|
|
||||||
// if (other_module != nullptr) {
|
lb_set_entity_from_other_modules_linkage_correctly(other_module, e, name);
|
||||||
// lbValue *other_found = string_map_get(&other_module->members, name);
|
|
||||||
// if (other_found) {
|
|
||||||
// lbValue other_g = *other_found;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// LLVMSetLinkage(other_g.value, LLVMExternalLinkage);
|
// LLVMSetLinkage(other_g.value, LLVMExternalLinkage);
|
||||||
|
|
||||||
@@ -11820,6 +11837,8 @@ lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) {
|
|||||||
|
|
||||||
String name = lb_get_entity_name(other_module, e);
|
String name = lb_get_entity_name(other_module, e);
|
||||||
|
|
||||||
|
lb_set_entity_from_other_modules_linkage_correctly(other_module, e, name);
|
||||||
|
|
||||||
lbValue g = {};
|
lbValue g = {};
|
||||||
g.value = LLVMAddGlobal(m->mod, lb_type(m, e->type), alloc_cstring(permanent_allocator(), name));
|
g.value = LLVMAddGlobal(m->mod, lb_type(m, e->type), alloc_cstring(permanent_allocator(), name));
|
||||||
g.type = alloc_type_pointer(e->type);
|
g.type = alloc_type_pointer(e->type);
|
||||||
|
|||||||
Reference in New Issue
Block a user