From e605e8fe8c3a2ea3d09e34e10b964c43ad4d5262 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sat, 15 Aug 2026 17:26:39 -0500 Subject: [PATCH] feat: fix unify-backend script to support mirroring architecture-specific native libraries for consistency across builds --- meshchatx.rsm | Bin 195898 -> 195898 bytes scripts/unify-backend-plain-files.sh | 29 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/meshchatx.rsm b/meshchatx.rsm index 9e0f97592109460d9c86b97471b659127d95b542..6d78130d63e84fb052c5652b4ce16aa43354e97e 100644 GIT binary patch delta 188 zcmV;t07L(}`U|@H3qLl`%ajdtO0j7?`(@{opqK40R4sM+BAWHP;(9k2ysl54_|#CqE8%>k!}xf?1N0(UCtHAZX)s6~!1YM}4_8lu-RCDhvK85Wyoc zm=h7!&nk({j)8c!cmc-FKw~juI5c8mGBjf|HZUt-V1#u?03`Z1Y zNhY}X=RU6^lYw}(cmc-FKr%5hWMN@uF=8}kV`XJHG&3+WW-wxAI5uHpG%;Z?V`XDy qF*q?YW;Z!GGht>iVKX>nG%;g0GGRAkIbky~VTXRt0k?k70=z9Lj!e=3 diff --git a/scripts/unify-backend-plain-files.sh b/scripts/unify-backend-plain-files.sh index 0ea195c1..599b3c73 100755 --- a/scripts/unify-backend-plain-files.sh +++ b/scripts/unify-backend-plain-files.sh @@ -12,8 +12,8 @@ set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" -ARM64_DIR="$ROOT/build/exe/darwin-arm64" -X64_DIR="$ROOT/build/exe/darwin-x64" +ARM64_DIR="${MESHCHATX_UNIFY_ARM64_DIR:-$ROOT/build/exe/darwin-arm64}" +X64_DIR="${MESHCHATX_UNIFY_X64_DIR:-$ROOT/build/exe/darwin-x64}" if [[ ! -d "$ARM64_DIR" || ! -d "$X64_DIR" ]]; then echo "unify-backend: one or both backend dirs missing, skipping" @@ -36,6 +36,23 @@ required_native_rel() { return 1 } +# Intel NumPy wheels ship OpenBLAS (plus gfortran/quadmath/gcc_s). Apple +# Silicon NumPy uses Accelerate, so those dylibs are x64-only. Dropping them +# to equalize the two trees makes numpy._core._multiarray_umath fail to +# dlopen on the Intel slice. Mirror them into the other tree so +# @electron/universal sees the same paths. x64ArchFiles keeps the backend +# from being lipo'd, so the unused copy is never loaded. +mirror_native_rel() { + local base + base="$(basename "$1")" + case "$base" in + libscipy_openblas* | libgfortran* | libquadmath* | libgcc_s*) + return 0 + ;; + esac + return 1 +} + copy_missing() { local src_dir="$1" dst_dir="$2" label="$3" while IFS= read -r -d '' rel; do @@ -53,6 +70,14 @@ copy_missing() { echo " meshchatx.src.backend.bake_frozen_pycodec2 after each cx_Freeze slice." >&2 exit 1 fi + if mirror_native_rel "$rel"; then + mkdir -p "$dst_dir/$(dirname "$rel")" + cp "$src_file" "$dst_dir/$rel" + echo "unify-backend: mirroring arch-only native $rel ($label)" >&2 + echo " source reports: $ft" >&2 + synced=$((synced + 1)) + continue + fi echo "unify-backend: dropping arch-only Mach-O for consistency: $rel" >&2 echo " ($label); source reports: $ft" >&2 echo " Hint: this native library/extension only exists in one arch's" >&2