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

Not working on Windows 10. #736

Closed
abergmeier-dsfishlabs opened this issue Aug 17, 2017 · 57 comments
Closed

Not working on Windows 10. #736

abergmeier-dsfishlabs opened this issue Aug 17, 2017 · 57 comments
Assignees

Comments

@abergmeier-dsfishlabs
Copy link

When trying to use go_binary on Windows I get:

ERROR: C:/projects/bazel_go_cas/BUILD.bazel:6:1: every rule of type go_binary implicitly depends upon the target '@io_bazel_rules_go_toolchain//:go_toolchain', but this target could not be found because of: no such package '@io_bazel_rules_go_toolchain//': Unsupported operating system: windows 10.
@jayconrod
Copy link
Contributor

Unfortunately, we don't support Windows builds yet, but we hope to add support soon.

The logic for this is in go/private/repository_tools.bzl if you want to experiment with this sooner.

@ianthehat
Copy link
Contributor

I have done most of the work that I can to get us to the point where we could support windows, and I would like to finish it, but I don't currently have a windows machine to finish it on. It should be really easy (less than a day of effort) to get the core rules working.
The only remaining issue should be things that are not expecting executables to end in .exe (the main toolchain sdk build file probably needs to be either select or glob to pick up the tools), we have purged all the uses of bash that would have caused issues.
Of course you never really know what else there is until you try it...

@Xjs
Copy link
Contributor

Xjs commented Sep 4, 2017

@ianthehat I would be interested in testing and possibly contributing in order to make the Go rules (and, if possible, gazelle) work on Windows 10. How can I help?

@ianthehat
Copy link
Contributor

Run a build on a windows machine and tell me what does not work :)
The first thing you will hit is "Unsupported operating system:" from repository_tools.bzl, it will need another else for windows, but I don't know what the ctx.os.name will report, which is why I have not added it.
The next thing you will hit is that the sdk rules assume the go binary name don't have an extension, on windows it will need .exe added. This means changing line 12 of BUILD.sdk.bazel to something like srcs = [ "bin/go{exe_ext}" ], and then adding another substitution in [toolchain.bzl] (/bazelbuild/rules_go/blob/master/go/private/toolchain.bzl#L73) to add it. It would be based on the based on the host os, just like the repository_tools sdk choice.
After that, it might all just work...

If you are not confident trying to make those changes, try a build and tell me the error message (it will say what the host os is reported as) and then I can make a PR for you to try.

@Xjs
Copy link
Contributor

Xjs commented Sep 5, 2017

I added those changes and a few more that I found necessary while experimenting. I've reached the point where gazelle can be built, but I get the error message

ERROR: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go/go/tools/gazelle/rules/BUILD.bazel:3:1:
    no such package '@org_golang_x_tools//go/vcs':
        Not a file: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go_repository_tools/bin/gazelle
        and referenced by '@io_bazel_rules_go//go/tools/gazelle/rules:go_default_library'.

(the "Not a file" error is an indicator for a missing .exe somewhere), but I haven't been confident on where to add .exe for the gazelle binary. Could you give me a hint there?

@ianthehat
Copy link
Contributor

There are two places, one for fetch_repo and one for gazelle
At the moment that file is not configurable, you will need to add a .format to the place it is written.

@Xjs
Copy link
Contributor

Xjs commented Sep 6, 2017

I added the extension in those places, but still it tries to call gazelle without .exe. cf. 87d000c Where else could I look? What could I do to debug?

@ianthehat
Copy link
Contributor

It's because go_repository is doing it wrong, if you look here and here it is using the filename directly rather than depending on the file group to decouple it from the actual name.

@abergmeier-dsfishlabs
Copy link
Author

It's because go_repository is doing it wrong, if you look here and here it is using the filename directly rather than depending on the file group to decouple it from the actual name.

This could be due to the limitation of Bazel that you currently can only reference source targets from Repository rules. Not sure whether filegroups work. Maybe @damienmg can clarify and prioritize.

@ianthehat
Copy link
Contributor

Yes, sorry, I was not clear. The go_repository rule is deliberately doing it wrong because it is not possible to do it right, as you can't get the outputs of a filegroup during repository rules, we would need to either be able to iterate a filegroup or have repository_ctx.path be able to understand a filegroup with a single entry.

@Xjs
Copy link
Contributor

Xjs commented Sep 6, 2017

I encountered this problem as well. Is there a way to do a OS check in go_repository.bzl as well for the labels for _fetch_repo and _gazelle? All my attempts so far have failed. (Adding .exe manually at least helps executing the binaries, which leads to different problems. More about that tomorrow... ;))

@ianthehat
Copy link
Contributor

You could try doing this
It drops the hidden attributes (no point on repository rules anyway, they can pick at labels directly all they want)

@Xjs
Copy link
Contributor

Xjs commented Sep 7, 2017

That works in fact. Thanks so far. Now the gazelle binary is actually executed. :)
The first problem I encounter now is Gazelle trying to compare a path like C:/foo/bar to a path like C:\foo\bar, and of course failing. I guess I'll find a remedy for that, though.

@Xjs
Copy link
Contributor

Xjs commented Sep 7, 2017

I fixed the aforementioned problem. Now gazelle is executed properly. When building though, there's another error, which appears to come from the buildtools.

  bazel-out/host/bin/external/io_bazel_rules_go/go/tools/builders/compile external/go1_9_windows_amd64/bin/go.exe -src external/com_github_bazelbuild_buildtools/differ/diff.go -src external/com_github_bazelbuild_buildtools/differ/isatty_other.go -o bazel-out/host/bin/external/com_github_bazelbuild_buildtools/differ/~normal~go_default_library~/github.com/bazelbuild/buildtools/differ.a -trimpath . -I . --.
external/com_github_bazelbuild_buildtools/differ/diff.go:105:5: undefined: isatty
external/com_github_bazelbuild_buildtools/differ/diff.go:109:18: undefined: isatty
2017/09/07 12:19:28 error running compiler: exit status 1

Could that be a problem in the go rules, or should I rather report it to buildtools?

@jayconrod
Copy link
Contributor

@Xjs that error is in buildtools. It looks like they already have a stub implementation for Windows, but it's not included in their BUILD.bazel. Re-running Gazelle there should fix it.

@Xjs
Copy link
Contributor

Xjs commented Sep 8, 2017

In order to get a step further, I created a fork of buildtools which works on Windows, and referenced it in repositories.bzl. Now I get a little farther, but now I end up with this error:

$ bazel run -s --logging 6 --verbose_failures //:gazelle
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go/go/def.bzl:179:3: DEPRECATED: go_repositories has been deprecated. go_rules_dependencies installs dependencies the way nested workspaces should, and go_register_toolchains adds the toolchains.
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.
.
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables,eg. VS140COMNTOOLS
.
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for Visual C++ through registry
.
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Visual C++ build tools found at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\\VC
.
____Loading complete.  Analyzing...
____Found 1 target...
____Building...
Target //:gazelle up-to-date:
  C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/gazelle_script.bash
  C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/gazelle
  C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/gazelle.exe
____Elapsed time: 0,871s, Critical Path: 0,01s

____Running command line: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/gazelle.exe
LAUNCHER ERROR: Rlocation failed on bazel-out/msvc_x64-fastbuild/bin/gazelle_script.bash, path doesn't exist in MANIFEST file
ERROR: Non-zero return code '1' from command: Process exited with status 1.

The mentioned MANIFEST file contains the following:

__main__/external/io_bazel_rules_go/go/tools/gazelle/gazelle/gazelle C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/host/bin/external/io_bazel_rules_go/go/tools/gazelle/gazelle/gazelle
__main__/gazelle C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/gazelle
__main__/gazelle.exe C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/gazelle.exe
__main__/gazelle_script.bash C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/gazelle_script.bash
__main__/WORKSPACE C:/users/jannis.schnitzer/src/gogs.edg.ag/jannis.schnitzer/handlungsempfehlungen/WORKSPACE
io_bazel_rules_go/go/tools/gazelle/gazelle/gazelle C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/host/bin/external/io_bazel_rules_go/go/tools/gazelle/gazelle/gazelle

It appears the keys in the MANIFEST file (in this case __main__/gazelle_script.bash) don't match the queried one bazel-out/msvc_x64-fastbuild/bin/gazelle_script.bash. Do you happen to know where the MANIFEST file is generated or where the launcher comes into play and why the paths don't fit? Could it be a problem with gazelle? The gazelle_script.bash file is referenced in go/private/tools/gazelle.bzl, but I don't know enough about the bazel launcher to understand if the problem could lie there. Maybe somebody can shed some light.

@ianthehat
Copy link
Contributor

if you do

bazel run @io_bazel_rules_go//:go_info

does it work and what does it say?

@ianthehat
Copy link
Contributor

Seems similar to, but not the same as bazelbuild/bazel#3620

@Xjs
Copy link
Contributor

Xjs commented Sep 8, 2017

Doesn't work out of the box, following error:

$ bazel run @io_bazel_rules_go//:go_info
..........
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go/go/def.bzl:179:3: DEPRECATED: go_repositories has been deprecated. go_rules_dependencies installs dependencies the way nested workspaces should, and go_register_toolchains adds the toolchains.
____Loading package: @io_bazel_rules_go//
____Loading package: @bazel_tools//tools/cpp
____Loading package: @bazel_tools//tools/jdk
____Loading package: @local_config_xcode//
____Loading package: @local_config_cc//
____Loading package: @local_jdk//
____Loading complete.  Analyzing...
____Loading package: @io_bazel_rules_go//go/toolchain
____Loading package: @io_bazel_rules_go//go/private
ERROR: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go/BUILD.bazel:55:1: in _go_info_script rule @io_bazel_rules_go//:go_info_script:
Traceback (most recent call last):
        File "C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go/BUILD.bazel", line 55
                _go_info_script(name = 'go_info_script')
        File "C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go/go/private/info.bzl", line 3, in _go_info_script_impl
                "\n".join((["export {}=\"{}\"".format(key,...")]))
        File "C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go/go/private/info.bzl", line 4, in "\n".join
                go_toolchain.go
'ToolchainInfo' object has no attribute 'go'
Available attributes: actions, data, env, external_linker, flags, name, paths, sdk, tools.
ERROR: Analysis of target '@io_bazel_rules_go//:go_info' failed; build aborted.
____Elapsed time: 3,695s
ERROR: Build failed. Not running target.

I can't look into it right now, but I can have a closer look on Monday.

@ianthehat
Copy link
Contributor

Sorry, I broke it with the toolchain changes, fixed in #817 and has a test now.

@Xjs
Copy link
Contributor

Xjs commented Sep 11, 2017

I tried again with 4781bcc, and now I get the same "Rlocation failed" error as with gazelle before:

$ bazel run @io_bazel_rules_go//:go_info
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/io_bazel_rules_go/go/def.bzl:179:3: DEPRECATED: go_repositories has been deprecated. go_rules_dependencies installs dependencies the way nested workspaces should, and go_register_toolchains adds the toolchains.
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.
.
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables,eg. VS140COMNTOOLS
.
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for Visual C++ through registry
.
WARNING: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Visual C++ build tools found at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\\VC
.
____Loading complete.  Analyzing...
____Found 1 target...
____Building...
Target @io_bazel_rules_go//:go_info up-to-date:
  C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/external/io_bazel_rules_go/go_info_script.bash
  C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/external/io_bazel_rules_go/go_info
  C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/external/io_bazel_rules_go/go_info.exe
____Elapsed time: 0,612s, Critical Path: 0,01s

____Running command line: C:/users/jannis.schnitzer/appdata/local/temp/_bazel_jannis.schnitzer/-oa-lc3d/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/external/io_bazel_rules_go/go_info.exe
LAUNCHER ERROR: Rlocation failed on bazel-out/msvc_x64-fastbuild/bin/external/io_bazel_rules_go/go_info_script.bash, path doesn't exist in MANIFEST file
ERROR: Non-zero return code '1' from command: Process exited with status 1.

@ianthehat
Copy link
Contributor

I am working on a Windows laptop for a couple of days, if you want to put up what you have so far in a PR, I can see what I can do with it

@Xjs
Copy link
Contributor

Xjs commented Sep 12, 2017

Thanks. :) #821.

@Xjs
Copy link
Contributor

Xjs commented Sep 18, 2017

@ianthehat I saw you merged analogous fixes to my PR. Have you made any progress so far? Is there anything else I can do to help?

@ianthehat
Copy link
Contributor

I also had to do this in order to get anything to work on the laptop I was working on, but there seem to be many possible values for cpu that represent windows, which is going to make this hard.

With this, I managed to build a pure go binary, but cgo was not working. If you want to try it (possibly with the change shown above) and let me know what it's doing now...

I now have a windows laptop assigned to me so I can keep working on this, but right now it is behaving very differently to the other windows laptop I was workign on, so I am trying to work out why.

@Xjs
Copy link
Contributor

Xjs commented Sep 21, 2017

I'm quite at loss here -- I created a Hyper-V VM with Windows 10 (Enterprise evaluation edition from TechNet) in order to have an as clean installation as possible. Installed chocolatey, chocolatey-installed git and bazel, cloned a small (testing) go repository and added a WORKSPACE and a BUILD.bazel as in the README file, referencing my local clone that's on the state of b3b0d1e plus my custom buildtools modification. Now I get a slightly different error message whose origin I can't seem to find:

PS ...\test> bazel run //:gazelle --logging 6 -s --verbose_failures
.............
WARNING: C:/users/jannis/appdata/local/temp/_bazel_jannis/z6cgbkoo/external/io_bazel_rules_go/go/def.bzl:182:3: DEPRECATED: go_repositories has been deprecated. go_rules_dependencies installs dependencies the way nested workspaces should, and go_register_toolchains adds the toolchains.
WARNING: C:/users/jannis/appdata/local/temp/_bazel_jannis/z6cgbkoo/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.
.
WARNING: C:/users/jannis/appdata/local/temp/_bazel_jannis/z6cgbkoo/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables,eg. VS140COMNTOOLS
.
WARNING: C:/users/jannis/appdata/local/temp/_bazel_jannis/z6cgbkoo/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for Visual C++ through registry
.
WARNING: C:/users/jannis/appdata/local/temp/_bazel_jannis/z6cgbkoo/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Visual C++ build tools found at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\\VC
.
ERROR: C:/users/jannis/appdata/local/temp/_bazel_jannis/z6cgbkoo/external/io_bazel_rules_go/go/tools/gazelle/resolve/BUILD.bazel:3:1:
    no such package '@org_golang_x_tools//go/vcs': no such package '@io_bazel_rules_go_repository_tools//':
    failed to build gazelle: java.io.IOException: CreateProcess(): Das System kann die angegebene Datei nicht finden.
    #### translation: "The system couldn't find the given file."
 and referenced by '@io_bazel_rules_go//go/tools/gazelle/resolve:go_default_library'.
ERROR: Analysis of target '//:gazelle' failed; build aborted.
INFO: Elapsed time: 111,317s
ERROR: Build failed. Not running target.
PS ...\test>

@filipesilva
Copy link
Contributor

I just tried with 0.8.0 and it seems like the go toolchain is still trying to use C:\Windows:

kamik@T460p MINGW64 D:/sandbox/rules_typescript_2 (master)
$ bazel version
Build label: 0.8.0
Build target: bazel-out/msvc_x64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Nov 27 13:18:30 2017 (1511788710)
Build timestamp: 1511788710
Build timestamp as int: 1511788710

kamik@T460p MINGW64 D:/sandbox/rules_typescript_2 (master)
$ bazel build ...
DEBUG: C:/users/kamik/appdata/local/temp/_bazel_kamik/5xzmk4di/external/io_bazel_rules_go/go/private/toolchain.bzl:104:5: mkdir C:\WINDOWS\go-build894015291: Access is denied.
ERROR: C:/users/kamik/appdata/local/temp/_bazel_kamik/5xzmk4di/external/io_bazel_rules_go/go/toolchain/BUILD.bazel:6:1: every rule of type _go_toolchain implicitly depends upon the target '@go_sdk//:packages.txt', but this target could not be found because of: no such package '@go_sdk//': Traceback (most recent call last):
        File "C:/users/kamik/appdata/local/temp/_bazel_kamik/5xzmk4di/external/io_bazel_rules_go/go/private/toolchain.bzl", line 45
                _prepare(ctx)
        File "C:/users/kamik/appdata/local/temp/_bazel_kamik/5xzmk4di/external/io_bazel_rules_go/go/private/toolchain.bzl", line 105, in _prepare
                fail("failed to list standard package...")
failed to list standard packages
ERROR: Analysis of target '//internal/devserver/main:main' failed; build aborted: no such package '@go_sdk//': Traceback (most recent call last):
        File "C:/users/kamik/appdata/local/temp/_bazel_kamik/5xzmk4di/external/io_bazel_rules_go/go/private/toolchain.bzl", line 45
                _prepare(ctx)
        File "C:/users/kamik/appdata/local/temp/_bazel_kamik/5xzmk4di/external/io_bazel_rules_go/go/private/toolchain.bzl", line 105, in _prepare
                fail("failed to list standard package...")
failed to list standard packages
INFO: Elapsed time: 119.614s
FAILED: Build did NOT complete successfully (43 packages loaded)

@droyo
Copy link

droyo commented Dec 8, 2017

Hey, I have an interest in getting this working. I want to use bazel to build a cross-platform game. @filipesilva, I believe @dslomov was referencing 0.8.0 of rules_go, and you're showing 0.8.0 of bazel :).

I no longer experience the C:\WINDOWS tmpdir issue with 0.8.0. I'm now trying to build a package that uses cgo. Following https://docs.bazel.build/versions/master/windows.html#build-c , I set BAZEL_VC and BAZEL_VS like so (using powershell):

$Env:BAZEL_VS="C:\Program Files (x86)\Microsoft Visual Studio 14.0"
$Env:BAZEL_VC="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"

but when building my package, I'm hit with this:

ERROR: C:/users/droyo/appdata/local/temp/_bazel_droyo/_upsbte4/external/go_stdlib_windows_amd64_cgo/BUILD.bazel:4:1: error executing shell command: 'export GOROOT=$(pwd)/bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools...' failed (Exit 1)
/usr/bin/bash: -c: line 0: syntax error near unexpected token `('
/usr/bin/bash: -c: line 0: `export GOROOT=$(pwd)/bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/HostX64/x64/cl.exe CXX=$(pwd)/C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/HostX64/x64/cl.exe COMPILER_PATH=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/HostX64/x64 && mkdir -p bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/src && mkdir -p bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/pkg && cp external/go_sdk//bin/go bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/bin/go && cp -rf external/go_sdk//src/* bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/src/ && cp -rf external/go_sdk//pkg/tool bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/pkg/ && cp -rf external/go_sdk//pkg/include bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/pkg/ && bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/bin/go install  std && bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/bin/go install  runtime/cgo'

The problem seems to be in stdlib.bzl, since "C:\Windows..." doesn't start with "/"

@droyo
Copy link

droyo commented Dec 8, 2017

I followed some of the advice in #1007 (comment);

mklink /d C:\MSVS "C:\Program Files (x86)\Microsoft Visual Studio 14.0"
mklink /d C:\MSVC "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"

Now I can get further, actually invoking the C compiler:

INFO: Found 1 target...
ERROR: C:/users/droyo/appdata/local/temp/_bazel_droyo/_upsbte4/external/go_stdlib_windows_amd64_cgo/BUILD.bazel:4:1: error executing shell command: 'export GOROOT=$(pwd)/bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=C:/MSVC/2017/Community/VC/Tools/MSVC/14.12.25827/bin/HostX64/x64/cl.exe CXX=C...' failed (Exit 2)
# runtime/cgo
Microsoft (R) C/C++ Optimizing Compiler Version 19.12.25830.2 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line error D8021 : invalid numeric argument '/Werror'

@dslomov
Copy link

dslomov commented Dec 11, 2017

No I meant 0.8.0 of Bazel.
@droyo do you think you can put up a PR to fix stdlib.bzl issue?
@ianthehat /Werror problem seems to be inside rules_go, do you think you'll have cycles to take a look?

@ianthehat
Copy link
Contributor

I am fixing things that will help, as they relate to other bugs (the way we depend on stdlib and the way it gets compiled), and hoping to get back to fixing windows before christmas (as soon as cross compiling cgo is working)
The go rules do not set /Werror, it's probably coming from inside the go build toolchain when it invokes the compiler directly, I don't think it has any support for working with the cl.exe, it only supports a gcc based toolchain. I don't believe there is any hope of this working in the near future, even if we made this step work, it would not be able to link the resulting obj file. This is a fundamental limitation of the way the cgo and go linker tools work.
Is there any support for using a gcc based toolchain in Bazel on windows?

@laszlocsomor
Copy link
Contributor

Is there any support for using a gcc based toolchain in Bazel on windows?

Sure, --cpu=x64_windows_msys already uses GCC in MSYS on Windows, though with the caveat that this GCC links to the MSYS DLL.
FYI @meteorcloudy

@meteorcloudy
Copy link
Member

Yes, you can try the GCC toolchain within MSYS by adding --cpu=x64_windows_msys as a build option.
But I'm not sure it works exactly like Linux, especially on linking dynamic library.

@Xjs
Copy link
Contributor

Xjs commented Dec 15, 2017

Relating to #1007 (comment) also -- I seem not yet to be getting gcc to work on Windows. The error I mentioned in #1007 occurs with --cpu=x64_windows_msys as well. What else would I need to use gcc instead of cl.exe from within MSYS?

@droyo
Copy link

droyo commented Dec 18, 2017

@dslomov opened PR #1149 , I'm not very happy with it but it got me further.

Understood on restriction to GCC, that's fine by me. I've been plugging away, here are some of the outstanding issues I have:

  • When following the windows installation instructions for bazel, the env executable is not in my PATH. So the env_execute helper function fails with java.io.IOException: ERROR: src/main/native/windows/processes-jni.cc(410): nativeCreateProcess(env): The system cannot find the file specified. I work around that by using ctx.execute's environment parameter instead (what's the point of env_execute?)

  • I'm getting inconsistent C compiler choices between runs. Sometimes it tries to use cl.exe (even with --cpu=x64_windows_msys), sometimes it tries to use gcc. I don't know why, yet, and I can't tell if it's just building targets in a different order each time.

  • When I do get a run using gcc, it gets pretty far, then fails with this:

      C:/msys64/usr/bin/bash.exe -c export GOROOT=$(pwd)/bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo && mkdir -p bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo/src && mkdir -p bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo/pkg && cp external/go_sdk//bin/go bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo/bin/go && cp -rf external/go_sdk//src/* bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo/src/ && cp -rf external/go_sdk//pkg/tool bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo/pkg/ && cp -rf external/go_sdk//pkg/include bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo/pkg/ && bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo/bin/go install  std && bazel-out/x64_windows_msys-fastbuild/bin/external/go_stdlib_windows_amd64_cgo/bin/go install  runtime/cgo
      # runtime/cgo
      gcc: error: \" -I $WORK\runtime\cgo\_obj\ -g -O2 -Wall -Werror -I . C:\users\droyo\appdata\local\temp\_bazel_droyo\_upsbte4\execroot\__main__\tmp57d_3bd920b75bc7a07e\cgo-gcc-input-910226015.c: No such file or directory
      gcc: fatal error: no input files
      compilation terminated.
    

@meteorcloudy
Copy link
Member

You probably need to pass --host_cpu=x64_windows_msys, otherwise, Bazel still uses cl.exe for host build.

@Xjs
Copy link
Contributor

Xjs commented Dec 19, 2017

An update from me: I tried with HEAD (329d8f4) and got through to the invocation of gcc with bazel build --cpu=x64_windows_msys --host_cpu=x64_windows_msys bazel_test_cmd --verbose_failures -- but I can't make any sense out of this error message:

C:/tools/msys64/usr/lib/gcc/x86_64-pc-msys/6.3.0/cc1.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

Any ideas as to where the question mark comes from?

Full output:

jannis.schnitzer@jannis-desktop bazel_test $ bazel build --cpu=x64_windows_msys --host_cpu=x64_windows_msys bazel_test_cmd --verbose_failures
Extracting Bazel installation...
............
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading:
Analyzing: target //:bazel_test_cmd (4 packages loaded)
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables,eg. VS140COMNTOOLS
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for Visual C++ through registry
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Visual C++ build tools found at C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\\VC
Analyzing: target //:bazel_test_cmd (6 packages loaded)
Analyzing: target //:bazel_test_cmd (30 packages loaded)
Analyzing: target //:bazel_test_cmd (163 packages loaded)
Analyzing: target //:bazel_test_cmd (163 packages loaded)
Analyzing: target //:bazel_test_cmd (163 packages loaded)
Analyzing: target //:bazel_test_cmd (163 packages loaded)
INFO: Analysed target //:bazel_test_cmd (167 packages loaded).
INFO: Found 1 target...
[0 / 6] BazelWorkspaceStatusAction stable-status.txt
[4 / 13] GoStdlib external/go_stdlib_windows_amd64_cgo/bin/go.exe; 10s local ... (2 actions running)
[4 / 13] GoStdlib external/go_stdlib_windows_amd64_cgo/bin/go.exe; 40s local ... (2 actions running)
ERROR: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/go_stdlib_windows_amd64_cgo/BUILD.bazel:4:1: error executing shell command: 'export GOROOT="$(pwd)/bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo" GOOS="windows" GOARCH="amd64" CGO_ENABLED="1" CC="C:/tools/msys64/usr/bin/gcc" CXX="C:/tools/msys64/usr/bin/gcc" COMPI...' failed (Exit 2): zsh failed: error executing command
  cd C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/execroot/__main__
C:/tools/msys64/usr/bin/zsh -c export GOROOT="$(pwd)/bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo" GOOS="windows" GOARCH="amd64" CGO_ENABLED="1" CC="C:/tools/msys64/usr/bin/gcc" CXX="C:/tools/msys64/usr/bin/gcc" COMPILER_PATH="C:/tools/msys64/usr/bin" CGO_CPPFLAGS="" CGO_LDFLAGS="-lstdc++" && mkdir -p bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/src && mkdir -p bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/pkg && cp external/go_sdk/bin/go.exe bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/bin/go.exe && cp -rf external/go_sdk/src/* bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/src/ && cp -rf external/go_sdk/pkg/tool bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/pkg/ && cp -rf external/go_sdk/pkg/include bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/pkg/ && bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/bin/go.exe install  std && bazel-out/host/bin/external/go_stdlib_windows_amd64_cgo/bin/go.exe install  runtime/cgo
# runtime/cgo
C:/tools/msys64/usr/lib/gcc/x86_64-pc-msys/6.3.0/cc1.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
Target //:bazel_test_cmd failed to build
INFO: Elapsed time: 137,123s, Critical Path: 54,44s
FAILED: Build did NOT complete successfully

@ianthehat
Copy link
Contributor

We are getting there... but now you have got further than me. I spent yesterday failing to get bazel to be able to run gcc at all on windows...

@Xjs
Copy link
Contributor

Xjs commented Dec 19, 2017

@ianthehat Earlier I had the problem that I had a mingw64 build of gcc installed in C:/tools/msys64/mingw64/bin/gcc, but not the msys64 build in C:/tools/msys64/usr/bin/gcc. There are pacman packages for both. Maybe that does it for you as well?

@ianthehat
Copy link
Contributor

ianthehat commented Dec 19, 2017 via email

@Xjs
Copy link
Contributor

Xjs commented Dec 19, 2017

@ianthehat pacman -S gcc did it for me. This is the package description:

msys/gcc 6.3.0-1 (msys2-devel) [installed]
    The GNU Compiler Collection - C and C++ frontends

I have the following repository mirrors for the msys repository:

Server = http://repo.msys2.org/msys/$arch
Server = http://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/$arch
Server = http://www2.futureware.at/~nickoe/msys2-mirror/msys/$arch/

Earlier I had only the following package installed:

mingw64/mingw-w64-x86_64-gcc 7.2.0-1 (mingw-w64-x86_64-toolchain) [installed]
    GNU Compiler Collection (C,C++,OpenMP) for MinGW-w64

That one (installing gcc in /mingw64/bin/gcc) wasn't found by bazel.

@Xjs
Copy link
Contributor

Xjs commented Dec 20, 2017

I found another problem along the way: rules_go seem to be affected by the GOPATH environment variable. My default setting is GOPATH=$HOME, and if set such, the bazel build command fails in bazel_test_cmd because of duplicate packages in some repositories in my ~/src directory. (Tested with HEAD, I thought it might have changed with 5feb6b2, but hasn't)

jannis.schnitzer@jannis-desktop bazel_test $ bazel build --cpu=x64_windows_msys --host_cpu=x64_windows_msys bazel_test_cmd --verbose_failures
Extracting Bazel installation...
............
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading:
Analyzing: target //:bazel_test_cmd (4 packages loaded)
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables,eg. VS140COMNTOOLS
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Looking for Visual C++ through registry
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:37:3:
Auto-Configuration Warning: Visual C++ build tools found at C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\\VC
Analyzing: target //:bazel_test_cmd (4 packages loaded)
Analyzing: target //:bazel_test_cmd (11 packages loaded)
Analyzing: target //:bazel_test_cmd (163 packages loaded)
Analyzing: target //:bazel_test_cmd (163 packages loaded)
Analyzing: target //:bazel_test_cmd (163 packages loaded)
Analyzing: target //:bazel_test_cmd (163 packages loaded)
DEBUG: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/io_bazel_rules_go/go/private/sdk.bzl:98:5: can't load package: package github.com/Xjs/rules_go/tests/binary_test_outputs: found packages main (bin.go) and binary_test_outputs (test.go) in C:\Users\jannis.schnitzer\src\github.com\Xjs\rules_go\tests\binary_test_outputs
can't load package: package github.com/Xjs/rules_go/tests/coverage: found packages main (bin.go) and coverage (coverage_test.go) in C:\Users\jannis.schnitzer\src\github.com\Xjs\rules_go\tests\coverage
can't load package: package github.com/Xjs/rules_go/tests/no_prefix: found packages main (cmd.go) and no_prefix (no_prefix.go) in C:\Users\jannis.schnitzer\src\github.com\Xjs\rules_go\tests\no_prefix
can't load package: package github.com/Xjs/rules_go/tests/race: found packages race (race.go) and main (race_main.go) in C:\Users\jannis.schnitzer\src\github.com\Xjs\rules_go\tests\race
can't load package: package github.com/Xjs/rules_go/tests/trans_dep_error: found packages a (a.go) and b (b.go) in C:\Users\jannis.schnitzer\src\github.com\Xjs\rules_go\tests\trans_dep_error
can't load package: package github.com/Xjs/rules_go/tests/transitive_data: found packages go_lib (empty.go) and transitive_data (transitive_data_test.go) in C:\Users\jannis.schnitzer\src\github.com\Xjs\rules_go\tests\transitive_data
can't load package: package github.com/bazelbuild/rules_go/tests/binary_test_outputs: found packages main (bin.go) and binary_test_outputs (test.go) in C:\Users\jannis.schnitzer\src\github.com\bazelbuild\rules_go\tests\binary_test_outputs
can't load package: package github.com/bazelbuild/rules_go/tests/coverage: found packages main (bin.go) and coverage (coverage_test.go) in C:\Users\jannis.schnitzer\src\github.com\bazelbuild\rules_go\tests\coverage
can't load package: package github.com/bazelbuild/rules_go/tests/cross: found packages cross (cross_test.go) and main (main.go) in C:\Users\jannis.schnitzer\src\github.com\bazelbuild\rules_go\tests\cross
can't load package: package github.com/bazelbuild/rules_go/tests/empty_package: found packages cgo (cgo.go) and empty_package (empty_package_test.go) in C:\Users\jannis.schnitzer\src\github.com\bazelbuild\rules_go\tests\empty_package
can't load package: package github.com/bazelbuild/rules_go/tests/no_prefix: found packages main (cmd.go) and no_prefix (no_prefix.go) in C:\Users\jannis.schnitzer\src\github.com\bazelbuild\rules_go\tests\no_prefix
can't load package: package github.com/bazelbuild/rules_go/tests/race: found packages race (race.go) and main (race_main.go) in C:\Users\jannis.schnitzer\src\github.com\bazelbuild\rules_go\tests\race
can't load package: package github.com/bazelbuild/rules_go/tests/trans_dep_error: found packages a (a.go) and b (b.go) in C:\Users\jannis.schnitzer\src\github.com\bazelbuild\rules_go\tests\trans_dep_error
can't load package: package github.com/bazelbuild/rules_go/tests/transitive_data: found packages go_lib (empty.go) and transitive_data (transitive_data_test.go) in C:\Users\jannis.schnitzer\src\github.com\bazelbuild\rules_go\tests\transitive_data
ERROR: C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/io_bazel_rules_go/BUILD.bazel:7:1: every rule of type go_context_data implicitly depends upon the target '@go_sdk//:packages.txt', but this target could not be found because of: no such package '@go_sdk//': Traceback (most recent call last):
        File "C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/io_bazel_rules_go/go/private/sdk.bzl", line 46
                _prepare(ctx)
        File "C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/io_bazel_rules_go/go/private/sdk.bzl", line 99, in _prepare
                fail("failed to list standard package...")
failed to list standard packages
ERROR: Analysis of target '//:bazel_test_cmd' failed; build aborted: no such package '@go_sdk//': Traceback (most recent call last):
        File "C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/io_bazel_rules_go/go/private/sdk.bzl", line 46
                _prepare(ctx)
        File "C:/tools/msys64/tmp/_bazel_jannis.schnitzer/oal0cs5a/external/io_bazel_rules_go/go/private/sdk.bzl", line 99, in _prepare
                fail("failed to list standard package...")
failed to list standard packages
INFO: Elapsed time: 85,766s
FAILED: Build did NOT complete successfully (163 packages loaded)

@ianthehat ianthehat self-assigned this Dec 21, 2017
@droyo
Copy link

droyo commented Dec 23, 2017

pacman -S gcc won't work, it installs the msys2 version of GCC, and you will get compilation errors like this:

runtime\cgo\gcc_windows_amd64.c:32:2: error: implicit declaration of function '_beginthread' [-Werror=implicit-function-declaration]
  thandle = _beginthread(threadentry, 0, ts);
  ^

You have to use TDM-GCC. I've installed TDM-GCC and, for the time being, hard-coded its path in stdlib.bzl. With that it was able to build cgo.exe. Of course, when it came to build my application it's using MSYS2 gcc and running into errors.

@ianthehat
Copy link
Contributor

We have made progress, in fact, we can build fully working cgo binaries now.
you can use pacman -S mingw-w64-x86_64-gcc to get the right version of gcc, but it won't work without a custom CROSSTOOL right now. I am talking to the main Bazel team about making the normal windows crosstool work correctly.
Hard coding the path won't work, you need to affect the cc_library and cc_binary rules that go libraries with cgo use underneath.

@meteorcloudy
Copy link
Member

I'll try to make Bazel work with mingw under MSYS

@meteorcloudy
Copy link
Member

Sent https://bazel-review.googlesource.com/#/c/bazel/+/30290/ to enable mingw toolchain under MSYS.

@meteorcloudy
Copy link
Member

Hi @ianthehat , there are some discussions about how should we enable the mingw gcc toolchain.
There are three options currently.

  1. Using --cpu=x64_windows_msys_mingw option. This is the change I made in https://bazel-review.googlesource.com/#/c/bazel/+/30290/. But it requires adding another toolchain and cpu configuration in our already complicated Windows CROSSTOOL.
  2. Using --cpu=x64_windows_msys option and set USE_MINGW_GCC=1 to tell Bazel we want to mingw. This will work, but requires more setup from users.
  3. Still using --cpu=x64_windows_msys, then Bazel detects gcc from PATH. This requires /mingw64/bin/gcc to be in PATH, which is true when you use the MSYS-MINGW64 terminal(/mingw64/bin is in PATH) after installing gcc through pacman -S mingw-w64-x86_64-gcc

Which one is better from your perspective?

@ianthehat
Copy link
Contributor

None of the above?
I think we are misusing the flags on windows
--cpu (which is not really the cpu) should pick windows_x86_64 automatically and be left alone
--glibc should pick the runtime (msys, native etc)
--compiler should pick msvc, msys-gcc, mingw-gcc etc

@meteorcloudy
Copy link
Member

Make sense, I made corresponding changes in https://bazel-review.googlesource.com/#/c/bazel/+/30290/

bazel-io pushed a commit to bazelbuild/bazel that referenced this issue Jan 3, 2018
We used to have --cpu=x64_windows_msys for selecting msys gcc toolchain,
this is a misuse of --cpu flag.

Instead, we should use --compiler flag to select C++ toolchain.
For example, --compiler=msvc-cl, --compiler=msys-gcc, --compiler=mingw-gcc

After this change, we can use mingw gcc toolchain by following steps:
1. In MSYS, install mingw by `pacman -S mingw-w64-x86_64-gcc`
2. Add /mingw64:/mingw64/bin into PATH
3. build with --compiler=mingw-gcc

Related:
bazelbuild/rules_go#736

Change-Id: I4b5f77ce0698cfcafefe5d2ab17657f9c9e295d3
PiperOrigin-RevId: 180678829
werkt pushed a commit to werkt/bazel that referenced this issue Mar 2, 2018
We used to have --cpu=x64_windows_msys for selecting msys gcc toolchain,
this is a misuse of --cpu flag.

Instead, we should use --compiler flag to select C++ toolchain.
For example, --compiler=msvc-cl, --compiler=msys-gcc, --compiler=mingw-gcc

After this change, we can use mingw gcc toolchain by following steps:
1. In MSYS, install mingw by `pacman -S mingw-w64-x86_64-gcc`
2. Add /mingw64:/mingw64/bin into PATH
3. build with --compiler=mingw-gcc

Related:
bazelbuild/rules_go#736

Change-Id: I4b5f77ce0698cfcafefe5d2ab17657f9c9e295d3
PiperOrigin-RevId: 180678829
@jayconrod
Copy link
Contributor

Closing this old issue as we now have basic support for Windows. Some targets can build on Windows 10, but our support and documentation is far from perfect. The windows tag will track Windows issues now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants