Unable to build lxml with --static-deps

Bug #1389090 reported by Andy Freeland
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
lxml
Invalid
Undecided
Unassigned

Bug Description

Ubuntu 14.04 x86_64
Python 2.7
libxml2-dev: 2.9.1+dfsg1-3ub
libxslt1-dev: 1.1.28-2build1
gcc: gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

When running python setup.py bdist_wheel --static-deps, I get an error while building libiconv:

make[2]: Entering directory `/build/lxml-3.4.0/build/tmp/libiconv-1.14/srclib'
make[3]: Entering directory `/build/lxml-3.4.0/build/tmp/libiconv-1.14'
make[3]: Nothing to be done for `am--refresh'.
make[3]: Leaving directory `/build/lxml-3.4.0/build/tmp/libiconv-1.14'
gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -g -O2 -c allocator.c
gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -g -O2 -c areadlink.c
gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -g -O2 -c careadlinkat.c
gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -g -O2 -c malloca.c
gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -g -O2 -c progname.c
gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -g -O2 -c safe-read.c
In file included from progname.c:26:0:
./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
 ^
gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -g -O2 -c -o width.o `test -f 'uniwidth/width.c' || echo './'`uniwidth/width.c
gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -g -O2 -c xmalloc.c
make[2]: *** [progname.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/build/lxml-3.4.0/build/tmp/libiconv-1.14/srclib'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/build/lxml-3.4.0/build/tmp/libiconv-1.14/srclib'
make: *** [all] Error 2
Traceback (most recent call last):
  File "app_main.py", line 75, in run_toplevel
  File "setup.py", line 230, in <module>
    **setup_extra_options()
  File "setup.py", line 144, in setup_extra_options
    STATIC_CFLAGS, STATIC_BINARIES)
  File "/build/lxml-3.4.0/setupinfo.py", line 57, in ext_modules
    multicore=OPTION_MULTICORE)
  File "/build/lxml-3.4.0/buildlibxml.py", line 348, in build_libxml2xslt
    cmmi(configure_cmd, libiconv_dir, multicore, **call_setup)
  File "/build/lxml-3.4.0/buildlibxml.py", line 285, in cmmi
    cwd=build_dir, **call_setup)
  File "/build/lxml-3.4.0/buildlibxml.py", line 268, in call_subprocess
    raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode))
Exception: Command "make -j5" returned code 512

Other projects have solved this by patching libiconv: https://github.com/mxe/mxe/issues/204

Andy Freeland (rouge8)
description: updated
Revision history for this message
scoder (scoder) wrote :

Just in case: please make sure you do not have a file "stdio.h" lying around somewhere in your build directory or so. At a quick glance, I couldn't find one in the libiconv sources.

Revision history for this message
Andy Freeland (rouge8) wrote :

(venv)root@516c2cc7b85a:/build/lxml-3.4.0# find . -name "stdio.h"
./build/tmp/libiconv-1.14/srclib/stdio.h

That only appears after the failed build.

Revision history for this message
Stefano (fontana-stefano0) wrote :

I'm also affected by this issue.
Linux ip-172-31-15-59 3.13.0-24-generic
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
lxml 3.4.1

Revision history for this message
malraux (scottanderson42) wrote :

I was able to get this to compile on an Amazon Linux AMI by doing the following:

1) Create an include file somewhere that looks like this:

[ec2-user@ip-172-30-0-8 ~]$ cat tmp_gets.h
#include "stdio.h"

#ifndef gets
    extern char *gets (char *__s);
#endif

2) Add the include file to CFLAGS so it is included in every file being compiled, -fPIC to avoid linker errors at the end of the compile, and -lgcrypt to avoid errors importing lxml.gtree:

STATIC_DEPS=true CFLAGS="-include /home/ec2-user/tmp_gets.h -fPIC -lgcrypt" pip install lxml

(myvenv)[ec2-user@ip-172-30-0-8 ~]$ python
Python 2.7.9 (default, Mar 4 2015, 20:43:00)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>> from bs4 import BeautifulSoup
>>> html = "<html><head></head<body><div>I like turnips.</div></body></html>"
>>> bs = BeautifulSoup(html, "lxml")
>>> bs.find('div')
<div>I like turnips.</div>

Revision history for this message
malraux (scottanderson42) wrote :

Actually it seems to work without this part too:

#ifndef gets
    extern char *gets (char *__s);
#endif

Revision history for this message
scoder (scoder) wrote :

Is this still an issue?

Changed in lxml:
status: New → Incomplete
Revision history for this message
scoder (scoder) wrote :

Closing. Probably resolved upstream.

Changed in lxml:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.