Skip to content

Fix apple static builds by not passing GNU-specific D modifier - #14

Merged
wolfgitpr merged 1 commit into
wolfgitpr:v2from
BillyONeal:fix-apple-ar-flags
Nov 21, 2026
Merged

wolfgitpr merged 1 commit into
wolfgitpr:v2from
BillyONeal:fix-apple-ar-flags

Conversation

@BillyONeal

Copy link
Copy Markdown

This change was originally by @SunBlack in microsoft/vcpkg#55144 . The following explanation is from "GitHub Copilot Fusion":

The reproducible-build block sets CMAKE_CXX_ARCHIVE_CREATE/APPEND to <CMAKE_AR> qcD / qD for every GNU|Clang build where cpp-pinyin is the top-level project. That includes AppleClang. On macOS, CMAKE_AR is Apple's cctools ar, which does not have a D (deterministic) modifier. Its option parser accepts only abcdilLmopqrSsTtuVvx6; see https://github.com/apple-oss-distributions/cctools/blob/main/ar/ar.c. Any other letter goes to usage() and exits 1, so static builds on macOS fail at the archive step.

The ranlib override right below is already guarded by if (NOT APPLE) for the same reason (Apple's ranlib has no -D). The existing comment also says the Apple static archive is not the shipped artifact. This change moves the two archive rules into that same guard. On Apple, CMake's default archive rules are used. Behavior on every other platform is unchanged.

The reproducible-build block sets CMAKE_CXX_ARCHIVE_CREATE/APPEND to
`<CMAKE_AR> qcD` / `qD` for every GNU|Clang build where cpp-pinyin is the
top-level project. That includes AppleClang. On macOS, CMAKE_AR is Apple's
cctools `ar`, which does not have a `D` (deterministic) modifier. Its
option parser accepts only `abcdilLmopqrSsTtuVvx6`; see
https://github.com/apple-oss-distributions/cctools/blob/main/ar/ar.c.
Any other letter goes to usage() and exits 1, so static builds on macOS
fail at the archive step.

The ranlib override right below is already guarded by `if (NOT APPLE)`
for the same reason (Apple's ranlib has no `-D`). The existing comment
also says the Apple static archive is not the shipped artifact. This
change moves the two archive rules into that same guard. On Apple, CMake's
default archive rules are used. Behavior on every other platform is
unchanged.

This patch comes from the vcpkg port update to 2.0.0,
microsoft/vcpkg#55144, where it fixes the
arm64-osx static build. Original author: @SunBlack.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants