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

bug: broken vendoring in [email protected] #619

Closed
nickeskov opened this issue Jan 28, 2025 · 2 comments · Fixed by #620
Closed

bug: broken vendoring in [email protected] #619

nickeskov opened this issue Jan 28, 2025 · 2 comments · Fixed by #620
Assignees
Labels
bug Something isn't working

Comments

@nickeskov
Copy link

Description

When using vendoring (go mod vendor) and then compiling dependencies, an error appears regarding missing .s files.

I'll demonstrate the compilation error using the gowaves project as an example.
When attempting to build the executable, the following error messages appear from the go compiler.

Go compiler output

# github.com/consensys/gnark-crypto/ecc/bls12-377/fp
vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/fp/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_6w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bls12-381/fp
vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/fp/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_6w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bls24-315/fp
vendor/github.com/consensys/gnark-crypto/ecc/bls24-315/fp/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_5w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bls24-317/fp
vendor/github.com/consensys/gnark-crypto/ecc/bls24-317/fp/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_5w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bn254/fp
vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_4w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bw6-633/fp
vendor/github.com/consensys/gnark-crypto/ecc/bw6-633/fp/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_10w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bw6-761/fp
vendor/github.com/consensys/gnark-crypto/ecc/bw6-761/fp/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_12w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bn254/fr
vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_4w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bls12-377/fr
vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/fr/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_4w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bls12-381/fr
vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/fr/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_4w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bls24-315/fr
vendor/github.com/consensys/gnark-crypto/ecc/bls24-315/fr/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_4w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bls24-317/fr
vendor/github.com/consensys/gnark-crypto/ecc/bls24-317/fr/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_4w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bw6-633/fr
vendor/github.com/consensys/gnark-crypto/ecc/bw6-633/fr/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_5w_amd64.s: no such file or directory
# github.com/consensys/gnark-crypto/ecc/bw6-761/fr
vendor/github.com/consensys/gnark-crypto/ecc/bw6-761/fr/element_amd64.s:10: #include: open /usr/local/opt/go/field/asm/element_6w_amd64.s: no such file or directory

The issue does not occur when vendoring is not used.

Expected Behavior

Successful compilation both with and without vendoring.

Actual Behavior

Compilation works fine without vendoring.
With go mod vendor compilation fails with the error described above.

Steps to Reproduce

  1. Clone gowaves
  2. Run go get github.com/consensys/[email protected] in the project directory (it also updates gnark-crypto to 0.15.0)
  3. Run go mod tidy && go mod vendor in the project directory
  4. Run make build-node-native in the project directory which is equivalent to go build -o build/bin/native/node ./cmd/node
  5. Observe the output

Context

Vendoring support is necessary for us in the gowaves project.

Your Environment

  • gnark-crypto version used: 0.15.0
  • go version (e.g. 1.20.6): go1.23.5 and go1.22.11
  • Operating System and version: macOS 14.7.2 and ubuntu-24.04
@nickeskov nickeskov changed the title bug: broken vendoring in *gnark-crypto 0.15.0* bug: broken vendoring in [email protected] Jan 28, 2025
@gbotrel gbotrel self-assigned this Jan 28, 2025
@gbotrel gbotrel added the bug Something isn't working label Jan 28, 2025
@gbotrel
Copy link
Collaborator

gbotrel commented Jan 28, 2025

Managed to reproduced easily on an empty project. Thanks for the report.

Possible fixes (cc @ivokub, thoughts?) :

  1. We revert to generating assembly files directly per package and duplicate things. The only silly thing that bother me here, is that then github classify gnark-crypto as assembly project whereas we just have 3 or 4 methods in assembly 🙄
  2. Ugly hack but should work; we use a dummy //go:embed directive to force go mod vendor to include the file. I think that would increase binary size of about 5kb for most modulus, 50kb for the fat ones with more assembly.. not too bad but could lead to unwanted side effects in some environments.
  3. put the assembly files in proper go packages maybe internal, export methods, call them. most cases the compiler should inline the wrapper just fine (edit: I hope).

@nickeskov
Copy link
Author

Thank you for the fix. Works for us. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants