GopherJS 1.8-wip: "warning: system calls not available" printed whenever "os" package imported. #583

Closed
shurcooL opened this Issue Feb 9, 2017 · 7 comments

Projects

None yet

2 participants

@shurcooL
Member
shurcooL commented Feb 9, 2017 edited

I've mentioned this in #552 (comment), but I've confirmed it happens in 1.8 only now.

I've investigated it and found the root cause.

image

It happens with GopherJS 1.8-wip only when "os" package is imported (not necessarily directly). That package is often imported by other packages, such as "net/http", or if you're getting os.Stdout, etc.

It happens because of Executable() addition to os package in Go 1.8.

As a result, os.Getwd() gets called as part of os package initialization:

var initCwd, initCwdErr = Getwd()

Source: https://github.com/golang/go/blob/09762ccff79ebf08839f8954ab99c17d41f071e2/src/os/executable_darwin.go#L9.

Calling os.Getwd() in browser ends up making a call to Syscall, which causes the warning to get printed to console (note that it's actually printed as an error to console).

@shurcooL
Member
shurcooL commented Feb 10, 2017 edited

There are multiple ways we can resolve this. Do you have preferences on this @neelance?

We could override Getwd on browser to return error right away, without making syscalls.

We could try to override initCwd and initCwdErr variables Getwd() never gets called, but I'm not sure if it's possible since it's single declaration for 2 variables, and the variable names are unexported, so they might change between Go versions more often... They might also have different names depending on the desktop architecture (note that the linked file is executable_darwin.go, for darwin; but there are others).

@shurcooL
Member

There are multiple ways we can resolve this. Do you have preferences on this @neelance?

Friendly ping @neelance.

@neelance
Member

What about excluding executable_darwin.go from the build?

@neelance
Member

Btw: Thanks for pinging.

@shurcooL
Member

What about excluding executable_darwin.go from the build?

note that the linked file is executable_darwin.go, for darwin; but there are others

image

There are multiple files, we'd have to exclude them all. For example, if someone uses GopherJS on Windows, their default GOOS value will be windows, and the file executable_windows.go will be used instead.

@shurcooL
Member
shurcooL commented Feb 16, 2017 edited

Although, it's worth noting executable_windows.go doesn't try to call os.Getwd. But it does import "internal/syscall/windows", which I expect would still be a bad idea in GopherJS.

@shurcooL shurcooL added a commit that referenced this issue Feb 16, 2017
@shurcooL shurcooL build, compiler/natives/src/os: Remove syscalling os.Executable imple…
…mentation.

Replace it with a not-implemented-erroring one.

This fixes the issue #583 where on darwin a call to os.Getwd is made,
which makes syscalls, and causes a warning to be printed to console:

	warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md

os.Executable is documented to be unsupported on nacl:

	// Executable is not supported on nacl or OpenBSD (unless procfs is
	// mounted.)

GOARCH=js is similar to nacl in many ways, so it's pretty expected
os.Executable wouldn't be supported here either.

Use https://github.com/golang/go/blob/990124da2a6ca5a54b38733b51018e2f8758cfae/src/os/executable_procfs.go#L21
as template for error message.

Fixes #583.
65da89e
@shurcooL
Member

This go1.8-branch-specific issue has been resolved in 65da89e, which is now a part of go1.8 branch. Closing.

@shurcooL shurcooL closed this Feb 16, 2017
@shurcooL shurcooL added a commit that referenced this issue Feb 16, 2017
@shurcooL shurcooL build, compiler/natives/src/os: Remove syscalling os.Executable imple…
…mentation.

Replace it with a not-implemented-erroring one.

This fixes the issue #583 where on darwin a call to os.Getwd is made,
which makes syscalls, and causes a warning to be printed to console:

	warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md

os.Executable is documented to be unsupported on nacl:

	// Executable is not supported on nacl or OpenBSD (unless procfs is
	// mounted.)

GOARCH=js is similar to nacl in many ways, so it's pretty expected
os.Executable wouldn't be supported here either.

Use https://github.com/golang/go/blob/990124da2a6ca5a54b38733b51018e2f8758cfae/src/os/executable_procfs.go#L21
as template for error message.

Fixes #583.
7522980
@shurcooL shurcooL added a commit that referenced this issue Feb 16, 2017
@shurcooL shurcooL build, compiler/natives/src/os: Remove syscalling os.Executable imple…
…mentation.

Replace it with a not-implemented-erroring one.

This fixes the issue #583 where on darwin a call to os.Getwd is made,
which makes syscalls, and causes a warning to be printed to console:

	warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md

os.Executable is documented to be unsupported on nacl:

	// Executable is not supported on nacl or OpenBSD (unless procfs is
	// mounted.)

GOARCH=js is similar to nacl in many ways, so it's pretty expected
os.Executable wouldn't be supported here either.

Use https://github.com/golang/go/blob/990124da2a6ca5a54b38733b51018e2f8758cfae/src/os/executable_procfs.go#L21
as template for error message.

Fixes #583.
b36bf38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment