Bug #74711 [NEW]: wrong libraries linked to SAPI

From: Date: Thu, 08 Jun 2017 14:05:40 +0000
Subject: Bug #74711 [NEW]: wrong libraries linked to SAPI
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209416@lists.php.net to get a copy of this message
From:             martijn at openbsd dot org
Operating system: OpenBSD (probably irrelevant)
PHP version:      Irrelevant
Package:          Dynamic loading
Bug Type:         Bug
Bug description:wrong libraries linked to SAPI

Description:
------------
When building PHP with shared modules I found that php wouldn't startup
any more when removing one of the modules and dependencies of the system
(in this case ext/odbc).

This is because libiodbc is linked into the different SAPIs:
$ ldd ./php
./php:
        Start            End              Type Open Ref GrpRef Name
        00000a9e0f800000 00000a9e0ff02000 exe  2    0   0      ./php
        00000aa0c76d5000 00000aa0c7927000 rlib 0    1   0     
/usr/local/lib/libiodbc.so.3.16
        00000aa0f976d000 00000aa0f997b000 rlib 0    4   0     
/usr/lib/libpthread.so.23.0
        00000aa102095000 00000aa1023ab000 rlib 0    1   0     
/usr/lib/libstdc++.so.57.0
        00000aa087c66000 00000aa087e8d000 rlib 0    3   0     
/usr/lib/libm.so.10.0
        00000aa0e1e2e000 00000aa0e2044000 rlib 0    2   0     
/usr/lib/libz.so.5.0
        00000aa03e983000 00000aa03ebc7000 rlib 0    1   0     
/usr/local/lib/libpcre.so.3.0
        00000aa06c91f000 00000aa06cc81000 rlib 0    1   0     
/usr/local/lib/libxml2.so.15.2
        00000aa0458a5000 00000aa045aca000 rlib 0    2   0     
/usr/local/lib/liblzma.so.2.1
        00000aa089fd8000 00000aa08a2d7000 rlib 0    2   0     
/usr/local/lib/libiconv.so.6.0
        00000aa0ec06b000 00000aa0ec2bd000 rlib 0    1   0     
/usr/lib/libssl.so.43.3
        00000aa0fbff1000 00000aa0fc3bb000 rlib 0    2   0     
/usr/lib/libcrypto.so.41.2
        00000aa0b473e000 00000aa0b4a0b000 rlib 0    1   0     
/usr/lib/libc.so.89.5
        00000aa085600000 00000aa085600000 rtld 0    1   0     
/usr/libexec/ld.so

I traced the problem via Makefile target BUILD_CLI which include
EXTRA_LIBS, which has this extra library added.

When looking around in the configure file I found that EXTRA_LIBS is a
concatenation of $EXTRA_LIBS $DLIBS $LIBS.
Adding some debugging found me that LIBS is the culprit in this case.

Continuing my search I found that LIBS is used in quite a few places
throughout the m4 files and that most of the time they save the value in
a tempvar and restore it later, but I did find that the PHP_ADD_LIBRARY
macro in aclocal.m4 and acinclude.m4 contains LIBS as the 5th argument.
This in my opinion is the most likely cause for not unsetting LIBS.

I tried to change the name LIBS to BLAHLIBS, but that breaks the libxml
checks.

Issue found in php 5.6.30, 7.0.19 and 7.1.5

Test script:
---------------
./configure --disable-rpath --disable-static
--enable-inline-optimization --enable-shared --program-suffix=-7.1
--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php-7.1
--with-pear=/usr/local/share/php-7.1 --with-pic --enable-filter
--enable-hash --enable-libxml=/usr/local --enable-session
--with-mhash=/usr/local --with-openssl --with-pcre-regex=/usr/local
--with-zlib --with-apxs2=/usr/local/sbin/apxs2 --enable-cgi --enable-cli
--disable-phpdbg --enable-fpm --with-fpm-user=www --with-fpm-group=www
--enable-bcmath=shared --with-bz2=shared,/usr/local
--enable-calendar=shared --enable-ctype=shared
--with-curl=shared,/usr/local --enable-dba=shared --with-gdbm=/usr/local
--enable-dom=shared --with-enchant=shared --enable-exif=shared
--enable-fileinfo=shared --enable-ftp=shared --with-gd=shared
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local
--with-zlib-dir=/usr --with-freetype-dir=/usr/X11R6
--with-xpm-dir=/usr/X11R6 --with-gettext=shared,/usr/local
--with-gmp=shared,/usr/local --with-iconv=shared,/usr/local
--with-imap=shared,/usr/local --with-imap-ssl --enable-intl=shared
--with-icu-dir=/usr/local --enable-json=shared
--with-ldap=shared,/usr/local --with-ldap-sasl=/usr/local
--enable-mbstring=shared --with-onig=/usr/local
--with-mcrypt=shared,/usr/local --enable-mysqlnd=shared
--with-mysqli=shared,mysqlnd --with-iodbc=shared,/usr/local
--enable-opcache --enable-pcntl=shared --enable-pdo=shared
--with-pdo-dblib=shared,/usr/local --with-pdo-mysql=shared,mysqlnd
--with-pdo-pgsql=shared,/usr/local --with-pdo-sqlite=shared,/usr/local
--with-pgsql=shared,/usr/local --enable-phar=shared
--enable-posix=shared --with-pspell=shared,/usr/local
--with-readline=shared --enable-shmop=shared,/usr/local
--enable-simplexml=shared --with-snmp=shared,/usr/local
--enable-soap=shared,/usr/local --enable-sockets=shared
--with-sqlite3=shared,/usr/local --enable-sysvmsg=shared
--enable-sysvsem=shared --enable-sysvshm=shared
--with-tidy=shared,/usr/local --enable-tokenizer=shared
--enable-wddx=shared --enable-xml=shared --enable-xmlreader=shared
--with-xmlrpc=shared --enable-xmlwriter=shared --with-xsl=shared
--enable-zip=shared,/usr/local --prefix=/usr/local --sysconfdir=/etc
--mandir=/usr/local/man --infodir=/usr/local/info --localstatedir=/var
--disable-silent-rules --disable-gtk-doc CFLAGS=-O2 -pipe
-I/usr/local/include -pthread YACC=/usr/bin/yacc

make

ldd sapi/cli/php


-- 
Edit bug report at https://bugs.php.net/bug.php?id=74711&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74711&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74711&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74711&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74711&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74711&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74711&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74711&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74711&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74711&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74711&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74711&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74711&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74711&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74711&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74711&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74711&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74711&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74711&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74711&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74711&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#209416) next »