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: add compiler-rt and wasm symbols to table #3844

Merged
merged 1 commit into from
Jul 31, 2023
Merged
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
20 changes: 19 additions & 1 deletion builder/ar.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"time"

wasm "github.com/aykevl/go-wasm"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the package is already named "wasm", so this would be fine:

Suggested change
wasm "github.com/aykevl/go-wasm"
"github.com/aykevl/go-wasm"

(Many people think the directory name is used, but that's not true: the name from package wasm is used).

"github.com/blakesmith/ar"
)

Expand Down Expand Up @@ -74,8 +75,25 @@ func makeArchive(arfile *os.File, objs []string) error {
fileIndex int
}{symbol.Name, i})
}
} else if dbg, err := wasm.Parse(objfile); err == nil {
for _, s := range dbg.Sections {
switch section := s.(type) {
case *wasm.SectionImport:
for _, ln := range section.Entries {

if ln.Kind != wasm.ExtKindFunction {
// Not a function
continue
}
symbolTable = append(symbolTable, struct {
name string
fileIndex int
}{ln.Field, i})
}
}
}
} else {
return fmt.Errorf("failed to open file %s as ELF or PE/COFF: %w", objpath, err)
return fmt.Errorf("failed to open file %s as WASM, ELF or PE/COFF: %w", objpath, err)
}

// Close file, to avoid issues with too many open files (especially on
Expand Down
1 change: 1 addition & 0 deletions targets/wasi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"goarch": "arm",
"linker": "wasm-ld",
"libc": "wasi-libc",
"rtlib": "compiler-rt",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now I realize this probably needs to be added to targets/wasm.json too. Feel free to make a new PR if you'd like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New PR for wasm.json #3848

"scheduler": "asyncify",
"default-stack-size": 16384,
"cflags": [
Expand Down
Loading