docs: document pureffi as a solution for purego duplicate symbol conflicts#50
Conversation
…licts This update adds unxed/pureffi to the README as a recommended workaround for resolving the fakecgo duplicate symbol linker conflict on Unix platforms. By implementing the complete purego API on top of the goffi engine, this library allows developers to combine both ecosystems inside a single, CGO-free binary without requiring compile-time build tags.
kolkov
left a comment
There was a problem hiding this comment.
@unxed Thank you for building pureffi — the concept is sound and solves a real problem (Issue #22). We've done a thorough code review of the pureffi codebase before merging this README change.
We found a few issues that should be fixed in pureffi before we can document it in our README:
1. Missing "errors" import in objc package (compile failure on Darwin)
objc/objc_runtime_darwin.go uses errors.New() at lines 448, 455, 469, 473 but does not import "errors". The objc package fails to compile on Darwin — the primary platform where the Apple Silicon variadic fix matters.
One-line fix: add "errors" to the import block.
2. Incorrect RTLD constants for Darwin and FreeBSD
dlfcn_unix.go defines a single set of constants for all Unix platforms:
RTLD_DEFAULT = 0 // Wrong on Darwin (should be ^uintptr(0)-1) and FreeBSD
RTLD_GLOBAL = 8 // Wrong on Linux (should be 0x100) and FreeBSDReal purego uses per-platform files (dlfcn_darwin.go, dlfcn_linux.go, dlfcn_freebsd.go) with correct values. The wrong RTLD_DEFAULT on Darwin causes Dlsym(RTLD_DEFAULT, "free") to fail — which panics at objc init time.
Your own sym_unix.go already hard-codes the correct Darwin value (^uintptr(0) - 1) internally — the public constant just needs to match.
Fix: split dlfcn_unix.go into per-platform files with correct constants from purego.
3. Missing cfn == 0 guard in RegisterFunc
Real purego panics early with a clear message when cfn is zero. pureffi passes unsafe.Pointer(0) through to goffi, producing a confusing deep error. Add:
if cfn == 0 {
panic("purego: cfn is nil")
}Once these are fixed
Once you've pushed the fixes to pureffi, let us know and we'll merge this PR. The README text looks good — we're happy to document pureffi as a workaround for #22.
|
Thanks for review! Check now pls |
kolkov
left a comment
There was a problem hiding this comment.
All fixes verified: errors import, RTLD_DEFAULT/RTLD_GLOBAL per-OS split, cfn==0 guard. LGTM.
This update adds unxed/pureffi to the README as a recommended workaround for resolving the fakecgo duplicate symbol linker conflict on Unix platforms. By implementing the complete purego API on top of the goffi engine, this library allows developers to combine both ecosystems inside a single, CGO-free binary without requiring compile-time build tags.