php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74711 wrong libraries linked to SAPI
Submitted: 2017-06-08 14:05 UTC Modified: 2021-10-17 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: martijn at openbsd dot org Assigned: cmb (profile)
Status: No Feedback Package: *Compile Issues
PHP Version: Irrelevant OS: OpenBSD (probably irrelevant)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
29 - 9 = ?
Subscribe to this entry?

 
 [2017-06-08 14:05 UTC] martijn at openbsd dot org
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


Patches

patch-ext_odbc_config_m4.diff (last revision 2017-07-05 09:48 UTC by martijn at openbsd dot org)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-08 14:31 UTC] spam2 at rhsoft dot net
"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" - how is that a bug? when you remove sharde libraries software is linked to you break that software

hence package managers was invited and when you try to remove such dependencies when you built PHP as package it would suggest to remove PHP or just say "No"
 [2017-07-05 09:52 UTC] martijn at openbsd dot org
Well, the point is, this is for a revamp of the OpenBSD package(s). So your point is kind of mute...

ODBC is in no way related to the PHP core and should not be linked to it.

The attached patch is based on php7.1.6, but works equally well on 5.6 and 7.0 and fixes the issue for me.
 [2021-10-06 13:39 UTC] cmb@php.net
-Status: Open +Status: Feedback -Package: Dynamic loading +Package: *Compile Issues -Assigned To: +Assigned To: cmb
 [2021-10-06 13:39 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-10-17 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 18:01:31 2024 UTC