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:
Phil Kedy
2019-09-12 02:35:43 -04:00
committed by Ron Evans
parent 1dbfc976e8
commit 55144ad608
3 changed files with 20 additions and 1 deletions
+5
View File
@@ -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 {