bazel-contrib / bazel-contrib/rules_go
Cgo errors building standard library on Windows with mingw
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 762
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
Originally reported by @Xjs in [#1676](https://github.com/bazelbuild/rules_go/issues/1676#issuecomment-415036003).
------
Somewhat related (?): building the same repository with --compiler=mingw-gcc like @jayconrod documented in https://github.com/bazelbuild/rules_go/issues/1613 fails with some C compiler errors:
```
(15:41:48) ERROR: C:/tmp/_bazel_jannis.schnitzer/47bkkx3e/external/io_bazel_rules_go/BUILD.bazel:8:1: Couldn't build file external/io_bazel_rules_go/linux_amd64_stripped/stdlib%/pkg: GoStdlib external/io_bazel_rules_go/linux_amd64_stripped/stdlib%/pkg failed (Exit 1): stdlib.exe failed: error executing command
cd C:/tmp/_bazel_jannis.schnitzer/47bkkx3e/execroot/com_github_Xjs_proto_test
SET CC=c:/tools/msys64/mingw64/bin/gcc
SET CGO_CFLAGS=
SET CGO_CPPFLAGS=
SET CGO_ENABLED=1
SET CGO_LDFLAGS=-lstdc++
SET GOARCH=amd64
SET GOOS=linux
SET GOROOT=external/go_sdk
SET GOROOT_FINAL=GOROOT
SET PATH=c:/tools/msys64/mingw64/bin
bazel-out/host/bin/external/io_bazel_rules_go/go/tools/builders/windows_amd64_stripped/stdlib.exe -sdk external/go_sdk -installsuffix linux_amd64 -out bazel-out/x64_windows-fastbuild/bin/external/io_bazel_rules_go/linux_amd64_stripped/stdlib% -filter_buildid bazel-out/host/bin/external/io_bazel_rules_go/go/tools/builders/windows_amd64_stripped/filter_buildid.exe
# runtime/cgo
gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
gcc_linux_amd64.c:62:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
sigset_t ign, oset;
^~~~~~~~
_sigset_t
gcc_linux_amd64.c:67:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
sigfillset(&ign);
^~~~~~~~~~
gcc_linux_amd64.c:62:16: error: unused variable 'oset' [-Werror=unused-variable]
sigset_t ign, oset;
^~~~
cc1.exe: all warnings being treated as errors
GoStdlib: error running subcommand: exit status 2
```
Contributor guide
Research direction
Reproduce the failure from external/io_bazel_rules_go/BUILD.bazel using --compiler=mingw-gcc and the shown standard-library command. Start with runtime/cgo/gcc_linux_amd64.c and the reported sigset_t and sigfillset errors; done means the Go standard library builds successfully on Windows with mingw.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, go
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100