You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building PHP as a static library for macOS, the resulting libphp.a file cannot be linked and the following (weird) error occurs:
ld: warning: ignoring file /usr/local/lib/libphp.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
The problem only occurs if at least one extension depending on another static library has been compiled (ex: ext-curl, ext-sqlite3...). The linking is done correctly if it's not the case, or if there are dependencies to shared libraries.
Extracting the .o file from the archive and recreating it using ar also fixes the issue:
mkdir /tmp/php-o
cd /tmp/php-o
ar x /usr/local/lib/libphp.a
ar rcs /usr/local/lib/libphp.a *.o
I suspect that it's related to libtool, and specifically this line:
I had the same issue but was because it was linking it against a macOS "Designed for iPad" version, which items like resolv, sqlite, xml, cannot be used with Brew/macOS versions unless those individual items are cross compiled against XCode's tool for the specific platform.
Here would be an example configuration to cross compile libphp. Do note opcache, specifically JIT, does not work at all. It needs access to some memory model which is not allowed on macOS 13+, this is with issue with ZTS as well.
While I do disable sqlite and resolve, I still need to link the frameworks for the target I am building on:
The specific problem is if you make a XCode project for iOS and just add in macOS, but as a "supported destination" and not as its own target:
Then you run into the exact linking issue that you brought up which makes no sense until you realize you're trying to use macOS for an iOS/iPadOS target.
I do have a static PHP embed SAPI working on macOS, iOS and iPadOS just fine, with me knowing that if I want sqlite, resolve, xml, etc I need to compile those external libraries separately.
Description
When building PHP as a static library for macOS, the resulting
libphp.a
file cannot be linked and the following (weird) error occurs:The problem only occurs if at least one extension depending on another static library has been compiled (ex: ext-curl, ext-sqlite3...). The linking is done correctly if it's not the case, or if there are dependencies to shared libraries.
Extracting the
.o
file from the archive and recreating it usingar
also fixes the issue:I suspect that it's related to libtool, and specifically this line:
The problem can easily be reproduced using
static-php-cli
: crazywhalecc/static-php-cli#153PHP Version
PHP 8.2.9
Operating System
macOS 13.4.1 (M1)
The text was updated successfully, but these errors were encountered: