diff --git a/builder/build.go b/builder/build.go index 57b67ed455..4a92fa4409 100644 --- a/builder/build.go +++ b/builder/build.go @@ -711,6 +711,12 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe } linkerDependencies = append(linkerDependencies, job) } + + // Add .syso files + // TODO: is this the right way to do this? + for _, filename := range pkg.SysoFiles { + ldflags = append(ldflags, filepath.Join(pkg.Dir, filename)) + } } // Linker flags from CGo lines: diff --git a/compiler/symbol.go b/compiler/symbol.go index 93c27803e2..cf806be317 100644 --- a/compiler/symbol.go +++ b/compiler/symbol.go @@ -350,6 +350,10 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) { info.wasmModule = parts[1] info.wasmName = parts[2] case "//go:wasmexport": + if c.archFamily() != "wasm32" { + // go:wasmimport is ignored on non-wasm architectures + continue + } if f.Blocks == nil { c.addError(f.Pos(), "can only use //go:wasmexport on definitions") continue @@ -367,9 +371,6 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) { c.addError(f.Pos(), fmt.Sprintf("//go:wasmexport does not allow main.main to be exported with -buildmode=%s", c.BuildMode)) continue } - if c.archFamily() != "wasm32" { - c.addError(f.Pos(), "//go:wasmexport is only supported on wasm") - } c.checkWasmImportExport(f, comment.Text) info.wasmExport = name info.wasmExportPos = comment.Slash diff --git a/loader/loader.go b/loader/loader.go index e935a9de3a..f14e43e019 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -60,9 +60,10 @@ type PackageJSON struct { } // Source files - GoFiles []string - CgoFiles []string - CFiles []string + GoFiles []string + CgoFiles []string + CFiles []string + SysoFiles []string // Embedded files EmbedFiles []string