FEniCS / ffcx

Next generation FEniCS Form Compiler for finite element forms
https://fenicsproject.org
Other
144 stars 38 forks source link

ABI incompatibility with c++17 dolfinx? #178

Closed francesco-ballarin closed 4 years ago

francesco-ballarin commented 4 years ago

Dear all,

I am currently compiling dolfinx on two machines (one Centos 7, the other Debian 10). The two systems provide luckily the same version of the compiler (g++ 8.3.0). I compile dolfinx and dependencies with the same scripts on both machines.

On the Debian 10 one, I get several failures while testing, the first one being

======================================================== FAILURES ========================================================
____________________________________________ test_assembly_dS_domains[mode0] _____________________________________________

mode = GhostMode.none

    @parametrize_ghost_mode
    def test_assembly_dS_domains(mode):
        N = 10
        mesh = dolfin.UnitSquareMesh(dolfin.MPI.comm_world, N, N, ghost_mode=mode)
        one = dolfin.Constant(mesh, 1)
>       val = dolfin.fem.assemble_scalar(one * ufl.dS)

fem/test_assemble_domains.py:179: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_dolfin-2019.2.0.dev0-py3.7-linux-x86_64.egg/dolfin/fem/assemble.py:70: in assemble_scalar
    return cpp.fem.assemble_scalar(_create_cpp_form(M))
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_dolfin-2019.2.0.dev0-py3.7-linux-x86_64.egg/dolfin/fem/assemble.py:24: in _create_cpp_form
    return Form(form)._cpp_object
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_dolfin-2019.2.0.dev0-py3.7-linux-x86_64.egg/dolfin/fem/form.py:43: in __init__
    mpi_comm=mesh.mpi_comm())
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_dolfin-2019.2.0.dev0-py3.7-linux-x86_64.egg/dolfin/jit.py:51: in mpi_jit
    return local_jit(*args, **kwargs)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_dolfin-2019.2.0.dev0-py3.7-linux-x86_64.egg/dolfin/jit.py:116: in ffc_jit
    r = ffc.codegeneration.jit.compile_forms([ufl_object], parameters=p, cache_dir=cache_dir, **cffi_options)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ffc-2019.2.0.dev0-py3.7.egg/ffc/codegeneration/jit.py:175: in compile_forms
    cffi_extra_compile_args, cffi_verbose, cffi_debug)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ffc-2019.2.0.dev0-py3.7.egg/ffc/codegeneration/jit.py:256: in _compile_objects
    _, code_body = ffc.compiler.compile_ufl_objects(ufl_objects, prefix="JIT", parameters=parameters)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ffc-2019.2.0.dev0-py3.7.egg/ffc/compiler.py:117: in compile_ufl_objects
    analysis = analyze_ufl_objects(ufl_objects, parameters)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ffc-2019.2.0.dev0-py3.7.egg/ffc/analysis.py:63: in analyze_ufl_objects
    form_data = tuple(_analyze_form(form, parameters) for form in forms)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ffc-2019.2.0.dev0-py3.7.egg/ffc/analysis.py:63: in <genexpr>
    form_data = tuple(_analyze_form(form, parameters) for form in forms)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ffc-2019.2.0.dev0-py3.7.egg/ffc/analysis.py:200: in _analyze_form
    complex_mode=complex_mode)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/algorithms/compute_form_data.py:332: in compute_form_data
    form = apply_restrictions(form)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/algorithms/apply_restrictions.py:175: in apply_restrictions
    only_integral_type=integral_types)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/algorithms/map_integrands.py:58: in map_integrand_dags
    form, only_integral_type)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/algorithms/map_integrands.py:39: in map_integrands
    for itg in form.integrals()]
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/algorithms/map_integrands.py:39: in <listcomp>
    for itg in form.integrals()]
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/algorithms/map_integrands.py:46: in map_integrands
    return itg.reconstruct(function(itg.integrand()))
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/algorithms/map_integrands.py:57: in <lambda>
    return map_integrands(lambda expr: map_expr_dag(function, expr, compress),
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/corealg/map_dag.py:37: in map_expr_dag
    result, = map_expr_dags(function, [expression], compress=compress)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/corealg/map_dag.py:84: in map_expr_dags
    r = handlers[v._ufl_typecode_](v)
$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/algorithms/apply_restrictions.py:78: in _missing_rule
    error("Missing rule for %s" % o._ufl_class_.__name__)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <ufl.log.Logger object at 0x7fd3eb7e34a8>, message = ('Missing rule for Constant',)

    def error(self, *message):
        "Write error message and raise an exception."
        self._log.error(*message)
>       raise self._exception_type(self._format_raw(*message))
E       ufl.log.UFLException: Missing rule for Constant

$HOME/fenicsx/2019-11-28-1eef790b8/petsc-2019-11-26-3055757620-3.12.2/lib/python3.7/site-packages/fenics_ufl-2019.2.0.dev0-py3.7.egg/ufl/log.py:172: UFLException
--------------------------------------------------- Captured log call ----------------------------------------------------
ERROR    UFL:log.py:171 Missing rule for Constant

I get similar failures later on in other tests, as well as when wrapping external classes with pybind11.

On the CentOS 7 machine everything runs fine instead.

After bisecting, I am reasonably sure that the issue was introduced when switching to C++17 in https://github.com/FEniCS/dolfinx/pull/641 but I am not fully able to debug any further due to limited knowledge of FFCX.

Is it possible that we need to enforce the std=c++17 flag on every FFCX compilation, as well as in the pybind11 layer of dolfinx?

michalhabera commented 4 years ago

Is your UFL up to date? That rule for ufl.Constant was added later.

UPDATE: Please, we changed the remote for UFL git code, check you have the correct git remote -v pointing to github.

garth-wells commented 4 years ago

The c++17 flag might be needed when compiling pybind11 but I think it's unlikely. See https://stackoverflow.com/questions/46746878/is-it-safe-to-link-c17-c14-and-c11-objects.

FFC-X doesn't compile any C++ code. It's plain C.

francesco-ballarin commented 4 years ago

Thanks Michal, indeed I had forgotten to change the remote of ufl on the affected machine (while I did change it on the other one). That solved the ufl issue.

I further realized that g++ on the affected machine had been updated by apt several times in the 8.X series. I had not been using the machine in a while, and compiled some of the dependencies with earlier versions. To be safe (even though it should have not made a difference, I was expecting), I recompiled the affected dependencies. To be even safer, I recompiled boost with c++17 instead of c++14.

There were probably many mistakes contributing (machine seldom used, wrong ufl, mix of different g++ versions). Apologies for having opened this on ffcx, not realizing that it compiles in C :)

I will close this