thirdparty: pin AR/RANLIB in autotools foreign builds (fix macOS jemalloc link)#210
Merged
Merged
Conversation
…lloc link) _configure passed CC/CXX from the resolved toolchain but let AR/RANLIB fall through to PATH. On macOS, a stray GNU-format `ar` ahead of /usr/bin/ar (e.g. Homebrew binutils / an llvm-ar in --format=gnu mode) builds a package's static archive in GNU format -- with `/` and `//` index members -- which Apple's ld rejects at link time: ld: archive member '/' not a mach-o file in '.../lib/libjemalloc.a' This surfaced on je_server (jemalloc's libjemalloc.a is built by a direct $(AR) crus Makefile rule, so it picks up the PATH ar; libtool-built archives like libtcmalloc/jsoncpp/ctemplate were unaffected because libtool drives the archiver consistently). The gperftools profiler archives hit the same GNU format but are gated Linux-only, so they never reached a macOS link. Pin AR/RANLIB the same way CC/CXX already are: force the system BSD ar/ranlib on macOS (they emit a `__.SYMDEF` archive ld accepts), and honor the toolchain ar elsewhere (GNU archives are fine for GNU ld). Passed both as env and as autoconf precious-vars so the generated Makefile uses them (verified: `AR = /usr/bin/ar`, archive members are `__.SYMDEF SORTED` + objects, je_server links). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
On macOS,
blade build //...fails linkingje_server:_configurepinsCC/CXXfrom the resolved toolchain but letsAR/RANLIBfall through to PATH. When a GNU-formatarsits ahead of/usr/bin/arin PATH (Homebrew binutils, or anllvm-arinvoked in--format=gnumode), a package built by a direct$(AR) crusMakefile rule produces a GNU-format archive (with/and//index members), which Apple'sldrejects.Why only jemalloc surfaced it
_la-object names) drive the archiver consistently → clean__.SYMDEFarchives → fine.$(AR)archives (jemalloc; gperftools' profiler/tcmalloc_and_profiler) pick up the PATHar→ GNU format.libjemalloc.ais in the macOS link graph (gperftools' profiler archives are gated Linux-only), soje_serverwas the only failure.Verified Apple
ldrejects both pure-GNU and GNU+ranlib-mixed archives — the format itself is the issue.Fix
Pin
AR/RANLIBthe same wayCC/CXXalready are: force the system BSD/usr/bin/ar+/usr/bin/ranlibon macOS (they emit a__.SYMDEFarchiveldaccepts), honor the toolchainarelsewhere. Passed both as env and as autoconf precious-vars so the generated Makefile uses them.Covers all
autotools_buildpackages (jemalloc, gperftools, …).Validation
Clean rebuild on macOS:
Makefilenow hasAR = /usr/bin/arlibjemalloc.amembers:__.SYMDEF SORTED+ objects (no///`)je_serverlinks;_je_mallctlresolves🤖 Generated with Claude Code