php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26462 bcmath doesn't compile as module
Submitted: 2003-11-29 07:34 UTC Modified: 2003-12-01 09:17 UTC
From: jdolecek at NetBSD dot org Assigned: sniper (profile)
Status: Closed Package: BC math related
PHP Version: 4.3.4 OS: NetBSD 1.6ZF
Private report: No CVE-ID: None
 [2003-11-29 07:34 UTC] jdolecek at NetBSD dot org
Description:
------------
NetBSD pkgsrc compiles modules individually, using phpize et.al. bcmath config.m4 doesn't have correct paths, so some includes are not properly found and compile fails. Furthermore, it still insists on number.c being present, which is apparently not needed (it used to be needed in past, I guess).

Note some care needs to be taken for the include
paths, since some files include "config.h", which
need to pick up the proper one - bcmath configure
or libbcmath one - appropriately.

Compile ends up with something along:

In file included from /usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/php_bcmath.h:26,
                 from /usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/bcmath.c:30:
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/bcmath.h:56:35: ext/bcmath/php_bcmath.h: No such file or directory

Following patch fixes the problem:

--- config.m4.orig      2002-03-07 15:18:01.000000000 +0100
+++ config.m4   2003-08-31 18:24:27.000000000 +0200
@@ -7,11 +7,11 @@

 if test "$PHP_BCMATH" != "no"; then
   AC_DEFINE(WITH_BCMATH, 1, [Whether you have bcmath])
-  PHP_NEW_EXTENSION(bcmath, bcmath.c number.c \
+  PHP_NEW_EXTENSION(bcmath, bcmath.c \
 libbcmath/src/add.c libbcmath/src/div.c libbcmath/src/init.c libbcmath/src/neg.c libbcmath/src/outofmem.c libbcmath/src/raisemod.c libbcmath/src/rt.c libbcmath/src/sub.c \
 libbcmath/src/compare.c libbcmath/src/divmod.c libbcmath/src/int2num.c libbcmath/src/num2long.c libbcmath/src/output.c libbcmath/src/recmul.c \
 libbcmath/src/sqrt.c libbcmath/src/zero.c libbcmath/src/debug.c libbcmath/src/doaddsub.c libbcmath/src/nearzero.c libbcmath/src/num2str.c libbcmath/src/raise.c \
 libbcmath/src/rmzero.c libbcmath/src/str2num.c,
-          $ext_shared,,-I@ext_srcdir@/libbcmath/src)
+          $ext_shared,,-I@ext_srcdir@ -I@ext_srcdir@/../.. -I@ext_srcdir@/libbcmath/src)
   PHP_ADD_BUILD_DIR($ext_builddir/libbcmath/src)
 fi

The patch is also available on NetBSD CVSweb server:

http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/pkgsrc/math/php4-bcmath/patches/patch-aa?rev=1.2&content-type=text/plain



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-29 08:15 UTC] sniper@php.net
I'm working on this. (btw. The patch here is not ok..)

 [2003-11-29 08:36 UTC] sniper@php.net
Fixed in CVS, here's the patch:

http://www.php.net/~jani/patches/bug26462.patch

 [2003-11-29 08:59 UTC] jdolecek at NetBSD dot org
No, compile still fails with:

cc -I/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src -I. -I/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath -DPHP_ATOM_INC -I/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/include -I/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/main -I/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath -I/usr/obj/pkgsrc/math/php4-bcmath/work/.buildlink/include/php -I/usr/obj/pkgsrc/math/php4-bcmath/work/.buildlink/include/php/main -I/usr/obj/pkgsrc/math/php4-bcmath/work/.buildlink/include/php/Zend -I/usr/obj/pkgsrc/math/php4-bcmath/work/.buildlink/include/php/TSRM -I/usr/obj/pkgsrc/math/php4-bcmath/work/.buildlink/include -DHAVE_CONFIG_H -O2 -pipe -I/usr/obj/pkgsrc/math/php4-bcmath/work/.buildlink/include -c /usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c  -fPIC -DPIC -o libbcmath/src/.libs/init.o
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c: In function `bc_init_numbers':
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:105: error: `_zero_' undeclared (first use in this function)
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:105: error: (Each undeclared identifier is reported only once
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:105: error: for each function it appears in.)
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:105: error: invalid lvalue in assignment
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:106: error: `_one_' undeclared (first use in this function)
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:106: error: invalid lvalue in assignment
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:107: error: invalid type argument of `->'
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:108: error: `_two_' undeclared (first use in this function)
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:108: error: invalid lvalue in assignment
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:109: error: invalid type argument of `->'
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c: In function `bc_init_num':
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:128: error: `_zero_' undeclared (first use in this function)
/usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath/libbcmath/src/init.c:128: warning: passing arg 1 of `bc_copy_num' makes pointer from integer without a cast
*** Error code 1

Stop.
make: stopped in /usr/obj/pkgsrc/math/php4-bcmath/work/php-4.3.4/ext/bcmath
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/math/php4-bcmath
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/math/php4-bcmath

I believe this is caused by libbcmath/init.c picking up 'wrong' config.h.
 [2003-11-30 03:36 UTC] sniper@php.net
Exactly HOW is the configure run? Give the full process, not just some part of it..

 [2003-12-01 03:26 UTC] jdolecek at NetBSD dot org
Sorry about not providing the steps at first.
Here it is:

1. tar xzf php-4.3.4.tar.bz2 php-4.3.4/ext/bcmath
2. cd php-4.3.4/ext/bcmath
3. patch < patch1; patch < patch2
4. phpize
5. ./configure --enable-bcmath
6. gmake

patch1 and patch2 are your two patches.

These steps get me reliably to the same compilation failure, as pasted in previous feedback.
 [2003-12-01 03:49 UTC] sniper@php.net
What two patches? There's exactly 1 (one) file I gave.
Anyway, this works just fine for me..

What libtool, autoconf and automake versions you're using?
Is the phpize you're using from PHP 4.3.4 ?


 [2003-12-01 07:17 UTC] jdolecek at NetBSD dot org
I split your patch into two files, so that there would
we one patch per patched file.

Yes, phpize is from PHP 4.3.4.

libtool 1.4
autoconf 2.57
automake 1.7.6

Note: all other php4 modules build fine, so it's only problem with bcmath. Perhaps 'your' libfool magically strips some -I directives? Can you paste your compile line for libcmath/src/init.c?

The problem happens due to init.c not picking .../ext/bcmath/config.h before including php_bcmath.h. Due to this, the #ifdef WITH_BCMATH block won't be included. Thus, BCG() macro is not defined and obviously the compile fails due to 'missing' _zero_ et.al. I'm not sure why it works for you - this is obviously wrong and shouldn't work anywhere.

Anyway, adding #include "../../config.h" just before #include "../../php_bcmath.h" in bcmath.h fixed the compile problem, thus this updated patch to bcmath.h works fine:

--- bcmath.h.orig       2002-11-22 10:27:08.000000000 +0100
+++ bcmath.h    2003-12-01 13:10:05.000000000 +0100
@@ -52,8 +52,9 @@
                           in the case of leading zeros generated. */
     } bc_struct;

-#include <php.h>
-#include <ext/bcmath/php_bcmath.h>
+#include "php.h"
+#include "../../config.h"
+#include "../../php_bcmath.h"


Note the file should really use #include <php.h>, because
php.h comes from installed PHP headers, not local bcmath module stuff. So I propose this patch as 'final':

--- libbcmath/src/bcmath.h.orig 2002-11-22 10:27:08.000000000 +0100
+++ libbcmath/src/bcmath.h      2003-12-01 13:16:46.000000000 +0100
@@ -53,7 +53,8 @@
     } bc_struct;

 #include <php.h>
-#include <ext/bcmath/php_bcmath.h>
+#include "../../config.h"
+#include "../../php_bcmath.h"


 /* The base used in storing the numbers in n_value above.


With this patch (and the config.m4 fix to not include number.c), the module compiles fine for me.
 [2003-12-01 09:01 UTC] sniper@php.net
This patch should work better:

http://www.php.net/~jani/patches/bug26462.patch

(fixed in CVS too)

 [2003-12-01 09:17 UTC] jdolecek at NetBSD dot org
Yes, this works. Arguably it's not right to #ifdef HAVE_CONFIG_H just ../../config.h, since it's always necessary to bring that in before you #include php_bcmath.h and it's not related to libbcmath build per-se (it's libbcmath configure which defines HAVE_CONFIG_H). It would be also aesthetically more pleasing to use #include <php.h> instead of #include "php.h".

But I don't really care about the details. It's cool it now compiles out of box. Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC