Skip to content

Commit abaadef

Browse files
committed
builder, loader: link .syso files in Go package directories
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.
1 parent c728e03 commit abaadef

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

builder/build.go

+6
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,12 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
701701
}
702702
linkerDependencies = append(linkerDependencies, job)
703703
}
704+
705+
// Add .syso files
706+
// TODO: is this the right way to do this?
707+
for _, filename := range pkg.SysoFiles {
708+
ldflags = append(ldflags, filepath.Join(pkg.Dir, filename))
709+
}
704710
}
705711

706712
// Linker flags from CGo lines:

loader/loader.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ type PackageJSON struct {
6060
}
6161

6262
// Source files
63-
GoFiles []string
64-
CgoFiles []string
65-
CFiles []string
63+
GoFiles []string
64+
CgoFiles []string
65+
CFiles []string
66+
SysoFiles []string
6667

6768
// Embedded files
6869
EmbedFiles []string

0 commit comments

Comments
 (0)