Skip to content

Ensure go_binary.embed libraries' importpath is main#2135

Merged
jayconrod merged 2 commits intomasterfrom
unknown repository
Jul 13, 2019
Merged

Ensure go_binary.embed libraries' importpath is main#2135
jayconrod merged 2 commits intomasterfrom
unknown repository

Conversation

@steeve
Copy link
Copy Markdown
Contributor

@steeve steeve commented Jul 12, 2019

Go 1.13 is now stricter on the package path passed to
go tool compile -p. This means that go_library passed in go_binary.embed
fails to declare a main.main, as they now retain their import path. Fix
this by forcing a importmain=main on go_binary.

Fixes #2133

@steeve
Copy link
Copy Markdown
Contributor Author

steeve commented Jul 12, 2019

While this fixes my test case, gazelle is failing to build still for the same reason. Digging.

@steeve
Copy link
Copy Markdown
Contributor Author

steeve commented Jul 12, 2019

Gotcha.
I'll try that, thanks!

Go 1.13 is stricter on the package path passed to go tool compile -p.
This means that go_library passed in go_binary.embed fails to declare a
main.main function, as they now retain their original import path. Fix
that by adding a is_main boolean to the GoLibrary provider, which will
tell wether a library is supposed to be a main package; that is,
compiled from within a go_binary.

Fixes #2133

Signed-off-by: Steeve Morin <steeve@zen.ly>
@steeve
Copy link
Copy Markdown
Contributor Author

steeve commented Jul 13, 2019

Updated the PR to add the is_main flag, works well !

* Revert change in effective_importpath_importmap. It looks like
  go_path needs these to stay exactly the same. Instead, adjust
  importmap in emit_archive.
* Also set is_main in go_test and nogo, which create GoLibrary
  providers without calling new_library.
* Minor doc rephrasing.
@jayconrod jayconrod merged commit a386ca7 into bazel-contrib:master Jul 13, 2019
@jayconrod
Copy link
Copy Markdown
Collaborator

Thanks for working on this. Hope you don't mind that I fixed a couple things and updated the PR directly. My earlier advice on updating effective_importpath_pkgpath was not correct. This is the kind of change that needs some tinkering. It's hard to say how it will turn out without actually writing it.

@steeve
Copy link
Copy Markdown
Contributor Author

steeve commented Jul 13, 2019

No worries! Thank you for amending the PR on a Saturday!

@steeve
Copy link
Copy Markdown
Contributor Author

steeve commented Jul 13, 2019

I had limited connectivity but I wanted to at least update the PR

@steeve steeve deleted the steeve/go1.13 branch July 13, 2019 22:35
jayconrod pushed a commit to jayconrod/bazel-gazelle that referenced this pull request Aug 21, 2019
Necessary to make the go1.13 linker happy.

Corresponding change in go_binary: bazel-contrib/rules_go#2135

Also: upgrade to rules_go 0.19.3
jayconrod pushed a commit to bazel-contrib/bazel-gazelle that referenced this pull request Aug 21, 2019
Necessary to make the go1.13 linker happy.

Corresponding change in go_binary: bazel-contrib/rules_go#2135

Also: upgrade to rules_go 0.19.3
jayconrod pushed a commit to jayconrod/bazel-gazelle that referenced this pull request Aug 23, 2019
…b#625)

Necessary to make the go1.13 linker happy.

Corresponding change in go_binary: bazel-contrib/rules_go#2135

Also: upgrade to rules_go 0.19.3
jayconrod pushed a commit to jayconrod/rules_go that referenced this pull request Aug 23, 2019
)

Go 1.13 is stricter on the package path passed to go tool compile -p.
This means that go_library passed in go_binary.embed fails to declare a
main.main function, as they now retain their original import path. Fix
that by adding a is_main boolean to the GoLibrary provider, which will
tell wether a library is supposed to be a main package; that is,
compiled from within a go_binary.

Fixes bazel-contrib#2133
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…thon (bazel-contrib#2135)

Before this PR the lockfile would become platform dependent when the
`requirements` file would have env markers. This was not caught because
we do not have MODULE.bazel.lock checked into the `rules_python`
repository because the CI is running against many versions and the lock
file is different, therefore we would not be able to run with
`bazel build --lockfile_mode=error`.

With this change we use the label to `BUILD.bazel` which is living next
to the `python` symlink and since the `BUILD.bazel` is the same on all
platforms, the lockfile will remain the same.

Summary
* refactor(uv): create a reusable macro for using uv for locking reqs.
* test(bzlmod): enable testing the MODULE.bazel.lock breakage across
platforms.
* test(bzlmod): use a universal requirements file for 3.9.
This breaks the CI, because the python interpreter file hash is added to
the lock file.
* fix(bzlmod): keep the lockfile platform independent when resolving
python


Fixes bazel-contrib#1105 and bazel-contrib#1868 for real this time.
Implements an additional helper for bazel-contrib#1975.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go 1.13 compat

3 participants