Skip to content

Conversation

pk910
Copy link

@pk910 pk910 commented Oct 19, 2025

Problem

The existing .syso file approach was causing persistent CGO warnings for all downstream projects:

loadinternal: cannot find runtime/cgo

This warning appeared even with CGO_ENABLED=1 because Go's linker detected native code in .syso files but couldn't find the CGO runtime. The warning was harmless but annoying and unprofessional for library users.

Solution

Replaced .syso files with proper CGO bindings using pre-built platform-specific static libraries.

What Changed

  1. Removed problematic files:

    • All *.syso files
    • Assembly wrapper files (wrapper_*.s)
    • Platform-specific Go files (bindings_*.go)
  2. Added platform-specific CGO bindings:

    • cgo_linux_amd64.go - Linux x86_64 with AVX2/AVX512/SHANI optimizations
    • cgo_linux_arm64.go - Linux ARM64 with SHA2 optimizations
    • cgo_darwin_arm64.go - macOS Apple Silicon with SHA2 optimizations
    • cgo_windows_amd64.go - Windows x86_64 with AVX2/AVX512/SHANI optimizations
    • cgo_fallback.go - Pure Go fallback when CGO disabled
  3. Pre-built static libraries:

    • lib/linux_amd64/libhashtree.a - Native Linux x86_64 build
    • lib/linux_arm64/libhashtree.a - Cross-compiled ARM64 build
    • lib/darwin_arm64/libhashtree.a - Native macOS ARM64 build
    • lib/windows_amd64/libhashtree.a - Native Windows MinGW build
  4. GitHub Actions workflow:

    • Builds libraries on appropriate native systems (ubuntu-22.04, macos-14, windows-latest)
    • Uses compatibility flags for broader platform support
    • Automatically builds libraries when source changes
    • Uploads build artifacts for simple copy & commit back to repo on demand
  5. Restored original CPU feature detection:

    • x86_64: supportedCPU = hasAVX2 || hasShani || hasAVX512
    • ARM64: supportedCPU = hasShani (improved from original true)

@pk910 pk910 force-pushed the pk910/use-static-libraries branch from 5218435 to 30dd36e Compare October 19, 2025 01:13
@pk910 pk910 force-pushed the pk910/use-static-libraries branch 6 times, most recently from 8a5d865 to eafc871 Compare October 19, 2025 02:03
@pk910 pk910 force-pushed the pk910/use-static-libraries branch from eafc871 to 0aebff0 Compare October 19, 2025 02:06
@pk910
Copy link
Author

pk910 commented Oct 19, 2025

should fix #7 & #52

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.

1 participant