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_ENABLED=0 signature_cgo.go:27:2 build constraints exclude all Go files #17452

Closed
bestplay opened this issue Aug 20, 2018 · 12 comments
Closed

Comments

@bestplay
Copy link

bestplay commented Aug 20, 2018

System information

Geth version: 1.8.13
Golang version: 1.10.3
OS & Version: Windows64
Commit hash : (if develop)

Expected behaviour

Build without cgo

Actual behaviour

....\vendor\github.com\ethereum\go-ethereum\crypto\signature_cgo.go:27:2: build constraints exclude all Go files in D:***\src\prjname\vendor\github.com\ethereum\go-ethereum\crypto\secp256k1

Steps to reproduce the behaviour

set CGO_ENABLED=0

More Info

Since #3680 merged (crypto: add btcec fallback for sign/recover without cgo)

@fjl

@karalabe
Copy link
Member

That library is not correct. I know of at least @whyrusleeping who found some issues in the signature verification. It has not been battle tested, nor probably audited. We use it for some tests, but you should not rely on it. Please keep the C version of secp256k1.

@bestplay
Copy link
Author

bestplay commented Aug 20, 2018

Thanks @karalabe . But when i use xgo to cross compile local project which imported geth/core/crypto,

I encounter issues like:

go: GOPATH entry is relative; must be absolute path: "\\ext-go\\1".

xgo issue 115

But xgo . also not work.

xgo github.com/karalabe/xgo works fine.

That is why i am looking for a nocgo solution.

@pawmart
Copy link

pawmart commented Oct 11, 2018

Is there any known solution to this problem? Can't compile my code with ethereum client ;/

@antonzhukov
Copy link

Any updates on this?

@decipherpunk
Copy link

Any solution to this ?

'vendor/github.com/ethereum/go-ethereum/crypto/signature_cgo.go:27:2: build constraints exclude all Go files in /go/src/app/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1
ERROR: compose.cli.main.main: Service 'app' failed to build: The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main main.go' returned a non-zero code: 1

@karalabe
Copy link
Member

karalabe commented Nov 9, 2018

You disabled CGO CGO_ENABLED=0 and then complain that C files don't build?

@decipherpunk
Copy link

decipherpunk commented Nov 9, 2018

@karalabe thanks for the response

I did that because my build failed with the following error

app/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1
vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/curve.go:42:44: fatal error: libsecp256k1/include/secp256k1.h: No such file or directory
#include "libsecp256k1/include/secp256k1.h"
^
compilation terminated.
ERROR: compose.cli.main.main: Service 'app' failed to build: The command '/bin/sh -c go build -o main main.go' returned a non-zero code: 2

I am unable to understand what is causing this, Can you please advise a work around ?

Thanks

@karalabe
Copy link
Member

karalabe commented Nov 9, 2018

When you vendored in geth, you probably didn't explicitly pull in the header files. Most go vendoring tools are incapable of handling folder without Go sources in them. We also have a special rule on our own repo to pull in all subfolders of secp256k1.

@decipherpunk
Copy link

@karalabe your actually right, i just did a fix to my build flow, a nice tool that came in handy https://github.com/nomad-software/vend

Thank you so much for such a swift response on this issue.

Cheers!

@karalabe
Copy link
Member

karalabe commented Nov 9, 2018

We use govendor. It was the best we could find until now.

@decipherpunk
Copy link

Sadly, i got hooked on to dep tool for last 3 months, switched from glide eventually, definitely going to take a look at govendor.

Thanks @karalabe 👍

@mrFranklin
Copy link
Contributor

@karalabe
Is it possible that we remove the c files and replace them by go files?
because when we want to have a slim go app docker, we may set CGO_ENABLED=0

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

8 participants