Allow runtime cgo implicit dependency - #1037
Conversation
mvdan
left a comment
There was a problem hiding this comment.
What bug is this fixing? And we need a test.
|
|
Thanks. Do you have a reproducer? See the bug template when you file an issue. It doesn't make any sense to merge a fix without some sort of regression test. |
|
Closing this for now. |
|
Environment
Files go.mod go 1.26 main.go Steps failsCGO_ENABLED=1 garble build -buildmode=pie succeeds — identical flags, plain toolchain (control)CGO_ENABLED=1 go build -buildmode=pie Expected: garble builds the binary, like go build does. Actual: reprolist runtime/cgo: not a dependency |
|
Thanks @mvdan ! Do you need any further information to reproduce the error? Thanks! |
|
Thanks @tomac for the pointer. I'll push a new version of this PR which adds a regression test and a more general fix. |
The go command adds packages to a main package's dependencies on behalf of the linker without them appearing in its imports, and garble rejects them: # repro list runtime/cgo: not a dependency exit status 1 That happens with CGO_ENABLED=1 and -linkmode=external, which links in runtime/cgo even for a package which does not use cgo at all. GOARCH=arm is broken in the same way for any main package which does not otherwise depend on math.
The go command adds a handful of packages to a main package's dependencies on behalf of the linker, such as runtime/cgo when linking externally or math on 32-bit arm for soft floating point. They end up in the importcfg, but not in the package's imports, which is how we rebuild the set of dependencies, so we rejected them: # repro list runtime/cgo: not a dependency exit status 1 Allow all of cmd/go's linker dependencies, along with their own dependencies, since runtime/cgo imports packages such as sync which runtime does not. Thanks to feicong for an initial fix in burrowers#1037 and David Barroso for the reproducer.
No description provided.