php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75852 PECL changes default compiler by changing path
Submitted: 2018-01-21 05:31 UTC Modified: 2019-03-14 06:42 UTC
Votes:11
Avg. Score:4.5 ± 0.8
Reproduced:10 of 10 (100.0%)
Same Version:9 (90.0%)
Same OS:8 (80.0%)
From: dpuglielli at magnitude dot com Assigned: remi (profile)
Status: Closed Package: PECL (PECL)
PHP Version: 7.2.1 OS: CentOS 7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dpuglielli at magnitude dot com
New email:
PHP Version: OS:

 

 [2018-01-21 05:31 UTC] dpuglielli at magnitude dot com
Description:
------------
When attempting to install a package using PECL, PECL prepends to the default path, which can prevent installation of extensions requiring a more recent compiler.

I am running CentOS 7. I installed PHP 7.2 from rpms.remirepo.net using yum. I then updated GCC by running the following commands: 
yum install centos-release-scl
yum install devtoolset-7
scl enable devtoolset-7 bash
(from https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/). I then tried to install SQLSRV using 'pecl install sqlsrv'. It failed at the compilation step with error messages about __builtin_saddl_overflow and __builtin_ssubl_overflow from zend_operators.h not being declared (full compiler output below).


Cause of the problem: On CentOS, the default GCC is 4.8.5. PHP 7.2 makes use of built-in integer overflow functions such as __builtin_saddl_overflow, which were only added to GCC in version 5. Downloading an updated GCC using the commands above changes the default path by prepending /opt/rh/devtoolset-7/root/usr/bin to it, which is the location of the updated compiler. However, when running 'pecl install <extension>', PECL prepends /usr/bin to the new path, causing it to use the old gcc executable (4.8) in /usr/bin instead of the newer one. The offending code is line 310 of /usr/share/pear/PEAR/Builder.php:
putenv('PATH=' . $this->config->get('bin_dir') . ':' . getenv('PATH'));

The result on CentOS/RedHat is that a few extensions, such as SQLSRV, will not compile at all, and others will give warnings about implicit function declarations. A workaround is to download the package file manually using 'pecl download', unzip it, and run 'phpize; ./configure; make; make install;' manually, but this should not be necessary.


Test script:
---------------
# pecl install sqlsrv

Expected result:
----------------
sqlsrv should compile and install without errors.

Actual result:
--------------
The compiler output from the make stage of installation:

running: make
/bin/sh /var/tmp/pear-build-davidp9cVJxa/sqlsrv-4.3.0/libtool --mode=compile g++ -std=c++11 -I. -I/var/tmp/sqlsrv -DPHP_ATOM_INC -I/var/tmp/pear-build-davidp9cVJxa/sqlsrv-4.3.0/include -I/var/tmp/pear-build-davidp9cVJxa/sqlsrv-4.3.0/main -I/var/tmp/sqlsrv -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -c /var/tmp/sqlsrv/conn.cpp -o conn.lo
libtool: compile:  g++ -std=c++11 -I. -I/var/tmp/sqlsrv -DPHP_ATOM_INC -I/var/tmp/pear-build-davidp9cVJxa/sqlsrv-4.3.0/include -I/var/tmp/pear-build-davidp9cVJxa/sqlsrv-4.3.0/main -I/var/tmp/sqlsrv -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -c /var/tmp/sqlsrv/conn.cpp  -fPIC -DPIC -o .libs/conn.o
In file included from /usr/include/php/Zend/zend_types.h:27:0,
                 from /usr/include/php/Zend/zend.h:29,
                 from /usr/include/php/main/php.h:35,
                 from /var/tmp/sqlsrv/shared/core_sqlsrv.h:34,
                 from /var/tmp/sqlsrv/php_sqlsrv.h:25,
                 from /var/tmp/sqlsrv/conn.cpp:20:
/usr/include/php/Zend/zend_operators.h: In function 'void fast_long_increment_function(zval*)':
/usr/include/php/Zend/zend_operators.h:446:68: error: '__builtin_saddl_overflow' was not declared in this scope
  if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), 1, &lresult))) {
                                                                    ^
/usr/include/php/Zend/zend_portability.h:312:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^
/usr/include/php/Zend/zend_operators.h: In function 'void fast_long_decrement_function(zval*)':
/usr/include/php/Zend/zend_operators.h:500:68: error: '__builtin_ssubl_overflow' was not declared in this scope
  if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), 1, &lresult))) {
                                                                    ^
/usr/include/php/Zend/zend_portability.h:312:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^
/usr/include/php/Zend/zend_operators.h: In function 'void fast_long_add_function(zval*, zval*, zval*)':
/usr/include/php/Zend/zend_operators.h:554:80: error: '__builtin_saddl_overflow' was not declared in this scope
  if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &lresult))) {
                                                                                ^
/usr/include/php/Zend/zend_portability.h:312:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^
/usr/include/php/Zend/zend_operators.h: In function 'void fast_long_sub_function(zval*, zval*, zval*)':
/usr/include/php/Zend/zend_operators.h:657:80: error: '__builtin_ssubl_overflow' was not declared in this scope
  if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &lresult))) {
                                                                                ^
/usr/include/php/Zend/zend_portability.h:312:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^
make: *** [conn.lo] Error 1
ERROR: `make' failed

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-22 06:15 UTC] remi@php.net
> I am running CentOS 7. I installed PHP 7.2 from rpms.remirepo.net using yum. 

So, simply: yum install php-sqlsrv  ;)

P.S. FYI, package in my repository (7.1 and 7.2) are all built using gcc 6.2 from devtoolset-6
 [2019-03-13 15:23 UTC] remi@php.net
This issue should be fixed by https://github.com/pear/pear-core/pull/88

(which is included in php-pear-1.10.8-2 from "remi-test" repository)
 [2019-03-13 18:05 UTC] ashnazg@php.net
remi's fix is now released in PEAR-1.10.9.
 [2019-03-14 06:42 UTC] remi@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: remi
 [2019-03-14 06:42 UTC] remi@php.net
Fixed in PEAR 1.10.9
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 22:01:28 2024 UTC