From dd36b92a34123929ec302ba50d70395136155e50 Mon Sep 17 00:00:00 2001 From: SunBlack Date: Thu, 19 Nov 2026 19:23:13 -0800 Subject: [PATCH] Don't pass ar's `D` modifier on Apple The reproducible-build block sets CMAKE_CXX_ARCHIVE_CREATE/APPEND to ` 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, https://github.com/microsoft/vcpkg/pull/55144/, where it fixes the arm64-osx static build. Original author: @SunBlack. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23d41dc..1a7ab64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,9 +81,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") # the build: a library that silently rewrites its host's toolchain rules is worse than one that is not # reproducible inside someone else's tree. if (_cpp_pinyin_top_level) - set(CMAKE_CXX_ARCHIVE_CREATE " qcD ") - set(CMAKE_CXX_ARCHIVE_APPEND " qD ") if (NOT APPLE) + set(CMAKE_CXX_ARCHIVE_CREATE " qcD ") + set(CMAKE_CXX_ARCHIVE_APPEND " qD ") # `ar qcD` on its own IS deterministic; the plain `ranlib` that CMake runs afterwards is NOT -- it # rewrites the symbol index with the current time in the member header, which is where the last # difference between two builds came from (measured 2026-10-20: `ar qcD` twice -> identical,