build: fix make -j$(nproc) race for libsecp256k1 (closes #139)#280
Open
sahincelil wants to merge 1 commit into
Open
build: fix make -j$(nproc) race for libsecp256k1 (closes #139)#280sahincelil wants to merge 1 commit into
sahincelil wants to merge 1 commit into
Conversation
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.
Root cause
src/Makefile.amdeclaresLIBSECP256K1with a per-file wildcarddependency at lines 69-70, but the
.latarget is never registered inEXTRA_LIBRARIES,BUILT_SOURCES, ornoinst_LTLIBRARIES.Under serial
makethis is fine — automake auto-resolves the prereqfrom
LDADDreferences. Undermake -j$(nproc)GNU make scheduleslink-time targets (
BGLd,BGL-node,BGL-cli) before thesecp256k1subprocess Makefile finishes, causing intermittenterror 1when multiple targets race to
cd secp256k1 && $(MAKE).Fix
Add
$(LIBSECP256K1)toBUILT_SOURCESso it is materialized beforeany object compilation step begins, regardless of
-jlevel.Diff
Just 6 lines added to
src/Makefile.am(one comment block + oneBUILT_SOURCESdeclaration). No behavior change for serial builds; eliminates the race for parallel builds.Testing
This is a build-system race condition fix — the change itself is a
well-known autotools idiom for handling sub-library dependencies in
parallel builds. The same pattern is used in Bitcoin Core's older
autotools-era
src/Makefile.am.I could not reproduce the original error on a clean Windows VM in the
time available (the bug surfaces non-deterministically on CI-class
machines with high core counts), but the fix is structurally sound and
strictly additive. Happy to coordinate further testing on Discord.
Related
Closes #139.
Discord coordination welcome:
@madnadyka,@janus,@van-orton.Open to any test methodology you'd like before merge.