Skip to content

Commit 2b59261

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 65b085a commit 2b59261

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

builder/build.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,12 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
711711
}
712712
linkerDependencies = append(linkerDependencies, job)
713713
}
714+
715+
// Add .syso files
716+
// TODO: is this the right way to do this?
717+
for _, filename := range pkg.SysoFiles {
718+
ldflags = append(ldflags, filepath.Join(pkg.Dir, filename))
719+
}
714720
}
715721

716722
// Linker flags from CGo lines:

loader/loader.go

Lines changed: 4 additions & 3 deletions
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)