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

Disable GOCACHE and only enable -shared/-dynlink on selected platforms #1696

Merged
merged 2 commits into from Sep 5, 2018
Merged

Disable GOCACHE and only enable -shared/-dynlink on selected platforms #1696

merged 2 commits into from Sep 5, 2018

Conversation

steeve
Copy link
Contributor

@steeve steeve commented Aug 28, 2018

Go 1.11 has its own build cache, which is enabled by default. Disable it because it doesn't make sense with bazel. See https://golang.org/cmd/go/#hdr-Build_and_test_caching

Also, only enable -shared/-dynlink on selected platforms, mimicking what go build does.

Copy link
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I have a minor comment, but this looks good.

Sorry for delays btw -- I'm at GopherCon this week.

"darwin/amd64": None,
}

def add_link_arg(go, args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to reduce constraints on how this function is called. It looks like it just needs a mode, and it could return a list of strings which could be added by the caller with args.add_all.

Also, the name add_link_arg doesn't quite seem right, since this affects code generation. Maybe link_mode_args would be a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sold!

@@ -241,6 +241,7 @@ def go_context(ctx, attr = None):
env.update({
"GOARCH": mode.goarch,
"GOOS": mode.goos,
"GOCACHE": "off", # bazel has it's own caching
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As was mentioned in another comment, this will probably break in Go 1.12. I think they want to integrate the cache more tightly into go build.

GoStdLib should be the only action that needs this. The other actions all read inputs and write outputs directly. So maybe GOCACHE could just be set in stdlib.go?

I share your concern about interacting with the user's cache outside of Bazel's workspace. It's probably okay as long as sandboxing or remote execution are in use, but that's not guaranteed. It's probably better to create a temp directory, set GOCACHE to that, then delete it at the end of the action.

It's probably best for all that to be in a separate PR though. Or feel free to file an issue, and I can fix it next week.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing, I'll remove it

@steeve
Copy link
Contributor Author

steeve commented Sep 3, 2018

I'm going to rebase on master

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

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One more small comment.

args = []
if mode.link == LINKMODE_C_ARCHIVE:
if platform in _LINK_C_ARCHIVE_PLATFORMS or mode.goos in _LINK_C_ARCHIVE_GOOS:
if platform == "linux/ppc64":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return could cause problems. Can the condition be folded into the if above? ... and platform != "linux/ppc64"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@jayconrod jayconrod merged commit 32445ce into bazelbuild:master Sep 5, 2018
@steeve
Copy link
Contributor Author

steeve commented Sep 5, 2018

Sorry I got sidetracked, thank you for making the change!

@steeve steeve deleted the fix/shared_and_gocache branch September 5, 2018 18:18
jayconrod pushed a commit that referenced this pull request Sep 5, 2018
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.

None yet

3 participants