buildbarn/bb-deployments

Build fails on Windows

kschzt opened this issue · 10 comments

Hi, the build fails with duplicate declarations as below. Running in Windows 11 Pro in a Git Bash (as the build requires bash for patching). Any clues as to how to fix?

$ bazel build -- ///bare:bare
DEBUG: C:/users/kschz/_bazel_kschz/u6fkmli4/external/com_github_bazelbuild_remote_apis/repository_rules.bzl:12:10: The switched_rules_by_language macro is deprecated. Consumers of @bazel_remote_apis should specify per-language dependencies in their own workspace.
INFO: Analyzed target //bare:bare (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: C:/users/kschz/_bazel_kschz/u6fkmli4/external/com_github_buildbarn_go_xdr/pkg/compiler/parser/BUILD.bazel:10:11: GoCompilePkg external/com_github_buildbarn_go_xdr/pkg/compiler/parser/parser.a [for host] failed: (Exit 1): builder.exe failed: error executing command bazel-out\host\bin\external\go_sdk\builder.exe compilepkg -sdk external/go_sdk -installsuffix windows_amd64 -src external/com_github_buildbarn_go_xdr/pkg/compiler/parser/xdr_base_listener.go -src ... (remaining 37 arguments skipped)
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_base_listener.go:8:6: BaseXDRListener redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_base_listener.go:8:6: other declaration of BaseXDRListener
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:18:6: XDRLexer redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:21:6: other declaration of XDRLexer
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:25:5: xdrlexerLexerStaticData redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:28:5: other declaration of xdrlexerLexerStaticData
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:38:6: xdrlexerLexerInit redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:41:6: other declaration of xdrlexerLexerInit
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:237:6: XDRLexerInit redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:240:6: other declaration of XDRLexerInit
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:243:6: NewXDRLexer redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:246:6: other declaration of NewXDRLexer
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:262:2: XDRLexerT__0 redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:265:2: other declaration of XDRLexerT__0
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:263:2: XDRLexerT__1 redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:266:2: other declaration of XDRLexerT__1
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:264:2: XDRLexerT__2 redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:267:2: other declaration of XDRLexerT__2
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:265:2: XDRLexerT__3 redeclared in this block
        external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr_lexer.go:268:2: other declaration of XDRLexerT__3
bazel-out\host\bin\external\com_github_buildbarn_go_xdr\pkg\compiler\parser\xdr.go\xdr_lexer.go:265:2: too many errors
compilepkg: error running subcommand external\go_sdk\pkg\tool\windows_amd64\compile.exe: exit status 2
Target //bare:bare failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.442s, Critical Path: 0.08s
INFO: 4 processes: 4 internal.
FAILED: Build did NOT complete successfully

I don't have a Windows environment right now to try it out. Do you get the same error when building just https://github.com/buildbarn/go-xdr?

@moroten No errors building that with bazel build //cmd/xdr_compiler.

PS. FYI I'm setting up a Windows RBE cluster for building Chromium with goma (natively), and buildbarn is the best on Linux (4 machines, 256 cores) – I tried all the OS RBE solutions – so I'd love to get this to work on Windows! 😊

You’re seeing this error, because it reran Gazelle in the go-xdr repo, which causes it to also build the generated source files.

@EdSchouten thanks. I'm pretty new to bazel. How can I tell it not to do that? And what makes it (only) do that on Windows? Thanks again!

Using bazel 5.3.1 btw.

I've worked around this by building the rbe and storage repos separately - they build just fine.

Good to hear that it works for you. I'll keep this ticket open to see if I can have a look at it in a few months time.

FYI I then failed at Failed to create Content Addressable Storage: rpc error: code = Unimplemented desc = Failed to open blocks block device: Memory mapping block devices is not supported on this platform which is another thing entirely :)

@EdSchouten thanks. I'm pretty new to bazel. How can I tell it not to do that? And what makes it (only) do that on Windows? Thanks again!

In go_dependencies.bzl you will find something like this:

    go_repository(
        name = "com_github_buildbarn_go_xdr",
        importpath = "github.com/buildbarn/go-xdr",
        sum = "h1:aVYAcBUakcn8QvCdKroXmjGjQBBqv3FLftTyiHjgKAQ=",
        version = "v0.0.0-20220804060714-a6fffae29b77",
    )

You could try adding build_file_generation = "off", to that. That will force it to use the BUILD files that are already in the repository.