Skip to content

docs: document pureffi as a solution for purego duplicate symbol conflicts#50

Merged
kolkov merged 1 commit into
go-webgpu:mainfrom
unxed:puregodoc
May 26, 2026
Merged

docs: document pureffi as a solution for purego duplicate symbol conflicts#50
kolkov merged 1 commit into
go-webgpu:mainfrom
unxed:puregodoc

Conversation

@unxed
Copy link
Copy Markdown

@unxed unxed commented May 25, 2026

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.

…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.
@unxed unxed requested a review from kolkov as a code owner May 25, 2026 20:41
Copy link
Copy Markdown
Contributor

@kolkov kolkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 FreeBSD

Real 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.

@unxed
Copy link
Copy Markdown
Author

unxed commented May 26, 2026

Thanks for review! Check now pls

Copy link
Copy Markdown
Contributor

@kolkov kolkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fixes verified: errors import, RTLD_DEFAULT/RTLD_GLOBAL per-OS split, cfn==0 guard. LGTM.

@kolkov kolkov merged commit ea43a79 into go-webgpu:main May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants