Subject: Re: [FEniCS-dev] Build time bugs in syfi and segfaults in dolfin -- Partially Fixed

From: Balbir Thomas <[email-masked]>
Date: Wed, 11 Feb 2009 20:23:15 -0500

Hi,

Looks like Harish was right. Rebuilding after update alternatives does seem
to solve the problem with C++ files. Of course I had to edit the scons file
and remove "-Werror" to build dolfin. I am now able to build and
successfully run the C++ demos (have not tested them all). This does
indicate Fenics has problems with mpich. Perhaps the build scripts and
dependencies in the packaging system need to take this into consideration.
Also  a note in big bold letters would help :-) .

However the python demos fail (at least all the ones I checked). For
instance demo/pde/poisson/python/demo.py produces the following error :

bt@ps:$ python demo.py
[darwin:04934] mca: base: component_find: unable to open osc pt2pt: file not
found (ignored)
Checking mesh ordering (finished).
Calling just-in-time (JIT) compiler, this may take some time... WARNING:
Didn't find dolfin.i in include paths returned from pkg-config.
In instant.recompile: The module did not compile, see
'/tmp/tmp0FoES72009-2-12-01-13_instant/dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e/compile.log'
Traceback (most recent call last):
  File "demo.py", line 31, in <module>
    u0 = Constant(mesh, 0.0)
  File "/usr/lib/python2.5/site-packages/dolfin/constant.py", line 38, in
Constant
    return Function(V, cppexpr)
  File "/usr/lib/python2.5/site-packages/dolfin/function.py", line 498, in
__new__
    cpp_base = compile_function([cpparg],[defaults])[0]
  File "/usr/lib/python2.5/site-packages/dolfin/compile_function.py", line
335, in compile_function
    function_classes =
compile_function_code("\n\n".join(code_snippets),classnames)
  File "/usr/lib/python2.5/site-packages/dolfin/compile_function.py", line
272, in compile_function_code
    signature      = module_name
  File "/usr/lib/python2.5/site-packages/instant/build.py", line 423, in
build_module
    recompile(modulename, module_path, setup_name, new_compilation_checksum)
  File "/usr/lib/python2.5/site-packages/instant/build.py", line 101, in
recompile
    "compile, see '%s'" % compile_log_filename)
  File "/usr/lib/python2.5/site-packages/instant/output.py", line 49, in
instant_error
    raise RuntimeError(text)
RuntimeError: In instant.recompile: The module did not compile, see
'/tmp/tmp0FoES72009-2-12-01-13_instant/dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e/compile.log'

The contents of
/tmp/tmp0FoES72009-2-12-01-13_instant/dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e/compile.log
show

bt@ps:$ more
/tmp/tmp0FoES72009-2-12-01-13_instant/dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e/compile.log
dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e.i:97: Error: Unable
to find 'dolfin.i'
running build_ext
building '_dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e'
extension
creating build
creating build/temp.linux-i686-2.5
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC
-I/home/bt/debian/sources/dolfin/dolfin-0.9.0/debian/tmp/include -I/
usr/lib/python2.5/site-packages/numpy/core/include
-I/usr/include/suitesparse -I/usr/include/python2.5
-I/usr/lib/petsc/bmake/linux-gnu-c-opt -I/usr/lib/petsc
/include -I/usr/lib/openmpi/include -I/usr/lib/openmpi/lib -I.
-I/usr/include/scotch -I/usr/include/libxml2 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/includ
e -I/usr/lib/python2.5/site-packages/numpy/core/include
-I/usr/include/python2.5 -c
dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e_wrap.cxx -o build
/temp.linux-i686-2.5/dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e_wrap.o
gcc: dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e_wrap.cxx: No
such file or directory
gcc: no input files
error: command 'gcc' failed with exit status 1

The contents of the temporary folder are

bt@ps:$ tree
/tmp/tmp0FoES72009-2-12-01-13_instant/dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e/
/tmp/tmp0FoES72009-2-12-01-13_instant/dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e/
|-- __init__.py
|-- build
|   `-- temp.linux-i686-2.5
|-- compile.log
|-- dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e.i
`-- setup.py

So I note dolfin.i and the cxx file could not be found. Where are these
supposed to be and or what is supposed to generate them ? I would be
grateful for any other suggestions to help fix these.

PS: i still need to read the manual but am distracted by having to build and
install dolfin correctly. So apologies if i should know something i dont.

regards
bt

---

From: "Johannes Ring" <[email-masked]>
Date: Thu, 12 Feb 2009 08:19:59 +0100 (CET)

Hi Balbir,

I am the maintainer of the FEniCS packages for Debian/Ubuntu. If you want
to build Debian packages for Lenny I will recommend you to use the Debian
control files in the pkg-scicomp Subversion repository [1]. If you want
and there is a demand for it I could easily add packages for Lenny to the
FEniCS repository.

The reason the DOLFIN package doesn't build depend on some implementation
of MPI is because it already depend on PETSc and PETSc again is built with
OpenMPI in Debian.

If you have any patches, please forward them to the pkg-scicomp mailing
list [2]. Please continue the discussion at [email-masked].

[1] svn://svn.debian.org/svn/pkg-scicomp/fenics/
[2] http://lists.alioth.debian.org/mailman/listinfo/pkg-scicomp-devel

Johannes

---

From: Johan Hake <[email-masked]>
Date: Thu, 12 Feb 2009 11:28:56 +0100

> and remove "-Werror" to build dolfin. 

Is it to be able to build PyDOLFIN you need this? Then you can remove it 
before building the swig generated wrapper files, look into dolfin/SConscript 
around line 235. This is fixed in the development version.

> I am now able to build and 

As Johannes pointed out in an other email, the DOLFIN package is dependent on 
the PETSc deb package which is compiled using OpenMPI. 

> [darwin:04934] mca: base: component_find: unable to open osc pt2pt: file
> not found (ignored)
> Calling just-in-time (JIT) compiler, this may take some time... 
> WARNING: Didn't find dolfin.i in include paths returned from pkg-config.

This line show that dolfin.i has not been found. In the development version we 
raise an Exception here, with better user information.

If dolfin.i is not found the cxx file won't be built, so that's why this file 
is not found. Where is DOLFIN installed and what does

  pkg-config dolfin --cflags

return?

> '/tmp/tmp0FoES72009-2-12-01-13_instant/dolfin_compile_function_c2c6ca28e8e2
>9b2498da8bbcedb6ff5e/compile.log' Traceback (most recent call last):
>     recompile(modulename, module_path, setup_name,
> new_compilation_checksum) File
> "/usr/lib/python2.5/site-packages/instant/build.py", line 101, in recompile
> /tmp/tmp0FoES72009-2-12-01-13_instant/dolfin_compile_function_c2c6ca28e8e29
>b2498da8bbcedb6ff5e/compile.log show
>
> bt@ps:$ more
> dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e.i:97: Error:
> Unable to find 'dolfin.i'
> running build_ext
> /temp.linux-i686-2.5/dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff
>5e_wrap.o gcc:
> dolfin_compile_function_c2c6ca28e8e29b2498da8bbcedb6ff5e_wrap.cxx: No such
> file or directory
> gcc: no input files
> PS: i still need to read the manual but am distracted by having to build
> and install dolfin correctly. So apologies if i should know something i
> dont.

The manual is unfortunatley quite outdated.

Johan

---

From: Balbir Thomas <[email-masked]>
Date: Thu, 12 Feb 2009 05:49:44 -0500

All dolfin packages are installed including libdolfin0-dev. And yes dolfin.i
is in /usr/include/dolfin/swig. However package-config --cflags dolfin
results in

bt@~:$ pkg-config --cflags dolfin
-Wall -pipe -ansi -DDEBUG -g -DNDEBUG -O2 -DHAS_MPI=1
-DMPICH_IGNORE_CXX_SEEK -DPACKAGE_VERSION="0.9.0" -DHAS_PETSC=1
-DHAS_SCOTCH=1 -DHAS_UMFPACK=1 -DHAS_GTS=1 -DHAS_CHOLMOD=1
-fno-strict-aliasing -pthread
-I/home/bt/debian/sources/dolfin/dolfin-0.9.0/debian/tmp/include
-I/usr/lib/python2.5/site-packages/numpy/core/include
-I/usr/include/suitesparse -I/usr/include/python2.5
-I/usr/lib/petsc/bmake/linux-gnu-c-opt -I/usr/lib/petsc/include
-I/usr/lib/openmpi/include -I/usr/lib/openmpi/lib -I. -I/usr/include/scotch
-I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include

Looks like this is the problem -->
-I/home/bt/debian/sources/dolfin/dolfin-0.9.0/debian/tmp/include

The include directory is being set relative to the build directory of the
debian source package. How and were does this get generated ?

I notice the following in debian/rules

        # Generate pkg-config file for DOLFIN based on pkg-config
files

        # in
scons/pkgconfig:

        python$* debian/gen_pkgconf.py debian/tmp/dolfin.pc

But am still trying to pin-point the error.

regards
bt

---

From: Balbir Thomas <[email-masked]>
Date: Thu, 12 Feb 2009 06:20:13 -0500

Hi,

I think the only problem remaining now is why is the pkg-config cflags are
wrong. The include directory points to the build directory not the install
directory.

/home/bt/debian/source/dolfin is the directory in which I unpack the debian
source package and build it resulting in
"-I/home/bt/debian/sources/dolfin/dolfin-0.9.0/debian/tmp/include"

As regards to "swig_cmd" in setup.py I am not sure what you mean by this.
The only setup.py in the source directory is

[email-masked]:$ find ./ -name setup.py
./scons/simula-scons/setup.py

I don't see and swig_cmd in setup.py

[email-masked]:$ more `find ./ -name setup.py`
# -*- coding: utf-8 -*-
from distutils.core import setup
from distutils import sysconfig
import sys, os, glob

setup(name='simula-scons',
    version='0.1',
    description='Addons for building software with SCons',
    author='Ãsmund ÃdegÃ¥rd, Arve N. Knudsen, Ola Skavhaug, Johannes Ring',
    author_email=[email-masked]',
    license="MIT",
    url='http://www.simula.no',
    packages=['simula_scons', 'simula_scons.pkgconfiggenerators'],
    package_dir={'simula_scons': 'simula_scons',
'simula_scons.pkgconfiggenerators': 'simula_scons/pkgconfiggenerators'},
    )

I suspect that since the debian package is being built and installed in a
debian/tmp directory the erroneous include (in pkg-config files) is being
generated for this reason.

In debian rules the build is done by

install-%:
build

        # Add here commands to install the package into
debian/tmp

        PYTHON=python$* $(SCONS) install prefix=$(CURDIR)/debian/tmp

        # in
scons/pkgconfig:

so "prefix" is relative to the unpacked source directory "CURDIR" and is in
debian/tmp which is where the
/home/bt/debian/sources/dolfin/dolfin-0.9.0/debian/tmp is being generated

However the package config files are generated by debian/gen_pkgconf.py
using debian/tmp/dolfin.pc. Perhaps this script needs to rewrite the include
lines to point to the correct install directory i.e. /usr/include. Not sure
how this is to be done ? Shall I just use sed or is there a more elegant way
?

regards
bt

---

From: Balbir Thomas <[email-masked]>
Date: Thu, 12 Feb 2009 06:28:09 -0500

On Thu, Feb 12, 2009 at 6:21 AM, Johannes Ring <[email-masked]> wrote:
> Ok, I will do that.

Thank you very much. Kindly do post a patch to this thread.

regards
b thomas

---

From: Balbir Thomas <[email-masked]>
Date: Thu, 12 Feb 2009 07:50:58 -0500

On Thu, Feb 12, 2009 at 6:35 AM, Johannes Ring <[email-masked]> wrote:
>
> > I don't think that is the reason for it to fail because it should have
> > been replaced by /usr/include which is included anyway, and because there
> > is a similar line in dolfin.pc in the Ubuntu package
> > (-I/tmp/buildd/dolfin-0.9.0/debian/tmp/include) and this works without any
> > problems. However, we should still try to fix this. I think we need to add
> > some sort of DESTDIR support in the build system.

Looks like you are correct here. I just manually edited
/usr/lib/pkgconfig/dolfin.pc and set "prefix" to "/usr". This did not
solve the problem with python scripts and dolfin.i can not be found
still .  dolfin.i is installed as can be seen by

ls -l /usr/include/dolfin/swig/dolfin.i
-rw-r--r-- 1 root root 1705 2009-01-05 10:15 /usr/include/dolfin/swig/dolfin.i

> I was referring to the setup.py file from the temporary Instant directory
> which you posted earlier.

Here are the contents of setup.py in the temporary instant directory
-------------------------------------------------------------------------------------------------

[email-masked]:$ more
/tmp/tmpCMJ4kh2009-2-12-11-48_instant/dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b/setup.py

import os
from distutils.core import setup, Extension
name = 'dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b'
swig_cmd ='swig -python  -c++
dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b.i'
os.system(swig_cmd)
sources = ['dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b_wrap.cxx']
setup(name = 'dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b',
     ext_modules = [Extension('_' +
'dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b',
                    sources,

include_dirs=['/usr/lib/python2.5/site-packages/numpy/core/include',
'/usr/include/suitesparse', '/usr/include/python2.5', '/usr/lib/pets
c/bmake/linux-gnu-c-opt', '/usr/lib/petsc/include',
'/usr/lib/openmpi/include', '/usr/lib/openmpi/lib', '.',
'/usr/include/scotch', '/usr/include/libxml2', '/
usr/include/glib-2.0', '/usr/lib/glib-2.0/include',
'/usr/lib/python2.5/site-packages/numpy/core/include'],
                    library_dirs=['/usr/lib/atlas',
'/usr/lib/petsc/lib/linux-gnu-c-opt'],
                    libraries=['dolfin', 'umfpack', 'petscts',
'petscsnes', 'petscksp', 'petscdm', 'petscmat', 'petscvec', 'petsc',
'lapack', 'blas', 'cholmo
d', 'amd', 'colamd', 'scotch', 'scotcherr', 'gts', 'm', 'xml2',
'gthread-2.0', 'rt', 'gmodule-2.0', 'dl', 'glib-2.0']  )])

and once again the contents of the directory are
---------------------------------------------------------------------

[email-masked]:$ tree /tmp/tmpCMJ4kh2009-2-12-11-48_instant/
/tmp/tmpCMJ4kh2009-2-12-11-48_instant/
`-- dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b
   |-- __init__.py
   |-- build
   |   `-- temp.linux-i686-2.5
   |-- compile.log
   |-- dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b.i
   `-- setup.py

the contents of the compile.log is
-------------------------------------------------

[email-masked]:$ more
/tmp/tmpCMJ4kh2009-2-12-11-48_instant/dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b/compile.log
dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b.i:97: Error:
Unable to find 'dolfin.i'
running build_ext
building '_dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b' extension
creating build
creating build/temp.linux-i686-2.5
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC
-I/usr/lib/python2.5/site-packages/numpy/core/include -I/usr/include
/suitesparse -I/usr/include/python2.5
-I/usr/lib/petsc/bmake/linux-gnu-c-opt -I/usr/lib/petsc/include
-I/usr/lib/openmpi/include -I/usr/lib/openmpi/lib -I. -I
/usr/include/scotch -I/usr/include/libxml2 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include
-I/usr/lib/python2.5/site-packages/numpy/core/include -I/usr/in
clude/python2.5 -c
dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b_wrap.cxx -o
build/temp.linux-i686-2.5/dolfin_compile_function_df46e19d3b7dfd0a28ed
8c435a22313b_wrap.o
gcc: dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b_wrap.cxx:
No such file or directory
gcc: no input files
error: command 'gcc' failed with exit status 1

the contents of /usr/lib/pkgconfig/dolfin.pc (with the manually
corrected "prefix" variable) is
---------------------------------------------------------------------------------------------------------------------------------

[email-masked]:$ more /usr/lib/pkgconfig/dolfin.pc
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
compiler=mpic++

Name: DOLFIN
Description: Dynamic Object-oriented Library for FINite element computation
Version: 0.9.0
Requires: ufc-1 gts libxml-2.0
Conflicts:
Libs:   -L${libdir} -ldolfin -L/usr/lib/atlas -lblas -lumfpack -lamd
 -L/usr/lib/petsc/lib/linux-gnu-c-opt -lpetscts -lpetscsnes
-lpetscksp -lpetscdm -lpet
scmat -lpetscvec -lpetsc   -L/usr/lib/atlas -llapack -lblas -lcholmod
-lamd -lcolamd   -lscotch -lscotcherr
Cflags:  -Wall -pipe -ansi -DDEBUG -g -DNDEBUG -O2 -DHAS_MPI=1
-DMPICH_IGNORE_CXX_SEEK -DPACKAGE_VERSION=\"0.9.0\" -DHAS_PETSC=1
-DHAS_SCOTCH=1 -DHAS_UMFPACK=
1 -DHAS_GTS=1 -DHAS_CHOLMOD=1 -fno-strict-aliasing -I${includedir}
-I/usr/lib/python2.5/site-packages/numpy/core/include
-I/usr/include/suitesparse   -I/u
sr/include/python2.5   -I/usr/lib/petsc/bmake/linux-gnu-c-opt
-I/usr/lib/petsc/include -I/usr/lib/openmpi/include
-I/usr/lib/openmpi/lib -I.   -I/usr/include/
suitesparse   -I/usr/include/scotch

pkg-config --cflags dolfin now yields
---------------------------------------------------

[email-masked]:$ pkg-config --cflags dolfin
-Wall -pipe -ansi -DDEBUG -g -DNDEBUG -O2 -DHAS_MPI=1
-DMPICH_IGNORE_CXX_SEEK -DPACKAGE_VERSION="0.9.0" -DHAS_PETSC=1
-DHAS_SCOTCH=1 -DHAS_UMFPACK=1 -DHAS_GTS=1 -DHAS_CHOLMOD=1
-fno-strict-aliasing -pthread
-I/usr/lib/python2.5/site-packages/numpy/core/include
-I/usr/include/suitesparse -I/usr/include/python2.5
-I/usr/lib/petsc/bmake/linux-gnu-c-opt -I/usr/lib/petsc/include
-I/usr/lib/openmpi/include -I/usr/lib/openmpi/lib -I.
-I/usr/include/scotch -I/usr/include/libxml2 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include

the contents of /usr/include/dolfin is
---------------------------------------------------

[email-masked]:$ ls /usr/include/dolfin
ale  common  elements  fem  function  graph  io  la  log  main  math
mesh  mf  nls  ode  parameter  plot  quadrature  swig

and finally /usr/include/dolfin/swig is
-----------------------------------------------------

[email-masked]:$ ls /usr/include/dolfin/swig/
directors.i           dolfin_exceptions.i     dolfin_headers.i
dolfin_la_pre.i     dolfin_mesh_pre.i            ignores.i
typemaps.i
dolfin_common_post.i  dolfin_function_post.i  dolfin.i
dolfin_log_post.i   dolfin_pde_pre.i             numpy_typemaps.i
dolfin_docstrings.i   dolfin_function_pre.i   dolfin_la_post.i
dolfin_mesh_post.i  dolfin_shared_ptr_classes.i  renames.i

Hope this helps. Let me know if anything else.

regards
bt

---

From: Balbir Thomas <[email-masked]>
Date: Thu, 12 Feb 2009 08:00:11 -0500

Thought it would help to include the relavent lines (line 97) from
/tmp/tmpCMJ4kh2009-2-12-11-48_instant/dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b/dolfin_compile_function_df46e19d3b7dfd0a28ed8c435a22313b.i
where dolfin.i is being imported

the lines are :
-------------------

%include exception.i

%include std_vector.i
%template(STLVectorFunctionPtr) std::vector<dolfin::Function *>;
%pythoncode %{
import dolfin.cpp
'''
A hack to get passed a bug in swig.
This is fixed in swig svn, and will be shipped with swig 1.3.37
%}
%import dolfin.i
%pythoncode %{
'''
%}

Could there be a problem with the "hack" ?

regards
bt