ProtonMail / go-crypto

Fork of go/x/crypto, providing an up-to-date OpenPGP implementation
https://pkg.go.dev/github.com/ProtonMail/go-crypto
BSD 3-Clause "New" or "Revised" License
328 stars 99 forks source link

cloudflare/circl dependency makes it difficult to compile without cgo for amd64 #185

Open pfiaux opened 11 months ago

pfiaux commented 11 months ago

I initially reported this in https://github.com/google/go-github/issues/2932 but it is also relevant here depending on how you intend this library to be used (with our without cgo).

I'm running into a slightly obscure build problem. Using bazel (and gazelle and rules_go) to build worked fine both for arm64 and amd64. I recently tried to bump to a package which uses go-crypto as a dependency and found myself unable to build for amd64 via bazel.

The dependency github.com/cloudflare/circl was bumped from v1.1.0 to v1.3.3. The problem is that it includes some platform specific files changes (*_amd64.go) for some packages, some headers and some assembly. It's not new but some changes seem to have been introduced which changed the behavior of the build.

Unfortunately led to some issues trying to build via bazel with dependencies not detected:

external/com_github_cloudflare_circl/dh/x25519/curve_amd64.s:7: #include: open external/com_github_cloudflare_circl/math/fp25519/fp_amd64.h: no such file or directory

From what I can tell it would be possible to specify the purego build tag to avoid this behavior but it's a bit cumbersome to use a manual rather than the cgo builtin tag.