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

bug(nogo): fails on @@com_github_aws_aws_sdk_go//internal/context:context #4070

Closed
tyler-french opened this issue Aug 27, 2024 · 0 comments · Fixed by #4075
Closed

bug(nogo): fails on @@com_github_aws_aws_sdk_go//internal/context:context #4070

tyler-french opened this issue Aug 27, 2024 · 0 comments · Fixed by #4075

Comments

@tyler-french
Copy link
Contributor

What version of rules_go are you using?

HEAD

What version of gazelle are you using?

latest

What version of Bazel are you using?

7.2

What did you do?

Build anything with any nogo analyzer (tested with multiple)

INFO: Writing tracer profile to '/tmp/bazel_20240827021935_dgnmh'
INFO: Invocation ID: 295c50af-8d33-4580-a3fe-f617286cd0d1
INFO: Analyzed 171 targets (0 packages loaded, 0 targets configured).
WARNING: Remote Cache: Expected output external/com_github_aws_aws_sdk_go/internal/context/context.nogo.log was not created locally.
ERROR: /home/user/.cache/bazel/_bazel_tfrench/b97476d719d716accead0f2d5b93104f/external/com_github_aws_aws_sdk_go/internal/context/BUILD.bazel:3:11: output 'external/com_github_aws_aws_sdk_go/internal/context/context.nogo.log' was not created
ERROR: /home/user/.cache/bazel/_bazel_tfrench/b97476d719d716accead0f2d5b93104f/external/com_github_aws_aws_sdk_go/internal/context/BUILD.bazel:3:11: Running nogo on @@com_github_aws_aws_sdk_go//internal/context:context failed: not all outputs were created or valid
INFO: Analysis succeeded for only 97 of 171 top-level targets
INFO: Found 171 targets...
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 26.484s, Critical Path: 25.68s
INFO: 2174 processes: 1 disk cache hit, 1 internal, 2172 processwrapper-sandbox.
ERROR: Build did NOT complete successfully
INFO: Build Event Protocol files produced successfully.

Looking at this target, here's the BUILD.bazel file:

load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
    name = "context",
    srcs = ["background_go1.5.go"],
    importpath = "github.com/aws/aws-sdk-go/internal/context",
    visibility = ["//:__subpackages__"],
)

alias(
    name = "go_default_library",
    actual = ":context",
    visibility = ["//:__subpackages__"],
)

and here's the source code:

//go:build !go1.7
// +build !go1.7

package context

import "time"

// An emptyCtx is a copy of the Go 1.7 context.emptyCtx type. This is copied to
// provide a 1.6 and 1.5 safe version of context that is compatible with Go
// 1.7's Context.
//
// An emptyCtx is never canceled, has no values, and has no deadline. It is not
// struct{}, since vars of this type must have distinct addresses.
type emptyCtx int

func (*emptyCtx) Deadline() (deadline time.Time, ok bool) {
	return
}

func (*emptyCtx) Done() <-chan struct{} {
	return nil
}

func (*emptyCtx) Err() error {
	return nil
}

func (*emptyCtx) Value(key interface{}) interface{} {
	return nil
}

func (e *emptyCtx) String() string {
	switch e {
	case BackgroundCtx:
		return "aws.BackgroundContext"
	}
	return "unknown empty Context"
}

// BackgroundCtx is the common base context.
var BackgroundCtx = new(emptyCtx)
@tyler-french tyler-french changed the title bug(nogo): bug(nogo): fails on @@com_github_aws_aws_sdk_go//internal/context:context Aug 27, 2024
@fmeum fmeum closed this as completed in 6f5f6f3 Aug 29, 2024
tyler-french pushed a commit that referenced this issue Aug 30, 2024
**What type of PR is this?**

Bug fix

**What does this PR do? Why is it needed?**

Without this, nogo runs on the external test sources when compiling the
internal test library, which can result in missing deps errors and is
also wasteful. Since filtering out files made certain nogo actions run
on no files, also fix a bug that affects this situation by writing out
an empty log in addition to an empty facts file.

The code that checks imports and builds the importcfg was shared between
`compilepkg` and `nogo` and is now extracted into a common method. Along
the way, have it output the file into the working directory, which
simplifies cleanup, makes the file easier to find and avoids writing
files unknown to Bazel into the output directory.

Also removes some unused test files.

**Which issues(s) does this PR fix?**

Fixes #4062
Fixes #4070
Fixes #4073

**Other notes for review**
tyler-french pushed a commit that referenced this issue Aug 30, 2024
**What type of PR is this?**

Bug fix

**What does this PR do? Why is it needed?**

Without this, nogo runs on the external test sources when compiling the
internal test library, which can result in missing deps errors and is
also wasteful. Since filtering out files made certain nogo actions run
on no files, also fix a bug that affects this situation by writing out
an empty log in addition to an empty facts file.

The code that checks imports and builds the importcfg was shared between
`compilepkg` and `nogo` and is now extracted into a common method. Along
the way, have it output the file into the working directory, which
simplifies cleanup, makes the file easier to find and avoids writing
files unknown to Bazel into the output directory.

Also removes some unused test files.

**Which issues(s) does this PR fix?**

Fixes #4062
Fixes #4070
Fixes #4073

**Other notes for review**
tyler-french pushed a commit to tyler-french/rules_go that referenced this issue Sep 4, 2024
…el-contrib#4075)

**What type of PR is this?**

Bug fix

**What does this PR do? Why is it needed?**

Without this, nogo runs on the external test sources when compiling the
internal test library, which can result in missing deps errors and is
also wasteful. Since filtering out files made certain nogo actions run
on no files, also fix a bug that affects this situation by writing out
an empty log in addition to an empty facts file.

The code that checks imports and builds the importcfg was shared between
`compilepkg` and `nogo` and is now extracted into a common method. Along
the way, have it output the file into the working directory, which
simplifies cleanup, makes the file easier to find and avoids writing
files unknown to Bazel into the output directory.

Also removes some unused test files.

**Which issues(s) does this PR fix?**

Fixes bazel-contrib#4062
Fixes bazel-contrib#4070
Fixes bazel-contrib#4073

**Other notes for review**
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

Successfully merging a pull request may close this issue.

1 participant