Skip to content

Strip foreign-architecture code from the macOS bundle (#10063)#10064

Merged
asheshv merged 2 commits into
pgadmin-org:masterfrom
dpage:worktree-mac-strip-foreign-arch
Jun 12, 2026
Merged

Strip foreign-architecture code from the macOS bundle (#10063)#10064
asheshv merged 2 commits into
pgadmin-org:masterfrom
dpage:worktree-mac-strip-foreign-arch

Conversation

@dpage

@dpage dpage commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

The macOS app is built for a single architecture (matching the build machine, via ${ARCH}), but relocatable-python pulls the python.org universal2 installer, so the entire Python.framework ships both arm64 and x86_64 slices. PostgreSQL-sourced dylibs (libpq, libssl, ...) may be universal too. The foreign slice is dead weight that bloats the bundle and DMG.

Fixes #10063.

Changes

  • New _strip_architecture() in pkg/mac/build-functions.sh, called from build.sh after _complete_bundle and before code-signing (lipo invalidates signatures, so the existing _codesign_* passes re-sign the thinned binaries — no extra re-sign needed).
  • Removes the universal2 stragglers: the python*-intel64 launcher and the stray config-*-darwin/python.o build object.
  • lipo -thins every fat Mach-O in the bundle to the build arch, preserving file modes (the +x bit the signing pass relies on) and warning rather than failing on any binary that lacks the target slice.
  • Already single-arch inputs (Electron and its helpers, downloaded per-arch) are skipped.
  • Changelog entry under Housekeeping in release_notes_9_16.rst.

Notes

lipo can only keep a slice that already exists — this strips the build machine's foreign slice from an otherwise-correct build; it does not let an arm64 build produce an x86_64 bundle or vice versa.

Summary by CodeRabbit

  • Housekeeping
    • Optimized macOS builds to exclude unused architecture slices from the bundled Python framework, reducing bundle size for single-architecture builds.
    • Resulting app bundles are smaller, which can reduce download size and disk usage.
    • No changes to functionality or user-facing behavior; installs, signing, and notarization remain unaffected.

)

The macOS app is built for a single architecture (matching the build
machine, via ${ARCH}), but relocatable-python pulls the python.org
universal2 installer, so the entire Python.framework ships both arm64
and x86_64 slices. PostgreSQL-sourced dylibs may be universal too. The
foreign slice is dead weight that bloats the bundle and DMG.

Add a _strip_architecture step, run after _complete_bundle and before
code-signing (lipo invalidates signatures, so the existing sign passes
re-sign the thinned binaries). It removes the universal2 stragglers
(python*-intel64 launcher, config-*-darwin/python.o) and lipo-thins
every fat Mach-O in the bundle to the build arch, preserving file modes
and warning on anything lacking the target slice. Already single-arch
inputs (Electron and its helpers) are skipped.
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 046b43a9-3a77-42fb-8dae-390bb79e660d

📥 Commits

Reviewing files that changed from the base of the PR and between 45abd1e and a5f1763.

📒 Files selected for processing (1)
  • docs/en_US/release_notes_9_16.rst
✅ Files skipped from review due to trivial changes (1)
  • docs/en_US/release_notes_9_16.rst

Walkthrough

This PR adds _strip_architecture() to thin universal/fat Mach-O binaries in the macOS app bundle to the build-machine architecture, removes Python framework universal2 stragglers, calls it during the build before SBOM generation, and documents the change in the release notes.

Changes

macOS architecture stripping

Layer / File(s) Summary
Strip architecture function
pkg/mac/build-functions.sh
_strip_architecture() thins universal/fat Mach-O binaries in the bundle to the build-machine target architecture. It removes Python framework universal2 artifacts, iterates through regular files to detect fat binaries via lipo -archs, and replaces them with single-arch versions using lipo -thin while preserving permissions. Non-applicable or failed operations emit warnings and continue.
Build integration and release notes
pkg/mac/build.sh, docs/en_US/release_notes_9_16.rst
_strip_architecture is called after _complete_bundle and before _generate_sbom to establish build step ordering. Release notes document the housekeeping improvement for Issue #10063 stating that foreign-architecture slices are stripped from the macOS bundle so single-arch builds no longer ship unused universal2 Python framework code.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: stripping foreign-architecture code from the macOS bundle, directly matching the primary objective and the linked issue #10063.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #10063: it strips foreign-architecture slices using lipo -thin on all universal Mach-O binaries, removes architecture-specific stragglers (bin/python3.x-intel64 and python.o), preserves single-arch artifacts, handles missing target slices gracefully, and performs thinning before code-signing.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the objectives: _strip_architecture() function for thinning binaries, build step ordering adjustments, and a Housekeeping changelog entry. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces the size of the macOS pgAdmin4 app bundle by stripping unused (foreign) CPU architecture slices from universal/fat Mach-O binaries (notably the universal2 Python.framework pulled in via relocatable-python) before code-signing.

Changes:

  • Adds _strip_architecture() to thin fat Mach-O files in the bundle to the build machine’s target architecture and remove universal2 installer stragglers.
  • Wires the new strip step into the macOS build pipeline before SBOM generation and code-signing.
  • Documents the change in the v9.16 release notes (Housekeeping).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/mac/build.sh Invokes _strip_architecture after bundle completion and before SBOM/signing.
pkg/mac/build-functions.sh Implements architecture stripping/thinning and removes universal2 Python installer leftovers.
docs/en_US/release_notes_9_16.rst Adds a release note entry for Issue #10063 under Housekeeping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/mac/build-functions.sh
Comment thread pkg/mac/build-functions.sh
Comment thread pkg/mac/build-functions.sh
@asheshv asheshv merged commit 922f06c into pgadmin-org:master Jun 12, 2026
34 checks passed
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.

macOS bundle ships both arm64 and x86_64 Python code (universal2), bloating single-arch builds

3 participants