diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-05-17 18:15:08 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-05-22 09:40:37 -0400 |
| commit | 713360a792ea54211624f7ac18e68c4c4a16aeb1 (patch) | |
| tree | c3b9291c733ae02decb225a7a79d64064b064e14 /src/llvm_backend.cpp | |
| parent | d6210ae76f01fd14b8eb09b12f9d3d1f48b32cea (diff) | |
Keep shared libraries from calling main program's startup/cleanup procs on Linux
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 7de147058..395238753 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -1907,6 +1907,10 @@ gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProc lb_add_attribute_to_proc(p->module, p->value, "optnone"); lb_add_attribute_to_proc(p->module, p->value, "noinline"); + // Make sure shared libraries call their own runtime startup on Linux. + LLVMSetVisibility(p->value, LLVMHiddenVisibility); + LLVMSetLinkage(p->value, LLVMWeakAnyLinkage); + lb_begin_procedure_body(p); lb_setup_type_info_data(main_module); @@ -2016,6 +2020,10 @@ gb_internal lbProcedure *lb_create_cleanup_runtime(lbModule *main_module) { // C lb_add_attribute_to_proc(p->module, p->value, "optnone"); lb_add_attribute_to_proc(p->module, p->value, "noinline"); + // Make sure shared libraries call their own runtime cleanup on Linux. + LLVMSetVisibility(p->value, LLVMHiddenVisibility); + LLVMSetLinkage(p->value, LLVMWeakAnyLinkage); + lb_begin_procedure_body(p); CheckerInfo *info = main_module->gen->info; |