Skip to content

x/tools/go/analysis: test failures due to disabled cgo with external linking #62268

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

Closed
gopherbot opened this issue Aug 24, 2023 · 8 comments
Closed
Labels
NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@gopherbot
Copy link
Contributor

gopherbot commented Aug 24, 2023

#!watchflakes
post <- pkg ~ `^golang\.org/x/tools/go/analysis` && log ~ `cgo is not enabled` && date < "2023-09-01"

Issue created automatically to collect these failures.

Example (log):

/data/local/tmp/go_android_exec/checker.test-17426/analysistest1197894427/src/rename/test.go:4:2: renaming "bar" to "baz"
/data/local/tmp/go_android_exec/checker.test-17426/analysistest1197894427/src/rename/test.go:5:6: renaming "bar" to "baz"
-: # command-line-arguments
../../../../../../../../../analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17426/analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:05 2 errors during loading
-: # command-line-arguments
../../../../../../../../../analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17426/analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:05 2 errors during loading
...
-: # command-line-arguments
../../../../../../../../../analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17426/analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:28 3 errors during loading
2023/08/24 16:47:28 file=non/existing/dir matched no packages
-: android/386 requires external (cgo) linking, but cgo is not enabled
2023/08/24 16:47:29 error during loading
--- FAIL: TestRunDespiteErrors (23.57s)
    checker_test.go:206: got incorrect exit code 1 for test no-errors; want 0
/data/local/tmp/go_android_exec/checker.test-17426/analysistest3753256058/src/comment/doc.go:1:1: 

watchflakes

@gopherbot gopherbot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 24, 2023
@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/passes/tests" && test == "TestRunDespiteErrors"
2023-08-24 16:41 android-386-emu tools@c28af0ab go@d5c58085 x/tools/go/analysis/passes/tests.TestRunDespiteErrors (log)
/data/local/tmp/go_android_exec/checker.test-17426/analysistest1197894427/src/rename/test.go:4:2: renaming "bar" to "baz"
/data/local/tmp/go_android_exec/checker.test-17426/analysistest1197894427/src/rename/test.go:5:6: renaming "bar" to "baz"
-: # command-line-arguments
../../../../../../../../../analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17426/analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:05 2 errors during loading
-: # command-line-arguments
../../../../../../../../../analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17426/analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:05 2 errors during loading
...
-: # command-line-arguments
../../../../../../../../../analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17426/analysistest956040403/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:28 3 errors during loading
2023/08/24 16:47:28 file=non/existing/dir matched no packages
-: android/386 requires external (cgo) linking, but cgo is not enabled
2023/08/24 16:47:29 error during loading
--- FAIL: TestRunDespiteErrors (23.57s)
    checker_test.go:206: got incorrect exit code 1 for test no-errors; want 0
/data/local/tmp/go_android_exec/checker.test-17426/analysistest3753256058/src/comment/doc.go:1:1: 
2023-08-24 16:41 android-amd64-emu tools@c28af0ab go@d5c58085 x/tools/go/analysis/passes/tests.TestRunDespiteErrors (log)
/data/local/tmp/go_android_exec/checker.test-17904/analysistest4271380061/src/rename/test.go:4:2: renaming "bar" to "baz"
/data/local/tmp/go_android_exec/checker.test-17904/analysistest4271380061/src/rename/test.go:5:6: renaming "bar" to "baz"
-: # command-line-arguments
../../../../../../../../../analysistest584738340/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17904/analysistest584738340/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:06 2 errors during loading
-: # command-line-arguments
../../../../../../../../../analysistest584738340/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17904/analysistest584738340/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:06 2 errors during loading
...
-: # command-line-arguments
../../../../../../../../../analysistest584738340/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17904/analysistest584738340/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/24 16:47:29 3 errors during loading
2023/08/24 16:47:29 file=non/existing/dir matched no packages
-: android/amd64 requires external (cgo) linking, but cgo is not enabled
2023/08/24 16:47:30 error during loading
--- FAIL: TestRunDespiteErrors (24.52s)
    checker_test.go:206: got incorrect exit code 1 for test no-errors; want 0
/data/local/tmp/go_android_exec/checker.test-17904/analysistest3249731709/src/comment/doc.go:1:1: 

watchflakes

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Aug 24, 2023
@gopherbot gopherbot added this to the Unreleased milestone Aug 24, 2023
@bcmills bcmills changed the title x/tools/go/analysis/passes/tests: TestRunDespiteErrors failures x/tools/go/analysis/passes/tests: test failures due to disabled cgo with external linking Aug 24, 2023
@bcmills bcmills self-assigned this Aug 24, 2023
@gopherbot
Copy link
Contributor Author

Change https://go.dev/cl/522795 mentions this issue: internal/testenv: simplify 'go build' support check

@bcmills bcmills changed the title x/tools/go/analysis/passes/tests: test failures due to disabled cgo with external linking x/tools/go/analysis: test failures due to disabled cgo with external linking Aug 24, 2023
@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure. labels Aug 25, 2023
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 25, 2023
@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
post <- pkg ~ `^golang\.org/x/tools/go/analysis` && log ~ `cgo is not enabled`
2023-08-25 17:48 android-386-emu tools@c51e3f73 go@e92c0f84 x/tools/go/analysis/passes/tests.TestRunDespiteErrors (log)
/data/local/tmp/go_android_exec/checker.test-17481/analysistest2701355272/src/rename/test.go:4:2: renaming "bar" to "baz"
/data/local/tmp/go_android_exec/checker.test-17481/analysistest2701355272/src/rename/test.go:5:6: renaming "bar" to "baz"
-: # command-line-arguments
../../../../../../../../../analysistest1555473918/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17481/analysistest1555473918/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:16:21 2 errors during loading
-: # command-line-arguments
../../../../../../../../../analysistest1555473918/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17481/analysistest1555473918/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:16:21 2 errors during loading
...
-: # command-line-arguments
../../../../../../../../../analysistest1555473918/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17481/analysistest1555473918/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:16:47 3 errors during loading
2023/08/25 18:16:47 file=non/existing/dir matched no packages
-: android/386 requires external (cgo) linking, but cgo is not enabled
2023/08/25 18:16:48 error during loading
--- FAIL: TestRunDespiteErrors (26.94s)
    checker_test.go:206: got incorrect exit code 1 for test no-errors; want 0
/data/local/tmp/go_android_exec/checker.test-17481/analysistest3877590027/src/comment/doc.go:1:1: 
2023-08-25 17:48 android-386-emu tools@c51e3f73 go@e92c0f84 x/tools/go/analysis/passes/tests.TestAnalysistest (log)
-: android/386 requires external (cgo) linking, but cgo is not enabled
--- FAIL: TestAnalysistest (0.09s)
    analysistest.go:304: error analyzing versiontest@m: analysis skipped due to errors in package
2023-08-25 17:48 android-386-emu tools@c51e3f73 go@e92c0f84 x/tools/go/analysis/passes/tests.TestMultichecker (log)
--- FAIL: TestMultichecker (0.09s)
    version_test.go:72: multichecker: exit status 1
        -: android/386 requires external (cgo) linking, but cgo is not enabled
        versiontest.test: error during loading
2023-08-25 17:48 android-386-emu tools@c51e3f73 go@777e65fe x/tools/go/analysis/passes/tests.TestRunDespiteErrors (log)
/data/local/tmp/go_android_exec/checker.test-17357/analysistest1635931659/src/rename/test.go:4:2: renaming "bar" to "baz"
/data/local/tmp/go_android_exec/checker.test-17357/analysistest1635931659/src/rename/test.go:5:6: renaming "bar" to "baz"
-: # command-line-arguments
../../../../../../../../../analysistest2489700639/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17357/analysistest2489700639/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:08:36 2 errors during loading
-: # command-line-arguments
../../../../../../../../../analysistest2489700639/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17357/analysistest2489700639/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:08:36 2 errors during loading
...
-: # command-line-arguments
../../../../../../../../../analysistest2489700639/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17357/analysistest2489700639/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:09:03 3 errors during loading
2023/08/25 18:09:03 file=non/existing/dir matched no packages
-: android/386 requires external (cgo) linking, but cgo is not enabled
2023/08/25 18:09:03 error during loading
--- FAIL: TestRunDespiteErrors (27.71s)
    checker_test.go:206: got incorrect exit code 1 for test no-errors; want 0
/data/local/tmp/go_android_exec/checker.test-17357/analysistest285533891/src/comment/doc.go:1:1: 
2023-08-25 17:48 android-386-emu tools@c51e3f73 go@777e65fe x/tools/go/analysis/passes/tests.TestAnalysistest (log)
-: android/386 requires external (cgo) linking, but cgo is not enabled
--- FAIL: TestAnalysistest (0.10s)
    analysistest.go:304: error analyzing versiontest@m: analysis skipped due to errors in package
2023-08-25 17:48 android-386-emu tools@c51e3f73 go@777e65fe x/tools/go/analysis/passes/tests.TestMultichecker (log)
--- FAIL: TestMultichecker (0.08s)
    version_test.go:72: multichecker: exit status 1
        -: android/386 requires external (cgo) linking, but cgo is not enabled
        versiontest.test: error during loading
2023-08-25 17:48 android-amd64-emu tools@c51e3f73 go@e92c0f84 x/tools/go/analysis/passes/tests.TestRunDespiteErrors (log)
/data/local/tmp/go_android_exec/checker.test-17768/analysistest719349545/src/rename/test.go:4:2: renaming "bar" to "baz"
/data/local/tmp/go_android_exec/checker.test-17768/analysistest719349545/src/rename/test.go:5:6: renaming "bar" to "baz"
-: # command-line-arguments
../../../../../../../../../analysistest878745363/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17768/analysistest878745363/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:33:54 2 errors during loading
-: # command-line-arguments
../../../../../../../../../analysistest878745363/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17768/analysistest878745363/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:33:54 2 errors during loading
...
-: # command-line-arguments
../../../../../../../../../analysistest878745363/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17768/analysistest878745363/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:34:18 3 errors during loading
2023/08/25 18:34:18 file=non/existing/dir matched no packages
-: android/amd64 requires external (cgo) linking, but cgo is not enabled
2023/08/25 18:34:18 error during loading
--- FAIL: TestRunDespiteErrors (24.25s)
    checker_test.go:206: got incorrect exit code 1 for test no-errors; want 0
/data/local/tmp/go_android_exec/checker.test-17768/analysistest2602912222/src/comment/doc.go:1:1: 
2023-08-25 17:48 android-amd64-emu tools@c51e3f73 go@e92c0f84 x/tools/go/analysis/passes/tests.TestAnalysistest (log)
-: android/amd64 requires external (cgo) linking, but cgo is not enabled
--- FAIL: TestAnalysistest (0.09s)
    analysistest.go:304: error analyzing versiontest@m: analysis skipped due to errors in package
2023-08-25 17:48 android-amd64-emu tools@c51e3f73 go@e92c0f84 x/tools/go/analysis/passes/tests.TestMultichecker (log)
--- FAIL: TestMultichecker (0.05s)
    version_test.go:72: multichecker: exit status 1
        -: android/amd64 requires external (cgo) linking, but cgo is not enabled
        versiontest.test: error during loading
2023-08-25 17:48 android-amd64-emu tools@c51e3f73 go@777e65fe x/tools/go/analysis/passes/tests.TestRunDespiteErrors (log)
/data/local/tmp/go_android_exec/checker.test-17783/analysistest2592724625/src/rename/test.go:4:2: renaming "bar" to "baz"
/data/local/tmp/go_android_exec/checker.test-17783/analysistest2592724625/src/rename/test.go:5:6: renaming "bar" to "baz"
-: # command-line-arguments
../../../../../../../../../analysistest130995133/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17783/analysistest130995133/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:08:27 2 errors during loading
-: # command-line-arguments
../../../../../../../../../analysistest130995133/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17783/analysistest130995133/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:08:27 2 errors during loading
...
-: # command-line-arguments
../../../../../../../../../analysistest130995133/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
/data/local/tmp/go_android_exec/checker.test-17783/analysistest130995133/src/rderr/test.go:5:9: invalid operation: s + 1 (mismatched types string and untyped int)
2023/08/25 18:08:50 3 errors during loading
2023/08/25 18:08:50 file=non/existing/dir matched no packages
-: android/amd64 requires external (cgo) linking, but cgo is not enabled
2023/08/25 18:08:50 error during loading
--- FAIL: TestRunDespiteErrors (23.75s)
    checker_test.go:206: got incorrect exit code 1 for test no-errors; want 0
/data/local/tmp/go_android_exec/checker.test-17783/analysistest109288704/src/comment/doc.go:1:1: 
2023-08-25 17:48 android-amd64-emu tools@c51e3f73 go@777e65fe x/tools/go/analysis/passes/tests.TestAnalysistest (log)
-: android/amd64 requires external (cgo) linking, but cgo is not enabled
--- FAIL: TestAnalysistest (0.08s)
    analysistest.go:304: error analyzing versiontest@m: analysis skipped due to errors in package
2023-08-25 17:48 android-amd64-emu tools@c51e3f73 go@777e65fe x/tools/go/analysis/passes/tests.TestMultichecker (log)
--- FAIL: TestMultichecker (0.07s)
    version_test.go:72: multichecker: exit status 1
        -: android/amd64 requires external (cgo) linking, but cgo is not enabled
        versiontest.test: error during loading

watchflakes

@bcmills bcmills reopened this Aug 25, 2023
@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
post <- pkg ~ `^golang\.org/x/tools/go/analysis` && log ~ `cgo is not enabled`
2023-08-25 18:47 android-386-emu tools@5fb106a9 go@e92c0f84 x/tools/go/analysis/unitchecker (log)
-: android/386 requires external (cgo) linking, but cgo is not enabled
2023-08-25 18:47 android-amd64-emu tools@5fb106a9 go@e92c0f84 x/tools/go/analysis/unitchecker (log)
-: android/amd64 requires external (cgo) linking, but cgo is not enabled

watchflakes

@gopherbot
Copy link
Contributor Author

Change https://go.dev/cl/523076 mentions this issue: go/analysis/unitchecker: avoid running ExampleSeparateAnalysis when 'go build' does not work

@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
post <- pkg ~ `^golang\.org/x/tools/go/analysis` && log ~ `cgo is not enabled`
2023-08-25 19:23 android-amd64-emu tools@2191a27a go@e92c0f84 x/tools/go/analysis/unitchecker (log)
-: android/amd64 requires external (cgo) linking, but cgo is not enabled

watchflakes

@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
post <- pkg ~ `^golang\.org/x/tools/go/analysis` && log ~ `cgo is not enabled`
2023-08-25 19:23 android-386-emu tools@2191a27a go@e92c0f84 x/tools/go/analysis/unitchecker (log)
-: android/386 requires external (cgo) linking, but cgo is not enabled

watchflakes

@bcmills bcmills closed this as completed Aug 31, 2023
@cforce
Copy link

cforce commented Jul 4, 2024

@bcmills I just recognized go builds for android started to require CGO_ENABLED=1 since i have moved from 1.21.7 to 1.22.4: Do you know something about it? See open-telemetry/opentelemetry-collector#10516

@bcmills bcmills removed their assignment Sep 2, 2024
apstndb pushed a commit to apstndb/gotoolsdiff that referenced this issue Jan 11, 2025
We have tried various approaches in testenv.hasTool to detect whether
'go build' works without actually building a binary. However, they all
turn out to be fairly fragile. If cgo is enabled then we need a C
linker, but if the platform requires external linking then cgo must be
enabled too.

Instead of trying to second-guess whether 'go build' will actually work,
let's just ask it to build a binary and see whether it succeeds.
Hopefully this appreach will be simple enough in practice.

This parallels the approach taken in CL 492979.

Fixes golang/go#62268.
Updates golang/go#46330.

Change-Id: I9fd85fb73d291306e7bfb2f3ef6cf75a09cb6bed
Reviewed-on: https://go-review.googlesource.com/c/tools/+/522795
Run-TryBot: Bryan Mills <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
gopls-CI: kokoro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
Archived in project
Development

No branches or pull requests

3 participants