- Standard library is now correctly weakly linked, fixing the use of C3 .so together with executable. #1549, #1107.

This commit is contained in:
Christoffer Lerno
2024-10-11 17:13:56 +02:00
parent 2739c86881
commit 09fee2aa4b
4 changed files with 10 additions and 0 deletions

View File

@@ -31,6 +31,7 @@
- Cannot use void as a generic parameter #1546
- Interfaces not correctly copied with generics #1545
- Memory leak in keys.new_list fixed.
- Standard library is now correctly weakly linked, fixing the use of C3 .so together with executable. #1549, #1107.
### Stdlib changes
- Remove unintended print of `char[]` as String

View File

@@ -53,6 +53,12 @@ static void gencontext_init(GenContext *context, Module *module, LLVMContextRef
{
assert(LLVMIsMultithreaded());
memset(context, 0, sizeof(GenContext));
if ((module->name->len == 3 && str_eq("std", module->name->module))
|| (module->name->len > 5 && memcmp("std::", module->name->module, 5) == 0))
{
context->weaken = true;
}
if (shared_context)
{
context->shared_context = true;
@@ -586,6 +592,7 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl)
{
LLVMSetVisibility(global_ref, LLVMDefaultVisibility);
if (optional_ref) LLVMSetVisibility(optional_ref, LLVMDefaultVisibility);
if (c->weaken) llvm_set_linkonce(c, global_ref);
}
else
{

View File

@@ -665,6 +665,7 @@ void llvm_emit_function_decl(GenContext *c, Decl *decl)
LLVMSetVisibility(function, LLVMDefaultVisibility);
return;
}
if (c->weaken) llvm_set_linkonce(c, function);
if (decl->is_weak) llvm_set_weak(c, function);
}

View File

@@ -83,6 +83,7 @@ typedef struct GenContext_
{
bool shared_context;
bool in_init_ref;
bool weaken;
LLVMModuleRef module;
LLVMBuilderRef global_builder;
LLVMTargetMachineRef machine;