php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40335 Compile fails when using GCC 4.1.1/binutils 2.17
Submitted: 2007-02-02 22:32 UTC Modified: 2007-02-12 17:13 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: earlej at hotmail dot com Assigned: tony2001 (profile)
Status: Closed Package: Compile Failure
PHP Version: 4.4.4 OS: RHEL4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: earlej at hotmail dot com
New email:
PHP Version: OS:

 

 [2007-02-02 22:32 UTC] earlej at hotmail dot com
Description:
------------
# export CFLAGS="-m64 -fPIC"
# gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.1.1/configure --prefix=/usr/local/gcc411 --quiet --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++ --disable-multilib --disable-libunwind-exceptions
Thread model: posix
gcc version 4.1.1

# ./configure (about as simple as it gets)
# make
...
ext/mysql/libmysql/my_tempnam.o: In function `my_tempnam':
my_tempnam.c:(.text+0x69): warning: the use of `tempnam' is dangerous, better use `mkstemp'
main/output.o: In function `php_output_init_globals':
output.c:(.text+0x12): undefined reference to `php_default_output_func'
output.c:(.text+0x23): undefined reference to `php_default_output_func'
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php] Error 1

If I try and build a DSO for Apache 1.3.37, using:

./configure \
--prefix=~/tools/php \
--with-xsl=~/tools/libxslt \             
--with-openssl=~/tools/openssl \             
--with-libxml-dir=~/tools/libxml2 \             
--with-zlib=~/tools/zlib \             
--without-xmlrpc \             
--without-bz2 \             
--with-mysql \             
--without-sqlite \             
--enable-force-cgi-redirect \             
--enable-memory-limit \             
--disable-pear \             
--disable-ipv6 \
--with-pgsql=/home/jonathan/sw/build/pgclient \
--with-apxs=~/tools/apache/bin/apxs

Then I receive:

/usr/local/gcc411/lib/gcc/x86_64-unknown-linux-gnu/4.1.1/../../../../x86_64-unknown-linux-gnu/bin/ld: main/output.lo: relocation R_X86_64_PC32 against `php_default_output_func' can not be used when making a shared object; recompile with -fPIC
/usr/local/gcc411/lib/gcc/x86_64-unknown-linux-gnu/4.1.1/../../../../x86_64-unknown-linux-gnu/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [libphp4.la] Error 1

Compile output shows main/output.c _is_built using -fPIC:

/bin/sh /home/jonathan/sw/vdx_ostk/build/php-4.4.4/libtool --silent --preserve-dup-deps --mode=compile gcc  -Imain/ -I/home/jonathan/sw/vdx_ostk/build/php-4.4.4/main/ -DPHP_ATOM_INC -I/home/jonathan/sw/vdx_ostk/build/php-4.4.4/include -I/home/jonathan/sw/vdx_ostk/build/php-4.4.4/main -I/home/jonathan/sw/vdx_ostk/build/php-4.4.4 -I/root/vdxtools/openssl/include -I/root/vdxtools/zlib/include -I/home/jonathan/sw/vdx_ostk/build/pgclient/ -I/home/jonathan/sw/vdx_ostk/build/php-4.4.4/ext/xml/expat -I/home/jonathan/sw/vdx_ostk/build/php-4.4.4/TSRM -I/home/jonathan/sw/vdx_ostk/build/php-4.4.4/Zend    -m64 -fPIC   -c /home/jonathan/sw/vdx_ostk/build/php-4.4.4/main/output.c -o main/output.lo

Expected result:
----------------
I would expect a properly built PHP instance.

Actual result:
--------------
Unless I use GCC 3.4.6 (the default on this system), I cannot build PHP.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-02 22:35 UTC] earlej at hotmail dot copm
Description:
------------
# export CFLAGS="-m64 -fPIC"
# gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.1.1/configure --prefix=/usr/local/gcc411
--quiet --enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--enable-languages=c,c++ --disable-multilib
--disable-libunwind-exceptions
Thread model: posix
gcc version 4.1.1

# ./configure (about as simple as it gets)
# make
...
ext/mysql/libmysql/my_tempnam.o: In function `my_tempnam':
my_tempnam.c:(.text+0x69): warning: the use of `tempnam' is dangerous,
better use `mkstemp'
main/output.o: In function `php_output_init_globals':
output.c:(.text+0x12): undefined reference to `php_default_output_func'
output.c:(.text+0x23): undefined reference to `php_default_output_func'
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php] Error 1

If I try and build a DSO for Apache 1.3.37, using:

./configure \
--prefix=~/tools/php \
--with-xsl=~/tools/libxslt \             
--with-openssl=~/tools/openssl \             
--with-libxml-dir=~/tools/libxml2 \             
--with-zlib=~/tools/zlib \             
--without-xmlrpc \             
--without-bz2 \             
--with-mysql \             
--without-sqlite \             
--enable-force-cgi-redirect \             
--enable-memory-limit \             
--disable-pear \             
--disable-ipv6 \
--with-pgsql=/home/jonathan/sw/build/pgclient \
--with-apxs=~/tools/apache/bin/apxs

Then I receive:

/usr/local/gcc411/lib/gcc/x86_64-unknown-linux-gnu/4.1.1/../../../../x86
_64-unknown-linux-gnu/bin/ld: main/output.lo: relocation R_X86_64_PC32
against `php_default_output_func' can not be used when making a shared
object; recompile with -fPIC
/usr/local/gcc411/lib/gcc/x86_64-unknown-linux-gnu/4.1.1/../../../../x86
_64-unknown-linux-gnu/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [libphp4.la] Error 1

Compile output shows main/output.c _is_built using -fPIC:

/bin/sh /home/jonathan/sw/build/php-4.4.4/libtool --silent
--preserve-dup-deps --mode=compile gcc  -Imain/
-I/home/jonathan/sw/vbuild/php-4.4.4/main/ -DPHP_ATOM_INC
-I/home/jonathan/sw/build/php-4.4.4/include
-I/home/jonathan/sw/build/php-4.4.4/main
-I/home/jonathan/sw/build/php-4.4.4
-I~/tools/openssl/include 
-I~/tools/zlib/include
-I/home/jonathan/sw/build/pgclient/
-I/home/jonathan/sw/build/php-4.4.4/ext/xml/expat
-I/home/jonathan/sw/build/php-4.4.4/TSRM
-I/home/jonathan/sw/build/php-4.4.4/Zend    -m64 -fPIC   -c
/home/jonathan/sw/build/php-4.4.4/main/output.c -o
main/output.lo

Expected result:
----------------
I would expect a properly built PHP instance.

Actual result:
--------------
Unless I use GCC 3.4.6 (the default on this system), I cannot build
PHP.
 [2007-02-02 22:41 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-02-05 15:40 UTC] shane at hemc dot coop
Is there a fix for the 4.4.4 version? I cannot upgrade to v5 quite yet...please help.
 [2007-02-06 16:13 UTC] earlej at hotmail dot com
Yes.. for various reasons, we also cannot upgrade to 5.x.  Perhaps, one day, time permitting, I will again be able to test the building of 5.x on all our systems, but so far, we've found the 4.x series to be the most (easily) compilable (via scripted operations) across our systems.
 [2007-02-06 17:14 UTC] tony2001@php.net
Works just fine with GCC 4.1.1 and GCC 4.1.2.
 [2007-02-07 20:53 UTC] earlej at hotmail dot com
Are you trying PHP 4.4.4 or 5.x?

I downloaded GCC 4.1.1 within the last week from gcc.gnu.org and have had this problem since.  Can you suggest anything (build options for gcc/php, tests to run, magic spells, etc?) to try and troubleshoot this?
 [2007-02-07 20:56 UTC] tony2001@php.net
>Are you trying PHP 4.4.4 or 5.x?
Both.

>Can you suggest anything 
I can suggest only using default GCC instead of manually built (unless you're testing GCC).
 [2007-02-09 14:19 UTC] earlej at hotmail dot com
Fixed my issue.  If this is suitable, can this be incorporated into the 4.4.4 codebase?

I got the idea elsewhere - forget where - to remove the inline keyword as the compiler (GCC 4.0+, IIRC) seems to put the code for the (inline) function _after_ the first incantation of the function.  I don't profess to understand how compilers do the magic they do but that is my (very) basic understanding of what happens.  This fixes things (and I see that inline has also been removed from the 5.x tree).

# Allow PHP 4.4.4 to build on a 64-bit environment using 
# GCC 4.1.1. Seems to be correctd in 5.x.
cd ${BUILD}/${SD_PHP}
cp main/output.c main/output.c.bak
$SED -e '53 s/inline//' main/output.c.bak > main/output.c
 [2007-02-09 14:24 UTC] tony2001@php.net
Does it work for you with this patch:
http://tony2001.phpclub.net/dev/tmp/bug40335.diff
?
 [2007-02-09 14:26 UTC] earlej at hotmail dot com
Oh.. found where I got the hint about removing the inline keyword (of course, I find it _after_ I post my results):

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30153
 [2007-02-09 14:49 UTC] tony2001@php.net
Could you please test the patch from the previous comment?
 [2007-02-09 18:31 UTC] earlej at hotmail dot com
Hi,

Thank you.  Yes, I tested the patch - it builds without error on RHEL with GCC 4.1.1 and 3.4.6 as well as on AIX5.3 with GCC 4.0.0.  Both systems are using 64-bit builds.

Cheers!
Jon
 [2007-02-12 17:13 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 17:01:32 2024 UTC