#36285 refactor: Use static const over inline const to work around ld64 bug
https://github.com/bitcoin/bitcoin/pull/36285 · · +8/-8 in 2 files, 1 commits · labels: Refactoring, macOS, Needs Backport (32.x)
Goal
- Fix build failures on macOS developer environments caused by a platform linker bug
- Ensure affected macOS toolchains can successfully compile the project
This PR partially reverts commit fa74f58 to replace inline const declarations with static const across two files. It works around an ld64 linker bug on macOS that mishandles initialization dependencies, trading a 70 kB binary size increase for working builds.
Problem: Recent refactoring using inline const causes the macOS linker ld64 to fail due to initialization dependencies, breaking builds on macOS environments such as Nix devShells.
Category: Build and CI (#2 of 55)
P2 · platform fix
- P2 because broken builds directly block macOS developers and automated tooling
- Restores reliable compilation for the upcoming 32.0 release and backports
Supported-platform build breakage blocks developers and automated tooling on macOS. The PR restores successful compilation on affected environments and is milestoned for 32.0 with a backport label.
Membership: Fixes a platform-specific linker failure on macOS toolchains.
Factors: security/stability 0, bug 2, performance 0, user value 1, leverage 1
Reviewability: Ready
- Ready for review, with a minimal diff and verified fixes on macOS
The change is an 8-line workaround with a clean merge state, green CI, and verified testing on affected macOS setups.
Author status: active
Open concerns:
- Whether the issue affects all ld64 versions or only the specific patched version packaged by Nix.
Agreement: Positive
- Verified by successfully building and running tests on Nix macOS (janb84)
- Asked whether the bug affects all ld64 linkers or just Nix's patched version (fanquake)
- Recommends merging the workaround for 32.0 to unblock affected users (maflcko)
Positive, with tested verification on Nix macOS and clarification requested regarding toolchain scope
One member provided a tested ACK confirming it resolves the build on macOS with Nix, while another asked about the upstream scope of the ld64 bug.
- janb84 tested ACK: 'This builds, runs and all the test work, on (my) macOS with nix.'
- fanquake asked if ld64 generally or Nix's patched version is affected.
- maflcko noted lack of macOS hardware to isolate further and recommended merging the workaround for 32.0.
Review verdicts (DrahtBot): 1
- ACK: janb84
Files
0 lines under test/bench/ci.
File list not available for this run.
Card
This PR replaces inline const with static const in two files to work around an ld64 linker bug on macOS that causes initialization dependency failures (#36281). The change partially reverts a recent refactor, adding roughly 70 kB to the binary to restore builds on affected macOS environments like Nix devShells. It is milestoned for 32.0 and tagged for backport. One reviewer verified the fix with a tested ACK on macOS with Nix, and the PR is ready for merge consideration.