dealii / dealii

The development repository for the deal.II finite element library
https://www.dealii.org
Other
1.34k stars 741 forks source link

dealii induces unnecessary dependencies (like OpenCascade, sundials) on its users when users are built as shared objects #15714

Closed yurivict closed 1 year ago

yurivict commented 1 year ago

For example, the "hyperdeal" library.

When it is built as a shared library libhyperdeal.so it is linked with many or all OpenCascade and sundials libraries:

Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKBO.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKBO.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKBool.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKBool.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKBRep.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKBRep.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKernel.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKernel.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKFeat.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKFeat.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKFillet.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKFillet.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKG2d.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKG2d.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKG3d.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKG3d.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKGeomAlgo.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKGeomAlgo.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKGeomBase.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKGeomBase.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKHLR.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKHLR.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKIGES.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKIGES.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKMath.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKMath.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKMesh.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKMesh.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKOffset.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKOffset.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKPrim.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKPrim.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKShHealing.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKShHealing.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKSTEP.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKSTEP.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKSTEPAttr.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKSTEPAttr.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKSTEPBase.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKSTEPBase.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKSTEP209.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKSTEP209.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKSTL.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKSTL.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKTopAlgo.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKTopAlgo.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libTKXSBase.so.7.7 from cad/opencascade but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libTKXSBase.so:cad/opencascade
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libscalapack.so from math/scalapack but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libscalapack.so:math/scalapack
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libslepc.so.3.19 from math/slepc but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libslepc.so:math/slepc
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libpetsc.so.3.19 from science/PETSc but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libpetsc.so:science/PETSc
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/liblapack.so.3 from math/lapack but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=liblapack.so:math/lapack
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libblas.so.3 from math/blas but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libblas.so:math/blas
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libmetis.so.2 from math/metis but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libmetis.so:math/metis
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libX11.so.6 from x11/libX11 but it is not declared as a dependency
Warning: you need USE_XORG+=x11
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libmpifort.so.12 from net/mpich but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libmpifort.so:net/mpich
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/gcc12/libgfortran.so.5 from lang/gcc12 but it is not declared as a dependency
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/gcc12/libquadmath.so.0 from lang/gcc12 but it is not declared as a dependency
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libmpicxx.so.12 from net/mpich but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libmpicxx.so:net/mpich
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libmpi.so.12 from net/mpich but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libmpi.so:net/mpich
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libsundials_idas.so.5 from math/sundials but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libsundials_idas.so:math/sundials
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libsundials_arkode.so.5 from math/sundials but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libsundials_arkode.so:math/sundials
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libsundials_kinsol.so.6 from math/sundials but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libsundials_kinsol.so:math/sundials
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libsundials_nvecserial.so.6 from math/sundials but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libsundials_nvecserial.so:math/sundials
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/libsundials_nvecparallel.so.6 from math/sundials but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libsundials_nvecparallel.so:math/sundials
Error: /usr/local/lib/libhyperdeal.so is linked to /usr/local/lib/gcc12/libgcc_s.so.1 from lang/gcc12 but it is not declared as a dependency

It isn't necessary to link shared libraries with all dependency libraries. This is only necessary for static libraries. In case of shared libraries this only induces unnecessary inter-package dependencies.

hypedreal uses DEAL_II_xx macros like:

EAL_II_SETUP_TARGET(obj_grid)

which likely cause these redundant dependencies.

tamiko commented 1 year ago

@yurivict You will need to report issues with hyperdeal on the hyperdeal github https://github.com/hyperdeal/hyperdeal There is really not much we, as deal.II project, can do to help you here. (Short of that the hyperdeal developers and deal.II principal developers have a nonzero overlap).

But I want to respond to your comment in detail.

No, what you are saying is not correct.

For C++ dependencies in particular, as we have many, you really need the full transitive link interface. This is because header files of direct dependencies can and will result in new object code that might link to symbols of a dependent, indirect library. The consensus reached around 15 years ago is that not providing the library for linking on the command line is an error. So, depending on how strict your linker is you will encounter errors like

.../path/to/direct/dependency: error adding symbols: DSO missing from command line

Therefore, in order to link correctly, we really have to provide the full, transitive link interface. This is a decade old problem. You can find informative summaries here: [1,2].

I agree that in an ideal world we would not need to provide the full transitive link interface because we make sure that our user-side included header files do not introduce new symbol (and therefore) object dependencies. But frankly, this is not a concern for any of our many dependencies, and also not for us. And with a code base of about a 0.75 million user visible lines of code this is also not going to happen.

Just have a look at to what length the QT project had to go to make sanitized, API and ABI stable header files a possibility in Qt 4... And such API and ABI stability are goals that are very orthogonal to what scientific projects and libraries typically care about. (We are happy with our 99% API stability we manage to achieve for a given release.)

You can try to compile with -Wl,--as-needed in order to minimize the number of dependencies the library itself is linked against. But this will not allow you to ignore these library dependencies in the final ports package - in order to actually use deal.II afterwards you will need to install all direct dependencies as "-dev" package (in Debian speak), meaning with full headers and pkgconfig/cmake configuration. In particular:

When packaging deal.II I suggest to

[1] https://fedoraproject.org/wiki/UnderstandingDSOLinkChange [2] https://flameeyes.blog/2010/11/26/it-s-not-all-gold-that-shines-why-underlinking-is-a-bad-thing/?utm_source=blogdoteu&utm_medium=referral&utm_campaign=permanent [3] https://packages.debian.org/trixie/libdeal.ii-dev, https://packages.debian.org/source/trixie/deal.ii [4] https://salsa.debian.org/science-team/deal.ii/-/blob/master/debian/control (have a look at the "build dependencies" but also the regular dependencies for the "-dev" package. The binary itself only depends on the libraries it explicitly links against).