mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 15:33:40 +00:00
WASM: Support for setting an imported function's module name (#455)
* wasm: add support for setting a function's Wasm import module name by using the //go:wasm-module comment.
This commit is contained in:
@@ -821,6 +821,11 @@ func (c *Compiler) parseFuncDecl(f *ir.Function) *Frame {
|
||||
// External/exported functions may not retain pointer values.
|
||||
// https://golang.org/cmd/cgo/#hdr-Passing_pointers
|
||||
if f.IsExported() {
|
||||
// Set the wasm-import-module attribute if the function's module is set.
|
||||
if f.Module() != "" {
|
||||
wasmImportModuleAttr := c.ctx.CreateStringAttribute("wasm-import-module", f.Module())
|
||||
frame.fn.LLVMFn.AddFunctionAttr(wasmImportModuleAttr)
|
||||
}
|
||||
nocaptureKind := llvm.AttributeKindID("nocapture")
|
||||
nocapture := c.ctx.CreateEnumAttribute(nocaptureKind, 0)
|
||||
for i, typ := range paramTypes {
|
||||
|
||||
Reference in New Issue
Block a user