Repository navigation
fix(linux): rebuild from source instead of stale prebuilt objects - #118
Merged
Merged
Conversation
The npm tarball ships prebuilt .o/.obj files in src/lib/temp/csr/.
make treats them as up-to-date, skips recompilation and archives the
stale objects, which then fail at dlopen with
'undefined symbol: TA_DEF_TableASize' (reproducible in clean containers
with a fresh toolchain, e.g. node:24-slim on Debian trixie).
- delete prebuilt objects in temp/csr before make so the full source
tree is recompiled for the current toolchain
- best-effort ranlib pass over the built .a archives: newer binutils
(>= 2.44) reject archives without a symbol index
('error adding symbols: archive has no index')
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The npm tarball for
talib@2.0.4ships prebuilt object files insrc/lib/temp/csr/(*.o). On install,makecompares timestamps, considers these objects up-to-date, skips recompilation and archives them into the.alibraries. Depending on the toolchain, this surfaces in two ways:New binutils (Debian trixie, binutils >= 2.44) — the archives built from stale objects have no symbol index, and the linker rejects them during
node-gyp build:Older binutils — the link succeeds but the addon fails at load time, because the stale objects are missing symbols from parts of the source tree (e.g.
table_*.c):Both are reproducible in clean containers with a fresh toolchain; on dev machines they are often masked by local rebuilds.
Reproduction
Single Dockerfile — uncomment the workaround block to apply the fix (the workaround is exactly what this PR moves into
src/lib/build.js, so it runs against the unmodifiedtalib@2.0.4from npm):Note: with the fix uncommented, use
npm install --ignore-scripts talib@2.0.4(the stock install script fails before the workaround gets a chance to run) — see the verified logs below.Without the fix (actual log)
docker build --progress=plain .fails insidenpm install talib@2.0.4. Themakephase completes in ~13 s with zerogcc -cinvocations — the stale objects from the tarball are archived as-is — and then the addon link step dies:With the fix (actual log)
Full recompile — 196
gcc -clines in the build log, ~20 s of real compilation, then ranlib and a successful addon build:Environment:
node:24-slim(Debian trixie, binutils 2.44), Node v24.21.0, node-gyp v12.4.0, Docker 27.5.0 on WSL2.Changes
In the linux/darwin branch of
src/lib/build.js:*.o/*.objfiles insrc/lib/temp/csr/before runningmake, so the full source tree is recompiled for the current toolchain. Non-fatal on failure (try/catch with a warning).make, run a best-effortranlibpass over all built.aarchives insrc/lib/lib/so the linker accepts them on new binutils. Also non-fatal.Verification
node --check src/lib/build.jspasses.patchedDependencies) in a production project since 2026-09 (Dokploy deploy on Debian trixie), where it fixed both thearchive has no indexlink failure and theundefined symbol: TA_DEF_TableASizedlopen failure.