From:             dpuglielli at magnitude dot com
Operating system: CentOS 7
PHP version:      7.2.1
Package:          PECL
Bug Type:         Bug
Bug description:PECL changes default compiler by changing path

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


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

Reply via email to