Repository navigation
fix(macos): bundle OpenSSL so PostgreSQL starts without Homebrew - #42
Open
vadimcomanescu wants to merge 2 commits into
Open
vadimcomanescu wants to merge 2 commits into
vadimcomanescu wants to merge 2 commits into
Conversation
The theseus-rs macOS PostgreSQL binaries load libssl/libcrypto from /opt/homebrew/opt/openssl@3, so pg0 cannot start PostgreSQL on a Mac without Homebrew (theseus-rs/postgresql-binaries#30). For the apple-darwin targets, build.rs now copies libssl.3.dylib and libcrypto.3.dylib from a pinned, checksummed conda-forge OpenSSL 3.5.9 package into the bundle's lib/, rewrites every reference to @loader_path/../lib/, re-signs the changed files ad-hoc and fails the build if any Mach-O still references /opt/homebrew or /usr/local. An install extracted by an earlier pg0 is re-extracted once. Linux and Windows builds are unchanged.
Ubuntu removed libxml2_2.9.13+dfsg-1ubuntu0.12 from the archive pool, so the Linux GNU builds failed with HTTP 404. Pin the current jammy point release (same bytes as the archive pool) by its Launchpad URL, which keeps every published package.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The theseus-rs macOS PostgreSQL 18.1.0 binaries load OpenSSL from the Homebrew prefix of the machine that built them (theseus-rs/postgresql-binaries#30). On a Mac without Homebrew's
openssl@3, PostgreSQL cannot load, sopg0 startfails.otool -L ~/.pg0/installation/18.1.0/lib/libpq.5.dylib(pg0 0.15.2):10 Mach-O files in the bundle reference it:
bin/postgres,pg_dump,pg_dumpall,pg_restore,pgbench,pg_combinebackup,pg_verifybackup,lib/libpq.5.dylib,lib/pgcrypto.dylib,lib/sslinfo.dylib.pg0 0.15.2 on a clean macOS 26.6.2 VM (no Homebrew, no Command Line Tools):
Fix
The same approach Postgres.app uses, done in
build.rsfor the two apple-darwin targets, next tobundle_runtime_libs:libssl.3.dylibandlibcrypto.3.dylibcome from conda-forge's OpenSSL 3.5.9 package (the 3.5 LTS line), pinned by URL and SHA-256 inversions.envthe way the Linux.debs are. conda-forge was chosen because it publishes checksummed builds for bothosx-arm64andosx-64with a macOS 11 deployment target; Homebrew no longer ships x86_64 macOS bottles.lib/, with OpenSSL's licence inshare/openssl/LICENSE.txt.libssl.3.dylib/libcrypto.3.dylibis rewritten to@loader_path/../lib/...(install_name_tool -change, and-idfor the two copied libraries), then re-signed ad hoc (codesign -f -s -), becauseinstall_name_toolinvalidates the signature./opt/homebrewor/usr/local.pg0re-extracts an install that lackslib/libcrypto.3.dylib, so a broken install left by an earlier pg0 gets repaired on the nextpg0 start.Linux and Windows builds are unchanged. A second commit repins libxml2 for the Linux GNU builds: Ubuntu removed
libxml2_2.9.13+dfsg-1ubuntu0.12from the archive pool (HTTP 404), so those builds were failing onmain. The new pin is0ubuntu0.13by its Launchpad URL, which keeps every published package, and its bytes are identical to the archive pool's.Evidence
After the fix,
otool -L lib/libpq.5.dylib:For the wheels
build-python-wheels.ymlbuilt on macos-14 and macos-15-intel, all 127 Mach-O files in the extracted install were scanned, and 0 reference/opt/homebrewor/usr/local.pg0 startandpg0 stopwork for both architectures.On the same clean macOS 26.6.2 arm64 VM, against the broken
~/.pg0that 0.15.2 left behind,pg0 startre-extracted the install and started PostgreSQL.CREATE EXTENSION vectorworked (0.8.5), andSHOW ssl_libraryreturnedOpenSSL.vmmapshowedpostgresloading~/.pg0/installation/18.1.0/lib/libssl.3.dylibandlibcrypto.3.dylib.pg0 stopstopped it, and a second start/stop worked too.