karalabe / hid

Gopher Interface Devices (USB HID)
Other
263 stars 131 forks source link

wchar.go:44:8: error: enumerator value for '__cgo_enum__0' is not an integer constant #2

Closed sergei-mironov closed 7 years ago

sergei-mironov commented 7 years ago

Hi. I am building the latest release of geth which depends on hid. Unfortunately, I have the topic error, more of it below. Probably, it is a build environment problem (I'm using NixOS linux distro which is quite unusual). My go is version 1.7.1. Could you please suggest a hint regarding the error?

# github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:44:8: error: enumerator value for '__cgo_enum__0' is not an integer constant
   return stringToWchar4(s) // Unix       
        ^                                 
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:52:8: error: enumerator value for '__cgo_enum__7' is not an integer constant
  case 2:                                 
        ^                                 
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:60:2: error: initializer element is not constant
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:60:2: note: (near initialization for '__cgodebug_data[0]')
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:67:2: error: initializer element is not constant
  default:                                
  ^                                       
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:67:2: note: (near initialization for '__cgodebug_data[7]')
github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid
# github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:44:8: error: enumerator value for '__cgo_enum__0' is not an integer constant
   return stringToWchar4(s) // Unix       
        ^                                 
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:52:8: error: enumerator value for '__cgo_enum__7' is not an integer constant
  case 2:                                 
        ^                                 
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:60:2: error: initializer element is not constant
go/src/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/wchar.go:60:2: note: (near initialization for '__cgodebug_data[0]')
karalabe commented 7 years ago

Could you try with updating to Go 1.8.1? These error messages seem originate from Go's compiler, not this library https://github.com/golang/go/issues/14669

sergei-mironov commented 7 years ago

I've tried go1.8 compiler (the latest available on NixOS so far). Errors are still here, but the text is a bit different. As far as I understand the golang/go#14669, one could workaround errors by passing '-O0'. I'll try to do that.

# github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid
cgo-dwarf-inference:2:8: error: enumerator value for '__cgo_enum__0' is not an integer constant
cgo-dwarf-inference:10:8: error: enumerator value for '__cgo_enum__7' is not an integer constant
cgo-dwarf-inference:18:2: error: initializer element is not constant
cgo-dwarf-inference:18:2: note: (near initialization for '__cgodebug_data[0]')
cgo-dwarf-inference:25:2: error: initializer element is not constant
cgo-dwarf-inference:25:2: note: (near initialization for '__cgodebug_data[7]')
javgh commented 7 years ago

Another NixOS user here - I also ran into this and have been attempting to debug it. It seems to be indeed unrelated to geth and a general problem with the go compiler under NixOS. I have filed a separate issue here: https://github.com/NixOS/nixpkgs/issues/25599 .

sergei-mironov commented 7 years ago

Thanks to @javagh, looks like we used gcc instead of clang. So it is really a NixOS issue. Closing this one now.

javgh commented 7 years ago

Indeed, the issue was that under NixOS the Go compiler is built using clang, but then while trying to build geth the C compiler was set to gcc. I have an updated NixOS package for geth 1.6.1 over here which works for me: https://github.com/javgh/nixpkgs/blob/master/pkgs/applications/altcoins/go-ethereum.nix . Cheers!

aaronlevin commented 7 years ago

I just wanted to pop in to say I'm seeing this too (via Nix) and this was a hard issue to track down.

javgh commented 7 years ago

Just as a FYI: The original guess regarding the compiler mixup was actually incorrect. Everything is built using gcc by default on Nix - including the Go compiler. Switching to clang still helps though as a workaround. The root cause is still unsolved though, as far as I know. This is the most recent issue about it: https://github.com/NixOS/nixpkgs/issues/25959 .