cloudflare / circl

CIRCL: Cloudflare Interoperable Reusable Cryptographic Library
http://blog.cloudflare.com/introducing-circl
Other
1.27k stars 142 forks source link

go plugin not compiling #391

Closed JensAc closed 1 year ago

JensAc commented 1 year ago

Hi, when I try to build a plugin containing circl like so

go build -buildmode=plugin

I get:

asm: fp_amd64.s:68: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00215 (....l/vendor/github.com/cloudflare/circl/math/fp25519/fp_amd64.s:68)  MULXQ   24(SI), AX, R15
asm: assembly failed

I am sorry, but I have no idea on debugging this. I found similar issues which let me assume that some upstream change could be required. If you find time to look into this, I would really appreciate your help.

JensAc commented 1 year ago

So, now I did some research on this. This issue is that the R15 register cannot be used in assembly, when compiling in plugin mode. Therefore, replacing the R15 register by the DI register could do the trick, as also done here. Would that be an option for this codebase as well? If yes, I could file a PR.

bwesterb commented 1 year ago

Sorry for the late reply. I think your analysis is correct and I think we would take that PR. @armfazh you agree?

(If so, we should add plugin compilation to the CI.)

armfazh commented 1 year ago

Update, I have checked spots in which compilation does not succeed due to R15 register. I am working on patching the code, and pretty close to have CIRCL compiling as a plugin.