|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42568 Compile fails when using --with-gmp option in MacOSX
Submitted: 2007-09-05 16:47 UTC Modified: 2008-11-04 01:00 UTC
Avg. Score:3.5 ± 1.7
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (66.7%)
From: jerry at scene-naturally dot dyndns dot org Assigned:
Status: No Feedback Package: GNU MP related
PHP Version: 5.2.4 OS: MacOSX 10.4.10
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-09-05 16:47 UTC] jerry at scene-naturally dot dyndns dot org
When PHP is compiled using the option --with-gmp=/usr/local (gmp being 
installed in /usr/local) PHP will not compile, failing with the error as 
noted below.

I have chatted with the developer for libgmp, and the gist of the result 
of the discussion is that this is a PHP bug.

Reproduce code:
gmp is compiled using 

./configure \
--prefix=/usr/local \
--enable-cxx \
--disable-shared \

as per the developer directions for installing libgmp on Mac OS X. (The subsequent build of GMP passes all tests.)

Expected result:
The usual result of a successful compile.

Actual result:
/usr/bin/ld: /usr/local/lib/libgmp.a(popcount.o) has local relocation 
entries in non-writable section (__TEXT,__text)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-06 11:06 UTC]
What was the full configure line for PHP?
 [2007-09-06 14:51 UTC] jerry at scene-naturally dot dyndns dot org
I tried this three different ways; (all crashed).

First way: a usual full list.

Second way:

./configure \
--prefix=/usr/local/apache2/php \
--with-config-file-path=/usr/local/apache2/php/lib \
--with-apxs2=/usr/local/apache2/bin/apxs \

This crashed as well, as did

./configure \

All done with fresh versions of PHP.
 [2007-09-06 22:27 UTC]
What if you compile GMP without --disable-shared ??
 [2007-09-07 01:26 UTC] jerry at scene-naturally dot dyndns dot org
There are serious problems with doing that. Libtool will switch to using 
CC instead of GCC to build the resulting shared library, which means 
most things that would in use the gmp library break because they need 
the GCC version, which is why the folks at GMP say to use the --
disabled-shared option for OS X.
 [2007-09-07 02:30 UTC] jerry at scene-naturally dot dyndns dot org
In order to be complete, I did check as you asked

compiling gmp via:

./configure \
--prefix=/usr/local \
--enable-cxx \

and using the resulting library to compile PHP via:
./configure \

PHP did configure and compile.

This leads to a conundrum though, Comparing the two libraries 
(libgmp.a built via the developers specs to libgmp.a built via your 
request) leads to 242 differences between the two static libraries.

This kind of throws cold waters on the hope of the idea of using the 
static library built the second way and tossing out the shared 
libraries (which come from not using the --disable-shared option).
 [2007-09-07 08:52 UTC]
My question is: Does it work? :D
You could try building PHP as well with --disable-shared..
 [2007-09-07 14:42 UTC] jerry at scene-naturally dot dyndns dot org
Actually that is the default for PHP -- to build with out shared 
libraries on OS X

checking whether the gcc linker (/usr/bin/ld) supports shared 
libraries... yes
checking dynamic linker characteristics... darwin8.10.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes

But I will try explicitly building using the --disable-shared option and 
see if that makes a difference.
 [2007-09-07 16:15 UTC] jerry at scene-naturally dot dyndns dot org
I had a chance to try the following;

GMP build via:

./configure \
--prefix=/usr/local \
--enable-cxx \
--disable-shared \

PHP configure:

./configure \
--with-gmp=/usr/local \

as requested, but running make for this configuration still crashes 
with the error

/usr/bin/ld: /usr/local/lib/libgmp.a(popcount.o) has local relocation 
entries in non-writable section (__TEXT,__text)
 [2007-09-11 12:32 UTC]
I have no idea how to fix this in PHP. And to me it seems more like a bug in either the tools in OSX used to compile/link and/or in libgmp. It works fine on Linux. :) Can you try and find out what the libgmp folks think might be wrong with PHP build system which might cause this kind of error? (I have no MacOSX machine to test anything so..)
 [2007-09-11 15:55 UTC] jerry at scene-naturally dot dyndns dot org
This is from the gmp folks:

"Well, I can only wish you luck since there is really nothing I can do
about this.  You need to dig in PHP to debug this.

You need to provide me with a test case that violates the documented
GMP behavior, then I will fix the error."

Therein is a problem, when gmp is build according to the developer's 
instructions, using it when building PHP is the only place things 
break, which does not violate the docs for gmp.
 [2007-09-13 10:18 UTC]
Assigned to the ext/gmp maintainer.
 [2007-11-05 19:12 UTC]
I'm afraid I don't know what to do with this - I don't have OS X readily available and OS linkage is quite exotic so I couldn't figure it out using other systems...
 [2008-10-27 13:44 UTC]
Please try using this CVS snapshot:
For Windows:

 [2008-11-04 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-10-29 22:52 UTC] syzygy at mvn dot net
I got php version 5.3.0 to compile using the "--with-gmp" option and gmp version 4.3.1 as follows:

gmp compile dialog:

  $ cd gmp-4.3.1 
  $ ./configure --build=i686-apple-darwin9.8.0 \
    --host=i686-apple-darwin9.8.0 --target=i686-apple-darwin9.8.0 
  $ make 
  $ make check
  $ make install
php compile dialog:

  $ cd php-5.3.0
  $ ./configure --build=i686-apple-darwin9.8.0 \
    --host=i686-apple-darwin9.8.0 --target=i686-apple-darwin9.8.0 \
    --with-apxs2=/usr/sbin/apxs --with-mysql=/usr/local/mysql \
    --with-mcrypt=/usr/local/bin/mcrypt --enable-mbstring \
    --enable-calendar --enable-ftp --enable-sockets --without-pear \
    --disable-cgi --with-zlib --with-pgsql=/usr/local/pgsql \
  $ make
  $ make test
  $ sudo make install

Hope this is helpful.  I realize this is an old bug, but I was also having the same problem.  I believe that the success of my build is probably related to the use of the "--build", "--host", and/or "--target" options, which are for my Mac OS X 10.5.8 laptop, and others are likely to need different specifications for other Mac OS X configurations.

The php configure options "--with-mysql" through "--with-pgsql" are probably unimportant to the success of this build, but I've included them for the sake of completeness, just because I haven't taken the time to test the build without them.

This php build is now up and running, and appears to be stable on preliminary testing, although I haven't yet tested any of the gmp functions.  If any of the gmp_ functions fail during future development I'll leave another comment (assuming this one is still here).  Thanks & long live PHP.
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC