Skip to content

Commit

Permalink
builder, loader: link .syso files in Go package directories
Browse files Browse the repository at this point in the history
Among other things, this enables WebAssembly programs to link in custom sections,
which can be stored in a relocatable wasm module with a .syso suffix in a package directory.

This will simplify the build process for WASI 0.2, removing the need to run
'wasm-tools component embed' with the original source WIT files.
  • Loading branch information
ydnar committed Nov 11, 2024
1 parent c728e03 commit abaadef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,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 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

0 comments on commit abaadef

Please sign in to comment.