A workaround to call your external library function without CGo overhead.
- cgo direct call (no CGo wrapper, example in SystemV amd64)
- cross platform compat (with
zig cc
) *
* for direct call, be sure you have prepared right calling convention, like eg. Microsoft x64 had RCX
as their first argument. (Also please check if caller is from G/T)
This due to compiler generateed results (specified by -target
on Makefile
) is platform specific (although the source is not), and also the linker (eg. ELF, PE, MACH-O, etc etc).
On asm2asm
approach, transpiler consume ATT-syntax asm generated by clang
and outputting Go's Plan9. clang
target is not specified so the reasonable fallback is the platform that runs it.
Snipped from asm2asm/asm2asm.py is SystemV amd64 ABI for caller to put arguments:
ARGS_ORDER = [ Register('rdi'), Register('rsi'), Register('rdx'),
Register('rcx'), Register('r8'), Register('r9') ]
The platform boundary is on Asm wrapper that call transpiled native function, that's why Windows support for bytedance/sonic just work like magic.
make build-native
# compile nodebug
make build
# compile debug
make debug
# compile debug and dump asm
make dmp