emmansun / gmsm

ShangMi (SM) cipher suites for golang (Go语言商用密码软件)

Home Page:https://emmansun.github.io/gmsm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

craftleon opened this issue · comments

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.

pls refer #154

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.

You can try -tags=plugin