diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2021-10-31 19:19:48 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-31 19:19:48 +0000 |
| commit | b1de429d2cf5c2d1643acc73ec3ced22e57d6a07 (patch) | |
| tree | 99d74a813fc16bbe3389f69cb0ca516744cbb561 /src/llvm_backend_proc.cpp | |
| parent | 3de1719c172771c2cb5ed41725274e71906b7e0a (diff) | |
| parent | 5f51337a01fa4a1e7a461604d564fa64601727cf (diff) | |
Merge pull request #1255 from odin-lang/wasi-wasm
`wasi_wasm32` support
Diffstat (limited to 'src/llvm_backend_proc.cpp')
| -rw-r--r-- | src/llvm_backend_proc.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 15689da36..29f7b6655 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -195,13 +195,19 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) // then it is very likely it is required by LLVM and thus cannot have internal linkage if (entity->pkg != nullptr && entity->pkg->kind == Package_Runtime && p->body != nullptr) { GB_ASSERT(entity->kind == Entity_Procedure); - if (entity->Procedure.link_name != "") { - LLVMSetLinkage(p->value, LLVMExternalLinkage); + String link_name = entity->Procedure.link_name; + if (entity->flags & EntityFlag_CustomLinkName && + link_name != "") { + if (string_starts_with(link_name, str_lit("__"))) { + LLVMSetLinkage(p->value, LLVMExternalLinkage); + } else { + LLVMSetLinkage(p->value, LLVMInternalLinkage); + } } } } } - + if (p->is_foreign) { if (is_arch_wasm()) { char const *import_name = alloc_cstring(permanent_allocator(), p->name); @@ -217,6 +223,7 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) LLVMAddTargetDependentFunctionAttr(p->value, "wasm-import-module", module_name); } } + // NOTE(bill): offset==0 is the return value isize offset = 1; |