Thanks to visit codestin.com
Credit goes to github.com

Skip to content

internal/poll: fails to build on Windows #688

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

Open
lifeng1992 opened this issue Aug 27, 2017 · 20 comments
Open

internal/poll: fails to build on Windows #688

lifeng1992 opened this issue Aug 27, 2017 · 20 comments

Comments

@lifeng1992
Copy link

What version of Go are you using (go version)?

go version go1.9 windows/amd64

What version of GopherJS are you using ?

GopherJS 1.9-1

What did you do?

cat src/hello/main.go

package main

import (
        "github.com/gopherjs/gopherjs/js"
        "fmt"
)

func SayHello(name string) string {
	fmt.Println("Hello", name)
        return "Hello " + name
}

func main() {
        js.Module.Get("exports").Set("SayHello", SayHello)
}

gopherjs build hello/main.go

What did you expect to see?

No errors

What did you see instead?

..\..\..\..\..\..\Go\src\internal\poll\fd_windows.go:367:22: invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx
..\..\..\..\..\..\Go\src\internal\poll\fd_windows.go:368:22: invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx
..\..\..\..\..\..\Go\src\internal\poll\fd_windows.go:157:5: invalid operation: o.fd.pd (variable of type pollDesc) has no field or method runtimeCtx

I think the bug is caused by commit 956dce4

@dmitshur
Copy link
Member

dmitshur commented Aug 27, 2017

Thanks a lot for this excellent bug report, @lifeng1992.

It looks like GopherJS 1.9-1 is not working with GOOS=windows. I only tested it on macOS.

In the meantime, can you try a work around of cross compiling for macOS or Linux? E.g.:

GOOS=darwin gopherjs build hello/main.go

I will work on fixing the bug soon.

@dmitshur
Copy link
Member

I can reproduce locally on macOS:

$ GOOS=windows gopherjs run main.go 
../../../../../../../../../../../usr/local/go/src/internal/poll/fd_windows.go:367:22: invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx
../../../../../../../../../../../usr/local/go/src/internal/poll/fd_windows.go:368:22: invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx
../../../../../../../../../../../usr/local/go/src/internal/poll/fd_windows.go:157:5: invalid operation: o.fd.pd (variable of type pollDesc) has no field or method runtimeCtx

@myitcv
Copy link
Member

myitcv commented Aug 27, 2017

@shurcooL presumably we can add a cross compile for Windows to the CI build matrix to help catch these?

@dmitshur
Copy link
Member

dmitshur commented Aug 27, 2017

Yes. (It would be an additional workload.)

We can also reconsider the decision of supporting multiple GOOS values instead of having gopherjs always use a fixed one (such as GOOS=linux). I'm still not convinced that the benefits justify the disadvantages (edit: I forgot one of the benefits is being able to use syscall module, that's quite important).

@joeblew99
Copy link

fails for me too on win10 too btw.

@dmitshur
Copy link
Member

dmitshur commented Sep 6, 2017

I will work on fixing the bug soon.

Okay, I investigated this and posted #693. My original plan to resolve this issue was to make gopherjs always build for the same supported GOOS value. That way, I could fix Windows without actually having to use it.

Unfortunately, that proposal won't work exactly as I imagined it (a 2 line PR), and fixing Windows support is going to be more work.

I can't afford to spend time on supporting Windows now, so I won't be actively working on this.

You can either continue to use GOOS=darwin gopherjs build, etc., for building JavaScript for running in the browser, or use a supported OS (perhaps in a VM). Or maybe someone else will want to work on fixing Windows. Sorry about the inconvenience.

@dmitshur dmitshur removed their assignment Sep 6, 2017
@dmitshur dmitshur changed the title invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx internal/poll: fails to build on Windows Sep 6, 2017
@pbrown12303
Copy link

Wow! Is this an official announcement that gopherjs development will not be supported on Windows?

@theclapp
Copy link

I think it's an announcement that @shurcooL won't be fixing it any time soon.

Is using GOOS=darwin gopherjs [...] problematic? I'm not currently developing on Windows.

@pbrown12303
Copy link

I just tried darwin. Though it is supposed to work (according to the documentation) I get compiler errors from gcc_darwin... - looks like some OS functions have marginally different names (e.g. the call does not have an underscore before the name and the provided function does).

@dmitshur
Copy link
Member

This is a valid issue. I'm not working on it, but anyone else who's interested can.

I get compiler errors from gcc_darwin...

Can you post exact command(s) you ran and the output you got?

@pbrown12303
Copy link

Sure. First, the environment variables:

S C:\Users\pbrow> Get-ChildItem Env: | format-list


Name  : ALLUSERSPROFILE
Value : C:\ProgramData

Name  : APPDATA
Value : C:\Users\pbrow\AppData\Roaming

Name  : CGO_ENABLED
Value : 1

Name  : CommonProgramFiles
Value : C:\Program Files\Common Files

Name  : CommonProgramFiles(x86)
Value : C:\Program Files (x86)\Common Files

Name  : CommonProgramW6432
Value : C:\Program Files\Common Files

Name  : COMPUTERNAME
Value : PCBT560

Name  : ComSpec
Value : C:\WINDOWS\system32\cmd.exe

Name  : configsetroot
Value : C:\WINDOWS\ConfigSetRoot

Name  : GOOS
Value : darwin

Name  : GOPATH
Value : C:\GoWorkspace\

Name  : GOROOT
Value : C:\Go\

Name  : HOMEDRIVE
Value : C:

Name  : HOMEPATH
Value : \Users\pbrow

Name  : LOCALAPPDATA
Value : C:\Users\pbrow\AppData\Local

Name  : LOGONSERVER
Value : \\PCBT560

Name  : NUMBER_OF_PROCESSORS
Value : 4

Name  : OneDrive
Value : C:\Users\pbrow\OneDrive

Name  : OS
Value : Windows_NT

Name  : Path
Value : C:\Program Files (x86)\RSA SecurID Token Common;C:\ProgramData\Oracle\Java\javapath;C:\Program Files
        (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32
        \Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine
        Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files
        (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine
        Components\IPT;C:\Program Files\Git\cmd;C:\Software\Qt\5.9.1\mingw53_32;C:\msys64\mingw64\bin;C:\Program
        Files\Intel\WiFi\bin\;C:\Program Files\Common
        Files\Intel\WirelessCommon\;C:\Go\bin;C:\Users\pbrow\AppData\Local\Microsoft\WindowsApps;

Name  : PATHEXT
Value : .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL

Name  : PKG_CONFIG_PATH
Value : C:\msys64\mingw64\lib\pkgconfig

Name  : PROCESSOR_ARCHITECTURE
Value : AMD64

Name  : PROCESSOR_IDENTIFIER
Value : Intel64 Family 6 Model 78 Stepping 3, GenuineIntel

Name  : PROCESSOR_LEVEL
Value : 6

Name  : PROCESSOR_REVISION
Value : 4e03

Name  : ProgramData
Value : C:\ProgramData

Name  : ProgramFiles
Value : C:\Program Files

Name  : ProgramFiles(x86)
Value : C:\Program Files (x86)

Name  : ProgramW6432
Value : C:\Program Files

Name  : PSModulePath
Value : C:\Users\pbrow\Documents\WindowsPowerShell\Modules;C:\Program
        Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

Name  : PUBLIC
Value : C:\Users\Public

Name  : QT_DIR
Value : C:\Software\Qt

Name  : QT_MSYS2
Value : true

Name  : QT_MSYS2_ARCH
Value : amd64

Name  : QT_MSYS2_DIR
Value : C:\msys64

Name  : QT_MSYS2_STATIC
Value : true

Name  : QT_VERSION
Value : 5.9.1

Name  : SESSIONNAME
Value : Console

Name  : SystemDrive
Value : C:

Name  : SystemRoot
Value : C:\WINDOWS

Name  : TEMP
Value : C:\Users\pbrow\AppData\Local\Temp

Name  : TMP
Value : C:\Users\pbrow\AppData\Local\Temp

Name  : USERDOMAIN
Value : PCBT560

Name  : USERDOMAIN_ROAMINGPROFILE
Value : PCBT560

Name  : USERNAME
Value : pbrow

Name  : USERPROFILE
Value : C:\Users\pbrow

Name  : windir
Value : C:\WINDOWS

Now the build results after creating the GOOS=darwin environment variable and cleaning my project

************  Building Go project: activeCRL  ************
  with GOPATH: C:\GoWorkspace\
>> Running: C:\Go\bin\go.exe install -v -gcflags " -N -l" github.com/pbrown12303/activeCRL/activeCRL/...
runtime/cgo
# runtime/cgo
gcc_darwin_amd64.c: In function '_cgo_sys_thread_start':
gcc_darwin_amd64.c:86:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_darwin_amd64.c:91:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_darwin_amd64.c:86:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
cc1.exe: all warnings being treated as errors
   ^^^ Terminated, exit code: 2 ^^^
************  Build terminated.  ************

@pbrown12303
Copy link

Some progress. I had CGO=1. When I removed that and set GOARCH=amd64, everything compiles. However, the tests will not execute. I get:

************  Building Go project: activeCRL  ************
  with GOPATH: C:\GoWorkspace\
>> Running: C:\Go\bin\go.exe test -v -gcflags "-N -l" github.com/pbrown12303/activeCRL/activeCRL/...
fork/exec C:\Users\pbrow\AppData\Local\Temp\go-build754112998\github.com\pbrown12303\activeCRL\activeCRL\core\_test\core.test: %1 is not a valid Win32 application.
FAIL	github.com/pbrown12303/activeCRL/activeCRL/core	0.011s
fork/exec C:\Users\pbrow\AppData\Local\Temp\go-build754112998\github.com\pbrown12303\activeCRL\activeCRL\coreFunctions\_test\coreFunctions.test: %1 is not a valid Win32 application.
FAIL	github.com/pbrown12303/activeCRL/activeCRL/coreFunctions	0.012s
fork/exec C:\Users\pbrow\AppData\Local\Temp\go-build754112998\github.com\pbrown12303\activeCRL\activeCRL\coreFunctionsUpdate\_test\coreFunctionsUpdate.test: %1 is not a valid Win32 application.
FAIL	github.com/pbrown12303/activeCRL/activeCRL/coreFunctionsUpdate	0.134s
fork/exec C:\Users\pbrow\AppData\Local\Temp\go-build754112998\github.com\pbrown12303\activeCRL\activeCRL\coreUpdate\_test\coreUpdate.test: %1 is not a valid Win32 application.
FAIL	github.com/pbrown12303/activeCRL/activeCRL/coreUpdate	0.014s
?   	github.com/pbrown12303/activeCRL/activeCRL/crlEditor	[no test files]
   ^^^ Terminated, exit code: 1 ^^^
************  Build terminated.  ************

@dmitshur
Copy link
Member

C:\Go\bin\go.exe install

Are you running go install? This issue is about gopherjs.

Let me clarify, what I said earlier is that you should use GOOS=darwin with gopherjs binary, not with go binary.

You should install gopherjs normally, without any kind of cross compilation.

@pbrown12303
Copy link

pbrown12303 commented Sep 26, 2017 via email

@dmitshur
Copy link
Member

This issue is about gopherjs compiler not working on Windows unless you specify GOOS=darwin. Since you're posting here about it, I thought that was what we were talking about.

If you're compiling things not related to GopherJS, then this issue and discussion in it is not relevant.

@pbrown12303
Copy link

I think it is relevant. The environment variable affects both normal go compiles and gopherjs. You're telling me it's OK to have an environment variable setting that has to be different (i.e. changed) every time you switch from go work to gopherjs work? Remember, we got here because the GOOS=windows is broken for gopherjs.

@dmitshur
Copy link
Member

Ok, I think I understand your issue now.

You're setting the GOOS=darwin environment variable globally, which then fixes GopherJS for you, but breaks normal Go. If you don't set it, then normal Go works, but GopherJS doesn't. Is that the issue you're having?

Setting the GOOS environment variable globally is not an ideal approach, when you run into different commands where you want to use different environment variables. I don't use Windows actively, but the last time I did, it was possible to use a bash-like shell where you could prepend environment variable assignments before executing a binary to set environment variables for that process only, like so:

$ go build
$ GOOS=darwin gopherjs build

Doing that would be my recommendation. Hopefully that helps.

@pbrown12303
Copy link

pbrown12303 commented Sep 28, 2017 via email

@dmitshur
Copy link
Member

Your suggestion will work

Good to hear.

but let's recognize that it is a work-around.

It certainly is. That's why this issue is open and has bug, NeedsFix labels.

It would be nice to fix the two underlying issues so that environments can be consistent across go and gopherjs.

It will be nice to fix this issue, but, that doesn't mean the environments can be consistent. GOOS and GOARCH environment variables are effectively arguments to the Go compiler. The GopherJS compiler also uses the GOOS environment variable in the same way. You can read more about it at https://golang.org/doc/install/source#environment.

So, you're expected to set GOOS or GOARCH as needed depending on what target you want to compile for (i.e., cross-compilation). Also see https://medium.com/@rakyll/go-1-5-cross-compilation-488092ba44ec for more information on cross-compilation.

@pbrown12303
Copy link

Sounds like it would be useful to have some gopherjs-specific environment variables that would override (if necessary) the go-specific variables, e.g. GOPHERJSOS.

dmitshur added a commit that referenced this issue Mar 16, 2018
Add instructions for what people should do when building with GopherJS
on unsupported platforms. Code generation works completely fine, but
syscalls (e.g., for gopherjs run) will only work on supported platforms.

Previously, this information was only in issues, people's heads, commit
messages, etc. It should be documented in README to provide clarity.

Rename "OS X" to "macOS", the current name of that operating system.
Rearrange sections to place more relevant information first. Mention
Linux before macOS consistently. Linux is placed first because it's open
source and more freely available than the proprietary macOS, so it's
easier to recommend it as an alternative.

Resolves #770.
Updates #776.
Updates #688.
dmitshur added a commit that referenced this issue Mar 17, 2018
Add instructions for what people should do when building with GopherJS
on unsupported platforms. Code generation works completely fine, but
syscalls (e.g., for gopherjs run) will only work on supported platforms.

Previously, this information was only in issues, people's heads, commit
messages, etc. It should be documented in README to provide clarity.

Rename "OS X" to "macOS", the current name of that operating system.
Rearrange sections to place more relevant information first. Mention
Linux before macOS consistently. Linux is placed first because it's open
source and more freely available than the proprietary macOS, so it's
easier to recommend it as an alternative.

Resolves #770.
Updates #776.
Updates #688.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants