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

runtime/cgo: -Werror=sign-compare prevents cross-compilation to Windows #27186

Closed
BenLubar opened this issue Aug 23, 2018 · 1 comment
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@BenLubar
Copy link

Please answer these questions before submitting your issue. Thanks!

What did you do?

Compile a package that uses cgo with GOOS=windows set.

For example:

cat > foo.go <<EOF
package main
  
import "C"

func main() {
}
EOF

GOOS=windows go build foo.go

What did you expect to see?

No output, an exe file is produced.

What did you see instead?

# runtime/cgo
gcc_libinit_windows.c: In function ‘void x_cgo_sys_thread_create(void (*)(void*), void*)’:
gcc_libinit_windows.c:57:13: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
  if(thandle == -1) {
     ~~~~~~~~^~~~~
cc1plus: all warnings being treated as errors

System details

go version go1.10.3 linux/amd64
GOARCH="amd64"
GOBIN="/home/ben/go/bin"
GOCACHE="/home/ben/.cache/go-build"
GOEXE=".exe"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="windows"
GOPATH="/home/ben/.golang-path:/home/ben/go"
GORACE=""
GOROOT="/home/ben/.gimme/versions/go1.10.3.linux.amd64"
GOTMPDIR=""
GOTOOLDIR="/home/ben/.gimme/versions/go1.10.3.linux.amd64/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="x86_64-w64-mingw32-g++"
CXX="x86_64-w64-mingw32-g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build105141075=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.10.3 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.10.3
uname -sr: Linux 4.15.0-32-generic
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.27-3ubuntu1) stable release version 2.27.
gdb --version: GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
x86_64-w64-mingw32-gcc (GCC) 7.3-posix 20180312
x86_64-w64-mingw32-g++ (GCC) 7.3-posix 20180312
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 23, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Aug 23, 2018
@BenLubar
Copy link
Author

Ah, it appears I accidentally set the C compiler to g++. It works with the C compiler set to gcc.

@golang golang locked and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants