emmansun / gmsm

ShangMi (SM) cipher suites for golang (Go语言商用密码软件)
https://emmansun.github.io/gmsm
MIT License
340 stars 62 forks source link

[plugin] Failed to compile as go plugin at buildmode=plugin #202

Closed craftleon closed 10 months ago

craftleon commented 10 months ago

Hello, your gmsm packages are awesome. When I build plugin module with gmsm imports, go complains about assembly failure as below:

github.com/emmansun/gmsm/internal/sm2ec github.com/emmansun/gmsm/internal/subtle github.com/emmansun/gmsm/kdf github.com/emmansun/gmsm/sm3

github.com/emmansun/gmsm/internal/sm2ec

asm: p256_asm_amd64.s:656: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00630 (/home/zengl/go/pkg/mod/github.com/emmansun/gmsm@v0.24.1/internal/sm2ec/p256_asm_amd64.s:656) MULQ R15 asm: p256_asm_amd64.s:1325: when dynamic linking, R15 is clobbered by a global variable access and is used here: 01181 (/home/zengl/go/pkg/mod/github.com/emmansun/gmsm@v0.24.1/internal/sm2ec/p256_asm_amd64.s:1325) MOVL R15, 488(SP) asm: assembly failed

Issue context: gmsm version v0.24.1 go version: 1.20.5 or 1.21.6. Both version have this failure but 1.21.6 has less complaints than 1.20.5. This error never happens when I build the project as app or shared library. I am not sure if it is due to go made some restrictions on assembly compilation at plugin build mode.

emmansun commented 10 months ago

pls refer #154

craftleon commented 10 months ago

pls refer #154

Thanks for your reply. Hope native asm can be supported in plugin mode in the future (mostly by Go). For now, I will try purego.

emmansun commented 10 months ago

You can try -tags=plugin