Edit report at https://bugs.php.net/bug.php?id=75852&edit=1

 ID:                 75852
 Comment by:         r...@php.net
 Reported by:        dpuglielli at magnitude dot com
 Summary:            PECL changes default compiler by changing path
 Status:             Open
 Type:               Bug
 Package:            PECL
 Operating System:   CentOS 7
 PHP Version:        7.2.1
 Block user comment: N
 Private report:     N

 New Comment:

> 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


Previous Comments:
------------------------------------------------------------------------
[2018-01-21 05:31:07] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75852&edit=1

-- 
PECL development discussion Mailing List (http://pecl.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to