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

cgo=0 of github.com/cloudflare/circl does not compile #3799

Closed
hugelgupf opened this issue Dec 24, 2023 · 1 comment
Closed

cgo=0 of github.com/cloudflare/circl does not compile #3799

hugelgupf opened this issue Dec 24, 2023 · 1 comment

Comments

@hugelgupf
Copy link
Contributor

What version of rules_go are you using?

v0.43.0

What version of gazelle are you using?

v0.34.0

What version of Bazel are you using?

7.0.0

Does this issue reproduce with the latest releases of all the above?

yes

What operating system and processor architecture are you using?

x86 / linux

What did you do?

I pulled in a go_repository that depended on github.com/cloudflare/circl
(CGO_ENABLED=0 go build ./... works in circl).

Compiling, I got:

ERROR: /usr/local/google/home/chrisko/.cache/bazel/_bazel_chrisko/9c6102c63dcce3ba37133cceee0f9e68/external/com_github_u-root_u-root/vendor/github.com/cloudflare/circl/dh/x25519/BUILD.bazel:3:11: GoCompilePkg external/com_github_u-root_u-root/vendor/github.com/cloudflare/circl/dh/x25519/x25519.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target @@com_github_u-root_u-root//vendor/github.com/cloudflare/circl/dh/x25519:x25519) bazel-out/k8-opt-exec-ST-397274ff1547/bin/external/go_sdk/builder_reset/builder compilepkg -sdk external/go_sdk -installsuffix linux_amd64 -src ... (remaining 41 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/com_github_u-root_u-root/vendor/github.com/cloudflare/circl/dh/x25519/curve_amd64.s:7: #include: open external/com_github_u-root_u-root/vendor/github.com/cloudflare/circl/math/fp25519/fp_amd64.h: no such file or directory
compilepkg: error running subcommand external/go_sdk/pkg/tool/linux_amd64/asm: exit status 1

So I tracked down the fact that assembly files in cgo packages are not included in pure compilation (#3798 -- though I don't think it's entirely correct), after which the following happens:

[...] Snip [...]
github.com/u-root/u-root/vendor/github.com/cloudflare/circl/sign/ed25519.(*pointR1).toAffine: relocation target github.com/u-root/u-root/vendor/github.com/cloudflare/circl/math/fp25519.modpAmd64 not defined
github.com/u-root/u-root/vendor/github.com/cloudflare/circl/sign/ed25519.(*pointR1).FromBytes: relocation target github.com/u-root/u-root/vendor/github.com/cloudflare/circl/math/fp25519.sqrAmd64 not defined
github.com/u-root/u-root/vendor/github.com/cloudflare/circl/sign/ed25519.(*pointR1).FromBytes: relocation target github.com/u-root/u-root/vendor/github.com/cloudflare/circl/math/fp25519.mulAmd64 not defined
github.com/u-root/u-root/vendor/github.com/cloudflare/circl/sign/ed25519.(*pointR1).FromBytes: relocation target github.com/u-root/u-root/vendor/github.com/cloudflare/circl/math/fp25519.subAmd64 not defined
github.com/u-root/u-root/vendor/github.com/cloudflare/circl/sign/ed25519.(*pointR1).FromBytes: relocation target github.com/u-root/u-root/vendor/github.com/cloudflare/circl/math/fp25519.addAmd64 not defined
github.com/u-root/u-root/vendor/github.com/cloudflare/circl/sign/ed25519.(*pointR1).FromBytes: relocation target github.com/u-root/u-root/vendor/github.com/cloudflare/circl/math/fp25519.modpAmd64 not defined
github.com/u-root/u-root/vendor/github.com/cloudflare/circl/sign/ed25519.(*pointR1).double: relocation target github.com/u-root/u-root/vendor/github.com/cloudflare/circl/math/fp25519.addAmd64 not defined
github.com/u-root/u-root/vendor/github.com/cloudflare/circl/sign/ed25519.(*pointR1).double: relocation target github.com/u-root/u-root/vendor/github.com/cloudflare/circl/math/fp25519.sqrAmd64 not defined
external/go_sdk/pkg/tool/linux_amd64/link: too many errors
link: error running subcommand external/go_sdk/pkg/tool/linux_amd64/link: exit status 2

Presumably because https://github.com/cloudflare/circl/blob/main/math/fp25519/fp_noasm.go is not included in compilation. (Which puzzles me actually, because I don't understand how it is included in regular CGO_ENABLED=0 compilation of the package. I haven't been able to track that down.)

@fmeum
Copy link
Collaborator

fmeum commented Jan 7, 2024

Yeah, the cgo structure of circl is not supported by Gazelle. You can use Bzlmod and depend on the circl module - it is set up so that Gazelle/rules_go will detect it as a Go dependency.

@fmeum fmeum closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2024
jrockway added a commit to pachyderm/pachyderm that referenced this issue May 3, 2024
There was an issue with a dependency of Pulumi that prevented us from
building with Bazel. That is fixed, or at least worked around cleanly:
bazelbuild/rules_go#3799 (comment)

With the workarounds, this now builds OK, so I've unignored it and added
a BUILD file.

There was also an issue where it generates invalid helm values. I fixed
that bug and added a test.
jrockway added a commit to pachyderm/pachyderm that referenced this issue May 3, 2024
There was an issue with a dependency of Pulumi that prevented us from
building with Bazel. That is fixed, or at least worked around cleanly:
bazelbuild/rules_go#3799 (comment)

With the workarounds, this now builds OK, so I've unignored it and added
a BUILD file.

There was also an issue where it generates invalid helm values. I fixed
that bug and added a test.
jrockway added a commit to pachyderm/pachyderm that referenced this issue May 3, 2024
There was an issue with a dependency of Pulumi that prevented us from
building with Bazel. That is fixed, or at least worked around cleanly:
bazelbuild/rules_go#3799 (comment)

With the workarounds, this now builds OK, so I've unignored it and added
a BUILD file.

There was also an issue where it generates invalid helm values. I fixed
that bug and added a test.

Backports #10017
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

No branches or pull requests

2 participants