From 8b01680b0653484889798ba63f6a182bfb26458e Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 00:06:07 -0700 Subject: [PATCH 01/14] chore: release v3.0.2 --- CHANGELOG.md | 1 + package.json | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4573de3..82e484b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. See [commit * **ast:** use single transaction for AST node insertion — astMs drops from ~3600ms to ~350ms (native) and ~547ms (WASM), reducing overall native build from 24.9 to 8.5 ms/file ([#333](https://github.com/optave/codegraph/pull/333)) + ## [3.0.2](https://github.com/optave/codegraph/compare/v3.0.1...v3.0.2) (2026-03-04) **Dataflow goes multi-language, build performance recovery, and native engine parity fixes.** This patch extends dataflow analysis from JS/TS-only to all 11 supported languages, recovers build performance lost after CFG/dataflow became default-on, fixes language-aware identifier collection in dataflow, and closes a native engine scoping bug for constants. diff --git a/package.json b/package.json index 0955e7e..e8b68ea 100644 --- a/package.json +++ b/package.json @@ -71,10 +71,17 @@ }, "optionalDependencies": { "@modelcontextprotocol/sdk": "^1.0.0", +<<<<<<< HEAD "@optave/codegraph-darwin-arm64": "3.0.3", "@optave/codegraph-darwin-x64": "3.0.3", "@optave/codegraph-linux-x64-gnu": "3.0.3", "@optave/codegraph-win32-x64-msvc": "3.0.3" +======= + "@optave/codegraph-darwin-arm64": "3.0.2", + "@optave/codegraph-darwin-x64": "3.0.2", + "@optave/codegraph-linux-x64-gnu": "3.0.2", + "@optave/codegraph-win32-x64-msvc": "3.0.2" +>>>>>>> 1165472 (chore: release v3.0.2) }, "devDependencies": { "@biomejs/biome": "^2.4.4", From 90b2880a92cc3d81e675170b71e3eb5ba48a29e9 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 02:33:18 -0700 Subject: [PATCH 02/14] feat: add linux-arm64-gnu and linux-x64-musl native platform packages 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 --- .github/workflows/build-native.yml | 34 ++++++++++- .github/workflows/publish.yml | 96 +++++++++++++++++++++++++----- crates/codegraph-core/package.json | 2 + package.json | 2 + src/native.js | 24 +++++++- 5 files changed, 138 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 55ec9e8..e09512d 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -20,18 +20,34 @@ jobs: target: x86_64-unknown-linux-gnu node_arch: x64 node_os: linux + artifact_key: linux-x64 + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + node_arch: arm64 + node_os: linux + artifact_key: linux-arm64 + cross: true + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + node_arch: x64 + node_os: linux + artifact_key: linux-x64-musl + cross: true - os: macos-latest target: aarch64-apple-darwin node_arch: arm64 node_os: darwin + artifact_key: darwin-arm64 - os: macos-14 target: x86_64-apple-darwin node_arch: x64 node_os: darwin + artifact_key: darwin-x64 - os: windows-latest target: x86_64-pc-windows-msvc node_arch: x64 node_os: win32 + artifact_key: win32-x64 runs-on: ${{ matrix.os }} name: Build ${{ matrix.target }} @@ -56,6 +72,22 @@ jobs: with: workspaces: crates/codegraph-core + - name: Install cross-compilation tools (aarch64-gnu) + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" + + - name: Install cross-compilation tools (x86_64-musl) + if: matrix.target == 'x86_64-unknown-linux-musl' + run: | + sudo apt-get update + sudo apt-get install -y musl-tools + echo "CC=musl-gcc" >> "$GITHUB_ENV" + echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" + - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 @@ -66,6 +98,6 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v7 with: - name: native-${{ matrix.node_os }}-${{ matrix.node_arch }} + name: native-${{ matrix.artifact_key }} path: crates/codegraph-core/*.node if-no-files-found: error diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index af9bf17..ba704c5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -97,18 +97,34 @@ jobs: target: x86_64-unknown-linux-gnu node_arch: x64 node_os: linux + artifact_key: linux-x64 + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + node_arch: arm64 + node_os: linux + artifact_key: linux-arm64 + cross: true + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + node_arch: x64 + node_os: linux + artifact_key: linux-x64-musl + cross: true - os: macos-latest target: aarch64-apple-darwin node_arch: arm64 node_os: darwin + artifact_key: darwin-arm64 - os: macos-14 target: x86_64-apple-darwin node_arch: x64 node_os: darwin + artifact_key: darwin-x64 - os: windows-latest target: x86_64-pc-windows-msvc node_arch: x64 node_os: win32 + artifact_key: win32-x64 runs-on: ${{ matrix.os }} name: Build ${{ matrix.target }} @@ -133,6 +149,22 @@ jobs: with: workspaces: crates/codegraph-core + - name: Install cross-compilation tools (aarch64-gnu) + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" + + - name: Install cross-compilation tools (x86_64-musl) + if: matrix.target == 'x86_64-unknown-linux-musl' + run: | + sudo apt-get update + sudo apt-get install -y musl-tools + echo "CC=musl-gcc" >> "$GITHUB_ENV" + echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" + - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 @@ -143,7 +175,7 @@ jobs: - name: Upload native binary uses: actions/upload-artifact@v7 with: - name: native-${{ matrix.node_os }}-${{ matrix.node_arch }} + name: native-${{ matrix.artifact_key }} path: crates/codegraph-core/*.node if-no-files-found: error @@ -189,11 +221,14 @@ jobs: VERSION: ${{ needs.compute-version.outputs.version }} shell: bash run: | + # Format: pkg_name|os|cpu|libc (libc empty for non-linux) declare -A PACKAGES=( - ["linux-x64"]="@optave/codegraph-linux-x64-gnu" - ["darwin-arm64"]="@optave/codegraph-darwin-arm64" - ["darwin-x64"]="@optave/codegraph-darwin-x64" - ["win32-x64"]="@optave/codegraph-win32-x64-msvc" + ["linux-x64"]="@optave/codegraph-linux-x64-gnu|linux|x64|glibc" + ["linux-x64-musl"]="@optave/codegraph-linux-x64-musl|linux|x64|musl" + ["linux-arm64"]="@optave/codegraph-linux-arm64-gnu|linux|arm64|glibc" + ["darwin-arm64"]="@optave/codegraph-darwin-arm64|darwin|arm64|" + ["darwin-x64"]="@optave/codegraph-darwin-x64|darwin|x64|" + ["win32-x64"]="@optave/codegraph-win32-x64-msvc|win32|x64|" ) ARTIFACTS="${RUNNER_TEMP}/artifacts" @@ -201,13 +236,23 @@ jobs: for artifact_dir in "${ARTIFACTS}"/native-*/; do platform=$(basename "$artifact_dir" | sed 's/^native-//') - pkg_name=${PACKAGES[$platform]} - node_os=${platform%%-*} - node_arch=${platform##*-} + entry=${PACKAGES[$platform]} + if [ -z "$entry" ]; then + echo "::warning::Unknown platform artifact: $platform — skipping" + continue + fi + + IFS='|' read -r pkg_name node_os node_arch libc <<< "$entry" mkdir -p "${PKG_DIR}/$platform" cp "$artifact_dir"/*.node "${PKG_DIR}/$platform/codegraph-core.node" + # Build libc field for Linux packages + libc_field="" + if [ -n "$libc" ]; then + libc_field="\"libc\": [\"${libc}\"]," + fi + cat > "${PKG_DIR}/$platform/package.json" < "${PKG_DIR}/$platform/package.json" <>>>>>> 1165472 (chore: release v3.0.2) }, diff --git a/src/native.js b/src/native.js index c2a9090..37ee083 100644 --- a/src/native.js +++ b/src/native.js @@ -12,9 +12,25 @@ import os from 'node:os'; let _cached; // undefined = not yet tried, null = failed, object = module let _loadError = null; -/** Map of (platform-arch) → npm package name. */ +/** + * Detect whether the current Linux environment uses glibc or musl. + * Returns 'gnu' for glibc, 'musl' for musl, 'gnu' as fallback. + */ +function detectLibc() { + try { + const report = process.report.getReport(); + const glibcVersion = report?.header?.glibcVersionRuntime; + return glibcVersion ? 'gnu' : 'musl'; + } catch { + return 'gnu'; + } +} + +/** Map of (platform-arch[-libc]) → npm package name. */ const PLATFORM_PACKAGES = { - 'linux-x64': '@optave/codegraph-linux-x64-gnu', + 'linux-x64-gnu': '@optave/codegraph-linux-x64-gnu', + 'linux-x64-musl': '@optave/codegraph-linux-x64-musl', + 'linux-arm64-gnu': '@optave/codegraph-linux-arm64-gnu', 'darwin-arm64': '@optave/codegraph-darwin-arm64', 'darwin-x64': '@optave/codegraph-darwin-x64', 'win32-x64': '@optave/codegraph-win32-x64-msvc', @@ -29,7 +45,9 @@ export function loadNative() { const require = createRequire(import.meta.url); - const key = `${os.platform()}-${os.arch()}`; + const platform = os.platform(); + const arch = os.arch(); + const key = platform === 'linux' ? `${platform}-${arch}-${detectLibc()}` : `${platform}-${arch}`; const pkg = PLATFORM_PACKAGES[key]; if (pkg) { try { From 10acfa519149b8a26cb8d49b938ced8866346245 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 19:30:55 -0700 Subject: [PATCH 03/14] fix(native): add linux-arm64-musl platform mapping --- src/native.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/native.js b/src/native.js index 37ee083..9b31f11 100644 --- a/src/native.js +++ b/src/native.js @@ -31,6 +31,7 @@ const PLATFORM_PACKAGES = { 'linux-x64-gnu': '@optave/codegraph-linux-x64-gnu', 'linux-x64-musl': '@optave/codegraph-linux-x64-musl', 'linux-arm64-gnu': '@optave/codegraph-linux-arm64-gnu', + 'linux-arm64-musl': '@optave/codegraph-linux-arm64-musl', // not yet published — placeholder for future CI target 'darwin-arm64': '@optave/codegraph-darwin-arm64', 'darwin-x64': '@optave/codegraph-darwin-x64', 'win32-x64': '@optave/codegraph-win32-x64-msvc', From b434172f6f4a13824ea44b4859e81dabc71a84f1 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:17:18 -0700 Subject: [PATCH 04/14] fix(ci): add crt-static for musl target to fix libgcc_s linker error --- .github/workflows/build-native.yml | 1 + .github/workflows/publish.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index e09512d..4c1ff73 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -87,6 +87,7 @@ jobs: sudo apt-get install -y musl-tools echo "CC=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" + echo "RUSTFLAGS=-C target-feature=+crt-static" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ba704c5..5412bc9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -164,6 +164,7 @@ jobs: sudo apt-get install -y musl-tools echo "CC=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" + echo "RUSTFLAGS=-C target-feature=+crt-static" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 From 4d6147d0a48954c9ecbd2b4c64856679c749c0a2 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:23:56 -0700 Subject: [PATCH 05/14] fix(ci): use -static-libgcc instead of +crt-static for musl cdylib +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. --- .github/workflows/build-native.yml | 2 +- .github/workflows/publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 4c1ff73..9c6925a 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -87,7 +87,7 @@ jobs: sudo apt-get install -y musl-tools echo "CC=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - echo "RUSTFLAGS=-C target-feature=+crt-static" >> "$GITHUB_ENV" + echo "RUSTFLAGS=-C link-arg=-static-libgcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5412bc9..73befc9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -164,7 +164,7 @@ jobs: sudo apt-get install -y musl-tools echo "CC=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - echo "RUSTFLAGS=-C target-feature=+crt-static" >> "$GITHUB_ENV" + echo "RUSTFLAGS=-C link-arg=-static-libgcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 From db12314fbc45877b4fac95b9432d32c8dd4eb2f7 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:27:27 -0700 Subject: [PATCH 06/14] fix(ci): create libgcc_s linker script for musl cdylib builds 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. --- .github/workflows/build-native.yml | 4 +++- .github/workflows/publish.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 9c6925a..92fcd95 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -85,9 +85,11 @@ jobs: run: | sudo apt-get update sudo apt-get install -y musl-tools + # Create linker script so -lgcc_s resolves to static libgcc + MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")" + echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null echo "CC=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - echo "RUSTFLAGS=-C link-arg=-static-libgcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 73befc9..430962c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -162,9 +162,11 @@ jobs: run: | sudo apt-get update sudo apt-get install -y musl-tools + # Create linker script so -lgcc_s resolves to static libgcc + MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")" + echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null echo "CC=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - echo "RUSTFLAGS=-C link-arg=-static-libgcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 From 04acefaf6694ae2b3eb304d6ed1b0828e72e673b Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:31:30 -0700 Subject: [PATCH 07/14] fix(ci): use target-specific CC env var for musl cross-compilation 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. --- .github/workflows/build-native.yml | 3 ++- .github/workflows/publish.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 92fcd95..1f1b148 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -88,7 +88,8 @@ jobs: # Create linker script so -lgcc_s resolves to static libgcc MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")" echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null - echo "CC=musl-gcc" >> "$GITHUB_ENV" + # Use target-specific env vars to avoid affecting host build scripts + echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 430962c..db68615 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -165,7 +165,8 @@ jobs: # Create linker script so -lgcc_s resolves to static libgcc MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")" echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null - echo "CC=musl-gcc" >> "$GITHUB_ENV" + # Use target-specific env vars to avoid affecting host build scripts + echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI From b0e5d2a50963521c5138c8536d0672f1f426a570 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:40:10 -0700 Subject: [PATCH 08/14] fix(ci): force gcc linker for host build scripts in musl job 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. --- .github/workflows/build-native.yml | 2 ++ .github/workflows/publish.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 1f1b148..ac8e7b5 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -91,6 +91,8 @@ jobs: # Use target-specific env vars to avoid affecting host build scripts echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" + # Ensure host build scripts don't fail with rust-lld (can't find libgcc_s) + echo "CARGO_HOST_RUSTFLAGS=-Clinker=gcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index db68615..0f4c735 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -168,6 +168,8 @@ jobs: # Use target-specific env vars to avoid affecting host build scripts echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" + # Ensure host build scripts don't fail with rust-lld (can't find libgcc_s) + echo "CARGO_HOST_RUSTFLAGS=-Clinker=gcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 From e7851e83123c3d99fc85e3a16d0e17df4d35e89a Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:43:53 -0700 Subject: [PATCH 09/14] fix(ci): configure musl linkers via .cargo/config.toml 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. --- .github/workflows/build-native.yml | 13 +++++++++---- .github/workflows/publish.yml | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index ac8e7b5..d478b31 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -88,11 +88,16 @@ jobs: # Create linker script so -lgcc_s resolves to static libgcc MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")" echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null - # Use target-specific env vars to avoid affecting host build scripts echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" - echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - # Ensure host build scripts don't fail with rust-lld (can't find libgcc_s) - echo "CARGO_HOST_RUSTFLAGS=-Clinker=gcc" >> "$GITHUB_ENV" + # Configure linkers via .cargo/config.toml (more reliable than env vars) + mkdir -p .cargo + cat >> .cargo/config.toml << 'TOML' + [target.x86_64-unknown-linux-musl] + linker = "musl-gcc" + + [host] + rustflags = ["-C", "linker=gcc"] + TOML - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0f4c735..92701ee 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -165,11 +165,16 @@ jobs: # Create linker script so -lgcc_s resolves to static libgcc MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")" echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null - # Use target-specific env vars to avoid affecting host build scripts echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" - echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - # Ensure host build scripts don't fail with rust-lld (can't find libgcc_s) - echo "CARGO_HOST_RUSTFLAGS=-Clinker=gcc" >> "$GITHUB_ENV" + # Configure linkers via .cargo/config.toml (more reliable than env vars) + mkdir -p .cargo + cat >> .cargo/config.toml << 'TOML' + [target.x86_64-unknown-linux-musl] + linker = "musl-gcc" + + [host] + rustflags = ["-C", "linker=gcc"] + TOML - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 From 30b26274b2749ca294f91e1a9ea1a2fca31c1cb4 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:47:35 -0700 Subject: [PATCH 10/14] fix(ci): use CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS for host 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. --- .github/workflows/build-native.yml | 12 +++--------- .github/workflows/publish.yml | 12 +++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index d478b31..c353836 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -89,15 +89,9 @@ jobs: MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")" echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" - # Configure linkers via .cargo/config.toml (more reliable than env vars) - mkdir -p .cargo - cat >> .cargo/config.toml << 'TOML' - [target.x86_64-unknown-linux-musl] - linker = "musl-gcc" - - [host] - rustflags = ["-C", "linker=gcc"] - TOML + echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" + # Force host build scripts to use gcc (bypasses rust-lld libgcc_s issue) + echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-C linker=gcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 92701ee..b7655c3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -166,15 +166,9 @@ jobs: MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")" echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" - # Configure linkers via .cargo/config.toml (more reliable than env vars) - mkdir -p .cargo - cat >> .cargo/config.toml << 'TOML' - [target.x86_64-unknown-linux-musl] - linker = "musl-gcc" - - [host] - rustflags = ["-C", "linker=gcc"] - TOML + echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" + # Force host build scripts to use gcc (bypasses rust-lld libgcc_s issue) + echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-C linker=gcc" >> "$GITHUB_ENV" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 From d37d27e88d3aae4a51962b39b7ed0569839742d0 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:52:08 -0700 Subject: [PATCH 11/14] fix(ci): symlink libgcc_s into Rust sysroot for musl cross-compilation 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. --- .github/workflows/build-native.yml | 6 ++++-- .github/workflows/publish.yml | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index c353836..fb6760a 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -90,8 +90,10 @@ jobs: echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - # Force host build scripts to use gcc (bypasses rust-lld libgcc_s issue) - echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-C linker=gcc" >> "$GITHUB_ENV" + # Symlink libgcc_s into Rust sysroot so rust-lld can find it for host builds + GNU_LIB="$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/lib" + sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so" + sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so.1" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b7655c3..99c77c9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -167,8 +167,10 @@ jobs: echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV" echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV" - # Force host build scripts to use gcc (bypasses rust-lld libgcc_s issue) - echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-C linker=gcc" >> "$GITHUB_ENV" + # Symlink libgcc_s into Rust sysroot so rust-lld can find it for host builds + GNU_LIB="$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/lib" + sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so" + sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so.1" - name: Install napi-rs CLI run: npm install -g @napi-rs/cli@3 From cc62a35fdc9e34f4de6fa46f5132519e3d74b15a Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Thu, 5 Mar 2026 02:25:15 -0700 Subject: [PATCH 12/14] perf: replace process.report with filesystem check in detectLibc Impact: 1 functions changed, 26 affected --- src/native.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/native.js b/src/native.js index 9b31f11..3d72d3a 100644 --- a/src/native.js +++ b/src/native.js @@ -18,12 +18,13 @@ let _loadError = null; */ function detectLibc() { try { - const report = process.report.getReport(); - const glibcVersion = report?.header?.glibcVersionRuntime; - return glibcVersion ? 'gnu' : 'musl'; - } catch { - return 'gnu'; - } + const { readdirSync } = require('fs'); + const files = readdirSync('/lib'); + if (files.some(f => f.startsWith('ld-musl-') && f.endsWith('.so.1'))) { + return 'musl'; + } + } catch {} + return 'gnu'; } /** Map of (platform-arch[-libc]) → npm package name. */ From d653a00ab550df8e901cd745b3912b571cd2aceb Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Thu, 5 Mar 2026 02:25:30 -0700 Subject: [PATCH 13/14] style: fix lint issues in detectLibc Impact: 1 functions changed, 3 affected --- src/native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/native.js b/src/native.js index 3d72d3a..785ba1b 100644 --- a/src/native.js +++ b/src/native.js @@ -18,9 +18,9 @@ let _loadError = null; */ function detectLibc() { try { - const { readdirSync } = require('fs'); + const { readdirSync } = require('node:fs'); const files = readdirSync('/lib'); - if (files.some(f => f.startsWith('ld-musl-') && f.endsWith('.so.1'))) { + if (files.some((f) => f.startsWith('ld-musl-') && f.endsWith('.so.1'))) { return 'musl'; } } catch {} From 6b38e87dad9fa73425300db2d34d9d654ef7770e Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Thu, 5 Mar 2026 02:26:53 -0700 Subject: [PATCH 14/14] fix: resolve conflict markers in package.json optionalDependencies --- package.json | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 12f9a81..e30a484 100644 --- a/package.json +++ b/package.json @@ -71,19 +71,13 @@ }, "optionalDependencies": { "@modelcontextprotocol/sdk": "^1.0.0", -<<<<<<< HEAD "@optave/codegraph-darwin-arm64": "3.0.3", "@optave/codegraph-darwin-x64": "3.0.3", + "@optave/codegraph-linux-arm64-gnu": "3.0.3", + "@optave/codegraph-linux-arm64-musl": "3.0.3", "@optave/codegraph-linux-x64-gnu": "3.0.3", + "@optave/codegraph-linux-x64-musl": "3.0.3", "@optave/codegraph-win32-x64-msvc": "3.0.3" -======= - "@optave/codegraph-darwin-arm64": "3.0.2", - "@optave/codegraph-darwin-x64": "3.0.2", - "@optave/codegraph-linux-arm64-gnu": "3.0.2", - "@optave/codegraph-linux-x64-gnu": "3.0.2", - "@optave/codegraph-linux-x64-musl": "3.0.2", - "@optave/codegraph-win32-x64-msvc": "3.0.2" ->>>>>>> 1165472 (chore: release v3.0.2) }, "devDependencies": { "@biomejs/biome": "^2.4.4",