Skip to content

refactor(scripts): one implementation of per-architecture library selection - #2350

Merged
datlechin merged 1 commit into
mainfrom
refactor/prepare-libs
Aug 21, 2026
Merged

refactor(scripts): one implementation of per-architecture library selection#2350
datlechin merged 1 commit into
mainfrom
refactor/prepare-libs

Conversation

@datlechin

Copy link
Copy Markdown
Member

Selecting the per-architecture slice of a vendored static library existed in five places that disagreed with each other. It is now one function in scripts/lib/macos.sh, the library #2336 introduced.

What was there

build-release.sh carried four near-identical functions, 159 lines between them:

lines how it resolved a library
prepare_mariadb 55 cd Libs, thin the universal only
prepare_libpq 30 thin the universal only
prepare_libmongoc 37 per-arch file, else thin the universal
prepare_hiredis 37 per-arch file, else thin the universal

and scripts/ci/prepare-libs.sh did a bare cp "Libs/${lib}_${ARCH}.a" with no fallback at all. So the release path and the CI step took different sources for the same library, and two of the four could not use a per-architecture file even when one existed.

build-release.sh drops from 693 lines to 529.

A regression I introduced and then caught by running it

The shared function first keeps a library that is already correct, which the originals expressed as:

lipo -info "Libs/${lib}.a" | grep -q "$target_arch"

That is a substring test, and a universal library contains arm64, so it matches. Faithful to build-release.sh, but not to ci/prepare-libs.sh, whose unconditional cp always produced a thin library. Porting the substring form would have left fat libraries in place and quietly changed the release to link those.

Running it is what showed this: after the first version, prepare-libs.sh arm64 reported libpq.a x86_64 arm64. The check is now an exact architecture match, so both callers produce a thin library, which is what the release path has always effectively had.

Verified

scripts/ci/prepare-libs.sh was run for real, both ways:

arm64    libmariadb.a arm64    libpq.a arm64    libhiredis.a arm64    libmongoc.a arm64
x86_64   libmariadb.a x86_64   libpq.a x86_64   libhiredis.a x86_64   libmongoc.a x86_64

Running it twice for the same architecture is a no-op, and a missing library fails naming it rather than leaving a half-prepared tree. Libs/ was restored afterwards and re-verified against the checksum baseline committed in git.

The extracted function was diffed against the original prepare_hiredis operation by operation: same three branches in the same order, the only textual difference being $LIBS_DIR in place of a relative Libs/, which also makes it independent of the caller's working directory.

build-release.sh itself is not run here, because it signs and notarizes.

https://claude.ai/code/session_013MEaba8K1HQcyDNeq5wEFk

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin
datlechin merged commit edbd46a into main Aug 21, 2026
8 checks passed
@datlechin
datlechin deleted the refactor/prepare-libs branch August 21, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant