Skip to content

feat: add linux-arm64-gnu and linux-x64-musl platform packages#341

Open
carlos-alm wants to merge 2 commits intomainfrom
feat/linux-arm64-musl-platforms
Open

feat: add linux-arm64-gnu and linux-x64-musl platform packages#341
carlos-alm wants to merge 2 commits intomainfrom
feat/linux-arm64-musl-platforms

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Adds native binary support for ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc), the two biggest platform gaps that currently force ~35x slower WASM fallback
  • Adds detectLibc() helper in native.js using process.report.getReport().header.glibcVersionRuntime to auto-select glibc vs musl packages
  • Adds cross-compilation CI steps (gcc-aarch64-linux-gnu for arm64, musl-tools for musl) in both build-native.yml and publish.yml
  • Generated platform package.json files now include npm's libc field for automatic variant selection (supported since npm v10 / Node 20+)

Changes

File What
crates/codegraph-core/package.json Add aarch64-unknown-linux-gnu + x86_64-unknown-linux-musl napi targets
src/native.js Add detectLibc(), update PLATFORM_PACKAGES with libc-qualified Linux keys
package.json Add @optave/codegraph-linux-arm64-gnu + @optave/codegraph-linux-x64-musl optionalDependencies
.github/workflows/build-native.yml Add 2 matrix entries, cross-compilation steps, artifact_key naming
.github/workflows/publish.yml Same matrix changes + structured PACKAGES map with libc field in pack steps

Test plan

  • npm run lint passes (only pre-existing warning)
  • 73/73 query integration tests pass
  • loadNative() verified working on win32-x64 (non-Linux path unchanged)
  • Trigger build-native workflow to verify cross-compilation succeeds
  • Test on actual ARM64 Linux and Alpine containers after first build

Add native binary support for ARM64 Linux (Docker on Apple Silicon, AWS
Graviton) and Alpine Linux (musl), closing the two biggest platform gaps
that currently force a ~35x slower WASM fallback.

- Add aarch64-unknown-linux-gnu and x86_64-unknown-linux-musl napi targets
- Add detectLibc() helper using process.report to distinguish glibc/musl
- Update PLATFORM_PACKAGES with libc-qualified Linux keys
- Add cross-compilation steps in CI (gcc-aarch64-linux-gnu, musl-tools)
- Add npm libc field to generated platform package.json for auto-selection
- Switch artifact naming to artifact_key for consistency across platforms

Impact: 2 functions changed, 3 affected
@greptile-apps
Copy link

greptile-apps bot commented Mar 4, 2026

Greptile Summary

This PR adds native binary support for ARM64 Linux (glibc) and Alpine Linux x64 (musl), closing major platform gaps that previously forced WASM fallback. The implementation is well-structured with a new detectLibc() helper that uses process.report.getReport().header.glibcVersionRuntime to distinguish between glibc and musl systems. Both CI workflows (build-native.yml and publish.yml) are updated with cross-compilation steps using gcc-aarch64-linux-gnu for ARM64 and musl-tools for musl builds. The package generation correctly includes npm's libc field for automatic variant selection.

Key changes:

  • Added aarch64-unknown-linux-gnu and x86_64-unknown-linux-musl napi targets
  • Implemented libc detection logic in native.js with platform key construction
  • Updated CI matrix with cross-compilation tooling and consistent artifact naming
  • Generated platform packages now include libc field for npm auto-selection
  • Version bumped to 3.0.2 with comprehensive changelog

Note: ARM64 Alpine (linux-arm64-musl) is not included in this PR - users on that platform will continue using WASM fallback.

Confidence Score: 5/5

  • Safe to merge - well-structured platform expansion with proper cross-compilation setup and graceful fallbacks
  • The implementation is comprehensive and follows best practices for multi-platform native addon distribution. Cross-compilation is properly configured with appropriate toolchains, the libc detection logic is sound, and the package generation includes npm's standard libc field for automatic variant selection. The code maintains backward compatibility and includes graceful WASM fallback for unsupported platforms. All changes are additive with no breaking modifications to existing platform support.
  • No files require special attention - all changes are straightforward platform additions

Important Files Changed

Filename Overview
src/native.js Added detectLibc() helper and updated platform key logic to support glibc vs musl differentiation; missing linux-arm64-musl support
package.json Added new optional dependencies for linux-arm64-gnu and linux-x64-musl packages, version bumped to 3.0.2
crates/codegraph-core/package.json Added aarch64-unknown-linux-gnu and x86_64-unknown-linux-musl to napi targets
.github/workflows/build-native.yml Added two new Linux matrix entries with cross-compilation tooling setup (gcc-aarch64-linux-gnu, musl-tools) and consistent artifact_key naming
.github/workflows/publish.yml Added new platform matrix entries and updated package generation script to include libc field for Linux packages using structured pipe-delimited format

Last reviewed commit: e0fe0c1

@greptile-apps
Copy link

greptile-apps bot commented Mar 4, 2026

Additional Comments (1)

src/native.js, line 37
Missing linux-arm64-musl - users on ARM64 Alpine will fall back to WASM instead of native. Consider adding if ARM64 Alpine support is desired.

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