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

When dynamic linking, R15 may be clobbered by a global variable access #113

Closed
gbotrel opened this issue Dec 14, 2021 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@gbotrel
Copy link
Collaborator

gbotrel commented Dec 14, 2021

See also #112 .

Can reproduce on x86 machine with

go build -linkshared ./...

For small moduli (<= 5 words) we can avoid the use of R15 register, a fix will be pushed in the code generator.

For larger moduli:

  • define qInv0 and qElement as constants through a define macro (imm)
  • put qElement on the stack at the start of the function
  • .. ?

however, for large moduli, this impact performance. Tracking the issue here, one option would be to use build tags for dynamic linking and a slower path.

@gbotrel gbotrel added the bug Something isn't working label Dec 14, 2021
@gbotrel gbotrel self-assigned this Dec 14, 2021
gbotrel added a commit that referenced this issue Dec 14, 2021
fix: remove use of R15 for small moduli mul #113
@gbotrel gbotrel closed this as completed Aug 18, 2023
@ale-linux
Copy link

The issue seems to be back

$ go build -linkshared ./...
# github.com/consensys/gnark-crypto/ecc/bn254/fr/mimc/test_vectors
/home/aso/local/go/pkg/tool/linux_amd64/link: cannot implicitly include runtime/cgo in a shared library
# github.com/consensys/gnark-crypto/ecc/bls12-377/fp
asm: element_mul_amd64.s:93: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00012 (/home/aso/w/Projects/OBC/Workspace/src/github.com/Consensys/gnark-crypto/ecc/bls12-377/fp/element_mul_amd64.s:93)      MULXQ   R10, R14, R15
asm: assembly failed
# github.com/consensys/gnark-crypto/ecc/bls12-378/fp
asm: element_mul_amd64.s:93: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00012 (/home/aso/w/Projects/OBC/Workspace/src/github.com/Consensys/gnark-crypto/ecc/bls12-378/fp/element_mul_amd64.s:93)      MULXQ   R10, R14, R15
asm: assembly failed
# github.com/consensys/gnark-crypto/ecc/bls12-381/fp
asm: element_mul_amd64.s:93: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00012 (/home/aso/w/Projects/OBC/Workspace/src/github.com/Consensys/gnark-crypto/ecc/bls12-381/fp/element_mul_amd64.s:93)      MULXQ   R10, R14, R15
asm: assembly failed
# github.com/consensys/gnark-crypto/ecc/bw6-761/fr
asm: element_mul_amd64.s:93: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00012 (/home/aso/w/Projects/OBC/Workspace/src/github.com/Consensys/gnark-crypto/ecc/bw6-761/fr/element_mul_amd64.s:93)        MULXQ   R10, R14, R15
asm: assembly failed
# github.com/consensys/gnark-crypto/ecc/bw6-756/fr
asm: element_mul_amd64.s:93: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00012 (/home/aso/w/Projects/OBC/Workspace/src/github.com/Consensys/gnark-crypto/ecc/bw6-756/fr/element_mul_amd64.s:93)        MULXQ   R10, R14, R15
asm: assembly failed
# github.com/consensys/gnark-crypto/ecc/bw6-633/fp
asm: element_mul_amd64.s:106: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00009 (/home/aso/w/Projects/OBC/Workspace/src/github.com/Consensys/gnark-crypto/ecc/bw6-633/fp/element_mul_amd64.s:106)      MULXQ   (R12), R14, R15
asm: assembly failed

@ale-linux
Copy link

@gbotrel ^

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

No branches or pull requests

2 participants