Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: link .syso files found in Go package directories #4593

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions compiler/symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down