All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] php: fix emalloc/efree/estrdup/... undefined references
@ 2018-04-05 21:06 Thomas Petazzoni
  2018-04-09  9:24 ` Thomas Petazzoni
  2018-04-09 15:50 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2018-04-05 21:06 UTC (permalink / raw)
  To: buildroot

zend_alloc.h defines some macros such as:

Where _estrdup is the actual function implemented by the PHP core. If
this header file is not included, and some code uses estrdup, one ends
up with an undefined reference. This happens when libexpat support is
enabled. This commit adds a PHP patch that fixes this issue. The patch
has been submitted upstream through a Github pull request.

Fixes:

  http://autobuild.buildroot.net/results/889d2c1f509c035cd506e36061939bfddc8f1500/

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 ...-expat_compat.h-add-missing-php.h-include.patch | 71 ++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 package/php/0009-ext-xml-expat_compat.h-add-missing-php.h-include.patch

diff --git a/package/php/0009-ext-xml-expat_compat.h-add-missing-php.h-include.patch b/package/php/0009-ext-xml-expat_compat.h-add-missing-php.h-include.patch
new file mode 100644
index 0000000000..daf004dcf7
--- /dev/null
+++ b/package/php/0009-ext-xml-expat_compat.h-add-missing-php.h-include.patch
@@ -0,0 +1,71 @@
+From fb1f0e17eed729204a6d5caf590715d6257dceb3 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Date: Thu, 5 Apr 2018 22:50:00 +0200
+Subject: [PATCH] ext/xml/expat_compat.h: add missing php.h include
+
+When expat support is disabled and libxml support is enabled, the
+following part of the code in expat_compat.h gets used:
+
+and therefore "php".h" is included. However, when libexpat support is
+enabled, HAVE_LIBEXPAT is defined, and therefore the following part of
+the code is used:
+
+In this case, "php.h" is not included. Due to this, zend_alloc.h is
+never included when building the ext/xmlrpc/libxmlrpc/xml_element.c
+file, and therefore the estrdup -> _estrdup macros are never defined,
+causing the following link time failure:
+
+ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_element_serialize':
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:462: undefined reference to `efree'
+ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_elem_entity_escape':
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:347: undefined reference to `emalloc'
+ext/xmlrpc/libxmlrpc/xml_element.o: In function `_xmlrpc_charHandler':
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:646: undefined reference to `efree'
+ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_elem_free_non_recurse':
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:198: undefined reference to `efree'
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:199: undefined reference to `efree'
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:200: undefined reference to `efree'
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:207: undefined reference to `efree'
+ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_elem_new':
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:263: undefined reference to `ecalloc'
+ext/xmlrpc/libxmlrpc/xml_element.o: In function `_xmlrpc_startElement':
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:602: undefined reference to `estrdup'
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:607: undefined reference to `emalloc'
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:609: undefined reference to `estrdup'
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:610: undefined reference to `estrdup'
+ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_elem_free_non_recurse':
+/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:211: undefined reference to `efree'
+collect2: error: ld returned 1 exit status
+make: *** [Makefile:248: sapi/cgi/php-cgi] Error 1
+
+This link time failure can be produced with:
+
+./configure --prefix=/usr --with-libdir=/usr/lib64 --disable-all \
+	    --without-pear --with-config-file-path=/etc --disable-phpdbg \
+	    --disable-cli --enable-cgi --disable-fpm --enable-xmlreader \
+	    --enable-xmlwriter --enable-libxml --enable-wddx --with-xmlrpc \
+	    --with-libexpat-dir=/
+
+We fix it by including "php.h" in the HAVE_LIBEXPAT case.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Upstream-status: https://github.com/php/php-src/pull/3212
+---
+ ext/xml/expat_compat.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/ext/xml/expat_compat.h b/ext/xml/expat_compat.h
+index ed621ab53d..29fe48a7dd 100644
+--- a/ext/xml/expat_compat.h
++++ b/ext/xml/expat_compat.h
+@@ -154,6 +154,7 @@ PHP_XML_API const XML_Char *XML_ExpatVersion(void);
+ PHP_XML_API void XML_ParserFree(XML_Parser);
+ 
+ #elif defined(HAVE_LIBEXPAT)
++#include "php.h"
+ #include <expat.h>
+ #endif /* HAVE_LIBEXPAT */
+ 
+-- 
+2.14.3
+
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] php: fix emalloc/efree/estrdup/... undefined references
  2018-04-05 21:06 [Buildroot] [PATCH] php: fix emalloc/efree/estrdup/... undefined references Thomas Petazzoni
@ 2018-04-09  9:24 ` Thomas Petazzoni
  2018-04-09 15:50 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2018-04-09  9:24 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu,  5 Apr 2018 23:06:22 +0200, Thomas Petazzoni wrote:
> zend_alloc.h defines some macros such as:
> 
> Where _estrdup is the actual function implemented by the PHP core. If
> this header file is not included, and some code uses estrdup, one ends
> up with an undefined reference. This happens when libexpat support is
> enabled. This commit adds a PHP patch that fixes this issue. The patch
> has been submitted upstream through a Github pull request.
> 
> Fixes:
> 
>   http://autobuild.buildroot.net/results/889d2c1f509c035cd506e36061939bfddc8f1500/
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> ---
>  ...-expat_compat.h-add-missing-php.h-include.patch | 71 ++++++++++++++++++++++
>  1 file changed, 71 insertions(+)
>  create mode 100644 package/php/0009-ext-xml-expat_compat.h-add-missing-php.h-include.patch

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] php: fix emalloc/efree/estrdup/... undefined references
  2018-04-05 21:06 [Buildroot] [PATCH] php: fix emalloc/efree/estrdup/... undefined references Thomas Petazzoni
  2018-04-09  9:24 ` Thomas Petazzoni
@ 2018-04-09 15:50 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2018-04-09 15:50 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@bootlin.com> writes:

 > zend_alloc.h defines some macros such as:

 > Where _estrdup is the actual function implemented by the PHP core. If

Lines starting with # are automatically dropped by git ;)

 > +++ b/package/php/0009-ext-xml-expat_compat.h-add-missing-php.h-include.patch
 > @@ -0,0 +1,71 @@
 > +From fb1f0e17eed729204a6d5caf590715d6257dceb3 Mon Sep 17 00:00:00 2001
 > +From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
 > +Date: Thu, 5 Apr 2018 22:50:00 +0200
 > +Subject: [PATCH] ext/xml/expat_compat.h: add missing php.h include
 > +
 > +When expat support is disabled and libxml support is enabled, the
 > +following part of the code in expat_compat.h gets used:
 > +

Here as well ;)

Committed to 2018.02.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-09 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05 21:06 [Buildroot] [PATCH] php: fix emalloc/efree/estrdup/... undefined references Thomas Petazzoni
2018-04-09  9:24 ` Thomas Petazzoni
2018-04-09 15:50 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.