php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76403 macOS compile linking to system libs instead of local
Submitted: 2018-06-02 00:16 UTC Modified: -
Votes:9
Avg. Score:3.8 ± 1.3
Reproduced:5 of 6 (83.3%)
Same Version:3 (60.0%)
Same OS:5 (100.0%)
From: kevin dot abel dot 0 at gmail dot com Assigned:
Status: Open Package: *Compile Issues
PHP Version: 7.2.6 OS: macOS
Private report: No CVE-ID: None
 [2018-06-02 00:16 UTC] kevin dot abel dot 0 at gmail dot com
Description:
------------
While running configure on macOS, the system library path is getting added to the list of library paths via the autoconf function PHP_ADD_LIBPATH. The build tools on macOS use paths like "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib" and "/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib" that the linker knows to refer back to the more common /usr/lib.

This is causing the macOS linker to link to system libraries rather than versions explicitly provided in configure flags.

This issue is affecting the Homebrew package manager, tracked at https://github.com/Homebrew/homebrew-core/issues/28398

Test script:
---------------
./configure
--prefix=/usr/local/Cellar/php/7.2.6
--localstatedir=/usr/local/var
--sysconfdir=/usr/local/etc/php/7.2
--with-config-file-path=/usr/local/etc/php/7.2
--with-config-file-scan-dir=/usr/local/etc/php/7.2/conf.d
--with-pear=/usr/local/Cellar/php/7.2.6/share/php/pear
--enable-bcmath
--enable-calendar
--enable-dba
--enable-dtrace
--enable-exif
--enable-ftp
--enable-fpm
--enable-intl
--enable-mbregex
--enable-mbstring
--enable-mysqlnd
--enable-opcache-file
--enable-pcntl
--enable-phpdbg
--enable-phpdbg-webhelper
--enable-shmop
--enable-soap
--enable-sockets
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--enable-wddx
--enable-zip
--with-apxs2=/usr/local/opt/httpd/bin/apxs
--with-bz2
--with-fpm-user=_www
--with-fpm-group=_www
--with-freetype-dir=/usr/local/opt/freetype
--with-gd
--with-gettext=/usr/local/opt/gettext
--with-gmp=/usr/local/opt/gmp
--with-icu-dir=/usr/local/opt/icu4c
--with-jpeg-dir=/usr/local/opt/jpeg
--with-kerberos
--with-layout=GNU
--with-ldap
--with-ldap-sasl
--with-libedit
--with-libzip
--with-mhash
--with-mysql-sock=/tmp/mysql.sock
--with-mysqli=mysqlnd
--with-ndbm
--with-openssl=/usr/local/opt/openssl
--with-password-argon2=/usr/local/opt/argon2
--with-pdo-dblib=/usr/local/opt/freetds
--with-pdo-mysql=mysqlnd
--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc
--with-pdo-pgsql=/usr/local/opt/libpq
--with-pgsql=/usr/local/opt/libpq
--with-pic
--with-png-dir=/usr/local/opt/libpng
--with-pspell=/usr/local/opt/aspell
--with-sodium=/usr/local/opt/libsodium
--with-unixODBC=/usr/local/opt/unixodbc
--with-webp-dir=/usr/local/opt/webp
--with-xmlrpc
--with-xsl
--with-zlib
--with-curl

Expected result:
----------------
The php binary is compiled and linked to the libpq library at /usr/local/opt/libpq/lib/libpq.5.dylib.

The Makefile does not include references to macOS's build tool SDK directories.

Actual result:
--------------
The php binary is compiled and linked to the system libpq library at /usr/lib/libpq.5.dylib.

The Makefile includes references to /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib.

Patches

acinclude-macos (last revision 2018-07-20 00:57 UTC by kevin dot abel dot 0 at gmail dot com)
acinclude-macos.patch (last revision 2018-06-02 00:17 UTC by kevin dot abel dot 0 at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-25 08:40 UTC] jan dot a dot viljanen at gmail dot com
To boil this down to something that's easily reproducible you can use this

./configure --disable-all --with-ldap=/usr/local/opt/openldap
make

Produces

# otool -L sapi/cli/php
sapi/cli/php:
	/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/local/opt/openldap/lib/libldap-2.4.2.dylib (compatibility version 13.0.0, current version 13.9.0)
	/usr/local/opt/openldap/lib/liblber-2.4.2.dylib (compatibility version 13.0.0, current version 13.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)

whereas 

./configure --disable-all --with-ldap=/usr/local/opt/openldap --enable-libxml
make

produces

# otool -L sapi/cli/php
sapi/cli/php:
	/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
	/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 59.1.0)

I'm on macOS 10.13.6 and this was tested with PHP 7.2.8 .

This is a showstopper for including some PHP extensions in the homebrew package manager project and also why we can't use the openldap package as suggested here https://bugs.php.net/bug.php?id=76433 . OP has updated the issue on github https://github.com/Homebrew/homebrew-core/issues/28398#issuecomment-407615789 with some more information.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC