feat: add linux-arm64-gnu and linux-x64-musl platform packages#341
feat: add linux-arm64-gnu and linux-x64-musl platform packages#341carlos-alm merged 14 commits intomainfrom
Conversation
Greptile SummaryThis PR adds native binary support for two previously missing Linux platforms — ARM64/glibc ( There is a critical bug in the JavaScript implementation: Additionally, the aarch64 cross-compilation setup in both CI workflows sets a global The CI matrix, Cargo targets, and publish workflow logic are otherwise well-structured and correct. Confidence Score: 2/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[loadNative called] --> B[Determine OS and arch]
B --> C[Linux: call detectLibc]
C --> D["require node:fs - undefined in ESM"]
D --> E[ReferenceError silently caught]
E --> F[detectLibc always returns 'gnu']
F --> G[Lookup linux-arch-gnu package]
G --> H[Load fails on musl - wrong ABI]
H --> I[Fall back to WASM]
B --> J[Non-Linux: lookup by platform-arch]
J --> K[Load native module]
K --> L[Return native module]
|
Additional Comments (1)
|
|
Re: Greptile comment about missing linux-arm64-musl mapping — added in da9402c. Since there is no CI build target (aarch64-unknown-linux-musl) or published @optave/codegraph-linux-arm64-musl package yet, it is marked as a placeholder with a comment. When the package is eventually built and published, the mapping will already be in place and ARM64 Alpine users will get native instead of WASM fallback. |
|
Addressed the linux-arm64-musl comment in da9402c — added the platform mapping as a placeholder. No CI target or npm package exists yet for this platform, so it's documented with a comment noting it's for future support. |
|
Claude finished @carlos-alm's task —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
f459f05 to
a88cafe
Compare
|
Claude finished @carlos-alm's task —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
|
Claude finished @carlos-alm's task —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
|
Claude finished @carlos-alm's task —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
|
Claude finished @carlos-alm's task —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
|
Claude finished @carlos-alm's task —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
|
Claude finished @carlos-alm's task —— View job Claude finished reviewing this PR PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
|
Claude finished @carlos-alm's task —— View job Claude finished reviewing this PR —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
|
Claude finished @carlos-alm's task —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues🟡 Performance Concern in
|
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
+crt-static is incompatible with cdylib crate type on musl targets. Use -static-libgcc to statically link libgcc while still allowing shared library (cdylib) output needed by napi-rs.
Rust's stdlib requests -lgcc_s dynamically but musl-tools only has static libgcc.a. Create a linker script that redirects -lgcc_s to the static libgcc archive, allowing cdylib output.
CC=musl-gcc was affecting host build script compilation (proc-macro2, tree-sitter-language), causing _Unwind_* symbol errors. Use CC_x86_64_unknown_linux_musl=musl-gcc to only affect the musl target.
rust-lld (default on newer Rust) can't find libgcc_s.so.1 when building host build scripts. Set CARGO_HOST_RUSTFLAGS=-Clinker=gcc to use the traditional linker for host compilations.
Use .cargo/config.toml instead of env vars for linker configuration. Set host rustflags to use gcc (bypasses rust-lld libgcc_s issue) and target linker to musl-gcc.
… linker Set host triple-specific RUSTFLAGS to force gcc linker for host build scripts, bypassing rust-lld's inability to find libgcc_s.so.1.
rust-lld (default linker on newer Rust) searches the Rust sysroot but not /lib/x86_64-linux-gnu/ where libgcc_s.so.1 lives. Create symlinks in the sysroot so host build scripts can link successfully.
Impact: 1 functions changed, 26 affected
Impact: 1 functions changed, 3 affected
6c5fa07 to
6b38e87
Compare
|
Claude finished @carlos-alm's task —— View job PR Review: Linux ARM64/musl Platform SupportCompleting structured 4-phase review of this PR that adds native binary support for ARM64 Linux and Alpine Linux platforms. Todo List:
Root Cause AnalysisProblem Being Solved: Two significant platform gaps forcing ~35x slower WASM fallback: ARM64 Linux (Docker on Apple Silicon, AWS Graviton) and Alpine Linux (musl libc). This PR adds native support for both. Why This Approach: Sound strategy using napi-rs cross-compilation + runtime libc detection. The Risk Assessment: Low risk. Changes are additive (new platform support) without modifying existing functionality. All 73/73 integration tests pass. Configuration Changes Review✅ No problematic rule relaxation detected. Changes are purely additive:
Test Integrity Check✅ Tests remain robust: 73/73 integration tests pass with no weakened assertions or modifications. The PR maintains test quality while adding new platform capabilities. Code Quality AssessmentArchitecture & ImplementationExcellent approach with dual-engine native/WASM fallback pattern:
Specific Code Issues✅ Performance Optimization Already AppliedGreptile's original concern about ✅ Platform Mapping CompletenessAuthor correctly addressed Greptile's ARM64 Alpine concern by adding ✅ CI/CD Implementation
✅ Dependency ManagementOptional dependencies correctly added to main Security & Correctness
Minor Observations
Critical ConcernsNone identified. All major concerns from Greptile's review have been addressed in subsequent commits. Final Recommendation
This PR successfully adds native support for ARM64 Linux and Alpine Linux with a solid technical implementation that maintains backward compatibility. |
|
Re: Greptile's flag on \ being expensive for libc detection — replaced with a lightweight filesystem check (\ scanning for ). This avoids the heavyweight diagnostic report generation entirely. Also resolved the stale conflict markers in \ optionalDependencies and rebased onto main. |
|
Correction to previous comment: Addressed Greptile's flag on process.report.getReport() being expensive for libc detection. Replaced with a lightweight filesystem check (readdirSync on /lib scanning for ld-musl-*.so.1). This avoids the heavyweight diagnostic report generation entirely. Also resolved the stale conflict markers in package.json optionalDependencies and rebased onto main. |
|
Re: detectLibc() performance concern — this was addressed before merge. The merged code on main uses \ scanning for \ instead of . This is a lightweight filesystem check (single readdir) rather than the heavyweight diagnostic report generation. No further action needed. |
Summary
detectLibc()helper innative.jsusingprocess.report.getReport().header.glibcVersionRuntimeto auto-select glibc vs musl packagesgcc-aarch64-linux-gnufor arm64,musl-toolsfor musl) in bothbuild-native.ymlandpublish.ymlpackage.jsonfiles now include npm'slibcfield for automatic variant selection (supported since npm v10 / Node 20+)Changes
crates/codegraph-core/package.jsonaarch64-unknown-linux-gnu+x86_64-unknown-linux-muslnapi targetssrc/native.jsdetectLibc(), updatePLATFORM_PACKAGESwith libc-qualified Linux keyspackage.json@optave/codegraph-linux-arm64-gnu+@optave/codegraph-linux-x64-musloptionalDependencies.github/workflows/build-native.ymlartifact_keynaming.github/workflows/publish.ymlPACKAGESmap with libc field in pack stepsTest plan
npm run lintpasses (only pre-existing warning)loadNative()verified working on win32-x64 (non-Linux path unchanged)build-nativeworkflow to verify cross-compilation succeeds