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

[Go 1.13] main function requires main package #639

Closed
qzmfranklin opened this issue Sep 20, 2019 · 1 comment
Closed

[Go 1.13] main function requires main package #639

qzmfranklin opened this issue Sep 20, 2019 · 1 comment

Comments

@qzmfranklin
Copy link

What version of gazelle are you using?

0.18.1

What version of rules_go are you using?

0.19.1

What version of Bazel are you using?

0.29.0

Does this issue reproduce with the latest releases of all the above?

What operating system and processor architecture are you using?

Ubuntu 18.04.2
amd64

What did you do?

bazel build @bazel_gazelle//cmd/gazelle

What did you expect to see?

The binary gazelle builds correctly.

What did you see instead?

10:53 $ bazel build @bazel_gazelle//cmd/gazelle
INFO: Invocation ID: 823d0a1e-e145-4b40-86fe-45f2a79a4831
INFO: Analyzed target @bazel_gazelle//cmd/gazelle:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
INFO: Writing explanation of rebuilds to 'build/logs'
ERROR: /home/zhongming/.cache/bazel/_bazel_zhongming/5a5efdfcd4f98edbd655a37c61128c16/external/bazel_gazelle/cmd/gazelle/BUILD.bazel:4:1: GoLink external/bazel_gazelle/cmd/gazelle/linux_amd64_stripped/gazelle failed (Exit 1) builder failed: error executing command
  (cd /home/zhongming/.cache/bazel/_bazel_zhongming/5a5efdfcd4f98edbd655a37c61128c16/sandbox/linux-sandbox/16085/execroot/logi && \
  exec env - \
    CGO_ENABLED=1 \
    GOARCH=amd64 \
    GOOS=linux \
    GOROOT=external/go_sdk \
    GOROOT_FINAL=GOROOT \
    PATH=tools/toolchains/cc/clang/wrappers:/bin:/usr/bin \
  bazel-out/host/bin/external/go_sdk/builder link -sdk external/go_sdk -installsuffix linux_amd64 -arc '@bazel_gazelle//language/proto:go_default_library=github.com/bazelbuild/bazel-gazelle/language/proto=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/language/proto/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/language/proto.a' -arc '@bazel_gazelle//config:go_default_library=github.com/bazelbuild/bazel-gazelle/config=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/config/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/config.a' -arc '@bazel_gazelle//internal/wspace:go_default_library=github.com/bazelbuild/bazel-gazelle/internal/wspace=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/internal/wspace/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/internal/wspace.a' -arc '@bazel_gazelle//rule:go_default_library=github.com/bazelbuild/bazel-gazelle/rule=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/rule/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/rule.a' -arc '@bazel_gazelle//label:go_default_library=github.com/bazelbuild/bazel-gazelle/label=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/label/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/label.a' -arc '@bazel_gazelle//pathtools:go_default_library=github.com/bazelbuild/bazel-gazelle/pathtools=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/pathtools/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/pathtools.a' -arc '@com_github_bazelbuild_buildtools//build:go_default_library=github.com/bazelbuild/buildtools/build=bazel-out/k8-fastbuild/bin/external/com_github_bazelbuild_buildtools/build/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/buildtools/build.a' -arc '@com_github_bazelbuild_buildtools//tables:go_default_library=github.com/bazelbuild/buildtools/tables=bazel-out/k8-fastbuild/bin/external/com_github_bazelbuild_buildtools/tables/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/buildtools/tables.a' -arc '@bazel_gazelle//language:go_default_library=github.com/bazelbuild/bazel-gazelle/language=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/language/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/language.a' -arc '@bazel_gazelle//resolve:go_default_library=github.com/bazelbuild/bazel-gazelle/resolve=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/resolve/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/resolve.a' -arc '@bazel_gazelle//repo:go_default_library=github.com/bazelbuild/bazel-gazelle/repo=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/repo/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/repo.a' -arc '@bazel_gazelle//merger:go_default_library=github.com/bazelbuild/bazel-gazelle/merger=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/merger/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/merger.a' -arc '@com_github_pelletier_go_toml//:go_default_library=github.com/pelletier/go-toml=bazel-out/k8-fastbuild/bin/external/com_github_pelletier_go_toml/linux_amd64_stripped/go_default_library%/github.com/pelletier/go-toml.a' -arc '@org_golang_x_tools//go/vcs:go_default_library=golang.org/x/tools/go/vcs=bazel-out/k8-fastbuild/bin/external/org_golang_x_tools/go/vcs/linux_amd64_stripped/go_default_library%/golang.org/x/tools/go/vcs.a' -arc '@bazel_gazelle//language/go:go_default_library=github.com/bazelbuild/bazel-gazelle/language/go=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/language/go/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/language/go.a' -arc '@bazel_gazelle//flag:go_default_library=github.com/bazelbuild/bazel-gazelle/flag=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/flag/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/flag.a' -arc '@bazel_gazelle//internal/version:go_default_library=github.com/bazelbuild/bazel-gazelle/internal/version=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/internal/version/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/internal/version.a' -arc '@bazel_gazelle//walk:go_default_library=github.com/bazelbuild/bazel-gazelle/walk=bazel-out/k8-fastbuild/bin/external/bazel_gazelle/walk/linux_amd64_stripped/go_default_library%/github.com/bazelbuild/bazel-gazelle/walk.a' -arc '@com_github_pmezard_go_difflib//difflib:go_default_library=github.com/pmezard/go-difflib/difflib=bazel-out/k8-fastbuild/bin/external/com_github_pmezard_go_difflib/difflib/linux_amd64_stripped/go_default_library%/github.com/pmezard/go-difflib/difflib.a' -package_list bazel-out/host/bin/external/go_sdk/packages.txt -o bazel-out/k8-fastbuild/bin/external/bazel_gazelle/cmd/gazelle/linux_amd64_stripped/gazelle -main bazel-out/k8-fastbuild/bin/external/bazel_gazelle/cmd/gazelle/linux_amd64_stripped/gazelle%/cmd/gazelle.a -p cmd/gazelle -- -extld tools/toolchains/cc/clang/wrappers/clang '-buildid=redacted' -w -extldflags '-Lexternal/clang/lib -lc++abi -lm -fuse-ld=lld -Wl,-z,relro,-z,now -no-canonical-prefixes')
Execution platform: @bazel_tools//platforms:host_platform

Use --sandbox_debug to see verbose messages from the sandbox
runtime.main_main·f: function main is undeclared in the main package
link: error running subcommand: exit status 2
Target @bazel_gazelle//cmd/gazelle:gazelle failed to build
INFO: Elapsed time: 1.137s, Critical Path: 0.31s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

Looks like starting with Go 1.13, the Go linker enforces that the main() function must reside in the main package.

@qzmfranklin
Copy link
Author

Never mind. This error does not occur on the most recent versions of rules_go (0.19.4) and gazelle (0.18.2).

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

1 participant