dolfin.pc Libs are parsed wrong whit a --start-group argument

Bug #966100 reported by Jens
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DOLFIN
Fix Released
Low
Johannes Ring

Bug Description

When there's a --start-group argument in the DOLFIN_TARGET_LINK_LIBRARIES the creation of the PKG_LINKFLAGS goes wrong in dolfin/CMakeLists.txt

especially the regex used here seems to be flawed:

# Convert libraries to -L<libdir> -l<lib> form
foreach(_lib ${DOLFIN_TARGET_LINK_LIBRARIES})
  string(REGEX REPLACE "(.?:?/[^ ]*)/lib([^ ]*)\\.(a|so|dylib|dll)" "-L\\1 -l\\2"
    _linkflags
    "${_lib}"
    )

  # Only add libraries that matches the form -L<libdir> -l<lib>
  if ("${_linkflags}" MATCHES "-L.+ -l.+")
    set(PKG_LINKFLAGS "${PKG_LINKFLAGS} ${_linkflags}")
  endif()
endforeach()

I printed out DOLFIN_TARGET_LINK_LIBRARIES and PKG_LINKFLAGS just after this piece of code was run and got these results:
Note the "-L " : the space is after the -L instead of before it, making things fail when trying to use these flags when compiling with instant.

 DOLFIN_TARGET_LINK_LIBRARIES:
  /usr/lib64/libxml2.so;/tmp/software/Armadillo/2.4.4-ictce-4.0.6/lib/libarmadillo.so;optimized;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_filesystem.so;debug;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_filesystem.so;optimized;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_program_options.so;debug;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_program_options.so;optimized;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_system.so;debug;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_system.so;optimized;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_thread.so;debug;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_thread.so;optimized;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_iostreams.so;debug;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_iostreams.so;optimized;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_math_tr1.so;debug;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_math_tr1.so;optimized;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_mpi.so;debug;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_mpi.so;optimized;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_serialization.so;debug;/tmp/software/Boost/1.49.0-ictce-4.0.6/lib/libboost_serialization.so;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/UMFPACK/lib/libumfpack.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/UMFPACK/lib/libamd.a;-Wl,--start-group
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_intel_lp64.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_sequential.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_core.a
  -Wl,--end-group;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CHOLMOD/lib/libcholmod.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/UMFPACK/lib/libamd.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CAMD/lib/libcamd.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/COLAMD/lib/libcolamd.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CCOLAMD/lib/libccolamd.a;-Wl,--start-group
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_intel_lp64.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_sequential.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_core.a
  -Wl,--end-group;/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib/libparmetis.a;/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib/libmetis.a;-Wl,--start-group
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_intel_lp64.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_sequential.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_core.a
  -Wl,--end-group;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CHOLMOD/lib/libcholmod.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/UMFPACK/lib/libamd.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CAMD/lib/libcamd.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/COLAMD/lib/libcolamd.a;/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CCOLAMD/lib/libccolamd.a;-Wl,--start-group
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_intel_lp64.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_sequential.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_core.a
  -Wl,--end-group;/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib/libparmetis.a;/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib/libmetis.a;-Wl,--start-group
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_intel_lp64.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_sequential.a
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_core.a
  -Wl,--end-group;/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib/libparmetis.a;/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib/libmetis.a;/usr/lib64/libz.so;/apps/gent/gengar/harpertown/software/impi/4.0.2.003/lib64/libmpi.so

  PKG_LINKFLAGS: -L/apps/gent/gengar/harpertown/software/impi/4.0.2.003/lib64
  -lmpi -L/usr/lib64 -lz -L/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib
  -lmetis -L/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib -lparmetis
  -Wl,--start-group-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_intel_lp64-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_sequential-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_core -Wl,--end-group -L/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib
  -lmetis -L/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib -lparmetis
  -Wl,--start-group-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_intel_lp64-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_sequential-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_core -Wl,--end-group
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CCOLAMD/lib
  -lccolamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/COLAMD/lib
  -lcolamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CAMD/lib -lcamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/UMFPACK/lib
  -lamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CHOLMOD/lib
  -lcholmod -Wl,--start-group-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_intel_lp64-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_sequential-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_core -Wl,--end-group -L/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib
  -lmetis -L/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib -lparmetis
  -Wl,--start-group-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_intel_lp64-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_sequential-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_core -Wl,--end-group
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CCOLAMD/lib
  -lccolamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/COLAMD/lib
  -lcolamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CAMD/lib -lcamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/UMFPACK/lib
  -lamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/CHOLMOD/lib
  -lcholmod -Wl,--start-group-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_intel_lp64-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_sequential-L
  /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -lmkl_core -Wl,--end-group
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/UMFPACK/lib
  -lamd
  -L/tmp/software/SuiteSparse/3.7.0-ictce-4.0.6-withparmetis/UMFPACK/lib
  -lumfpack -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib
  -lboost_serialization -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib
  -lboost_serialization -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib
  -lboost_mpi -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_mpi
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_math_tr1
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_math_tr1
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_iostreams
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_iostreams
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_thread
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_thread
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_system
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_system
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_program_options
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_program_options
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_filesystem
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib -lboost_filesystem
  -L/tmp/software/Armadillo/2.4.4-ictce-4.0.6/lib -larmadillo -L/usr/lib64
  -lxml2
  -L/apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64
  -L/apps/gent/gengar/harpertown/software/Python/2.7.2-ictce-4.0.6/lib
  -L/tmp/software/Boost/1.49.0-ictce-4.0.6/lib
  -L/tmp/software/UFC/2.0.5-ictce-4.0.6/lib -L/tmp/software/FFC/1.0.0/lib
  -L/tmp/software/FIAT/1.0.0/lib -L/tmp/software/Instant/1.0.0/lib
  -L/tmp/software/Viper/1.0.0/lib -L/tmp/software/UFL/1.0.0/lib
  -L/tmp/software/SCOTCH/5.1.12b_esmumps-ictce-4.0.6/lib
  -L/tmp/software/Armadillo/2.4.4-ictce-4.0.6/lib
  -L/tmp/software/ParMETIS/4.0.2-ictce-4.0.6/lib

Revision history for this message
Johannes Ring (johannr) wrote :

Do you know where the -Wl,--start-group flag comes from. Why is it added to DOLFIN_TARGET_LINK_LIBRARIES?

Revision history for this message
Jens (jens.timmerman) wrote :

Yes, I'm explicitly setting them.

I'm running

cmake -DCMAKE_INSTALL_PREFIX=/tmp/software/DOLFIN/1.0.0-ictce-4.0.6 . -DBoost_DIR=$SOFTROOTBOOST -DBOOST_INCLUDEDIR=$SOFTROOTBOOST/include -DBoost_DEBUG=ON -DBOOST_ROOT=$SOFTROOTBOOST -DUFC_DIR=$SOFTROOTUFC -DARMADILLO_DIR:PATH=$SOFTROOTARMADILLO -DMPI_COMPILER="$MPICC" -DMPI_LIBRARY="$SOFTROOTIMPI/lib64/libmpi.so" -DMPI_INCLUDE_PATH="$SOFTROOTIMPI/include64" -DPYTHON_LIBRARY=$SOFTROOTPYTHON/lib/libpython2.7.so -DPYTHON_INCLUDE_PATH=$SOFTROOTPYTHON/include/python2.7 -DPYTHON_LIBRARIES=$SOFTROOTPYTHON/lib/libpython2.7.so -DMPI_C_COMPILER="$MPICC" -DMPI_CXX_COMPILER="$MPICXX" -DUMFPACK_DIR="$SOFTROOTSUITESPARSE/UMFPACK" -DAMD_DIR="$SOFTROOTSUITESPARSE/UMFPACK" -DCHOLMOD_DIR="$SOFTROOTSUITESPARSE/CHOLMOD" -DUFCONFIG_DIR="$SOFTROOTSUITESPARSE/UFconfig" -DCAMD_LIBRARY:PATH="$SOFTROOTSUITESPARSE/CAMD/lib/libcamd.a" -DCCOLAMD_LIBRARY:PATH="$SOFTROOTSUITESPARSE/CCOLAMD/lib/libccolamd.a" -DCOLAMD_LIBRARY:PATH="$SOFTROOTSUITESPARSE/COLAMD/lib/libcolamd.a" -DBLAS_LIBRARIES:PATH="$LIBBLAS" -DLAPACK_LIBRARIES:PATH="$LIBLAPACK" -DPARMETIS_DIR="$SOFTROOTPARMETIS" -DSCOTCH_DIR="$SOFTROOTSCOTCH" -DOpenMP_CXX_FLAGS="-openmp" -DOpenMP_C_FLAGS="-openmp"

with for example
LIBBLAS set to " -Wl,--start-group /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_intel_lp64.a /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_sequential.a /apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_core.a -Wl,--end-group"

Revision history for this message
Jens (jens.timmerman) wrote :
Revision history for this message
Jens (jens.timmerman) wrote :

When debugging this I also noticed pkg-utils doesn't like the -Wl,--start-group either.

So I changed my LIBBLAS to -Wl,--start-group,/apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_intel_lp64.a,/apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_sequential.a,/apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_core.a,--end-group

this makes pkg-utils work as expected, however, I can't get cmake to create the correct dolfin.pc yet

Revision history for this message
Jens (jens.timmerman) wrote :

Using this (proof of concept) patch I can get instant to work after building everything:

- # Only add libraries that matches the form -L<libdir> -l<lib>
- if ("${_linkflags}" MATCHES "-L.+ -l.+")
- set(PKG_LINKFLAGS "${_linkflags} ${PKG_LINKFLAGS}")
+ #also add -Wl,x,x,x,x directives
+ if ("${_lib}" MATCHES "-Wl,[^ ]*")
+ set(PKG_LINKFLAGS "${_lib} ${PKG_LINKFLAGS}")
+ else()
+ # Only add libraries that matches the form -L<libdir> -l<lib>
+ if ("${_linkflags}" MATCHES "-L.+ -l.+")
+ set(PKG_LINKFLAGS "${_linkflags} ${PKG_LINKFLAGS}")
+ endif()
   endif()
 endforeach()

Revision history for this message
Jens (jens.timmerman) wrote :
Revision history for this message
Johannes Ring (johannr) wrote :

Does it work if you try

  -DBLAS_LIBRARIES="/apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_intel_lp64.a;/apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_sequential.a;/apps/gent/gengar/harpertown/software/imkl/10.3.6.233/mkl/lib/intel64/libmkl_core.a"

?

Revision history for this message
Jens (jens.timmerman) wrote :

No, this is not possible since there are unavoidable circular references between two or more archives.

Revision history for this message
Johannes Ring (johannr) wrote :

OK.

Thanks for the patch. I have pushed a slightly modified version of it now.

Changed in dolfin:
status: New → Fix Committed
assignee: nobody → Johannes Ring (johannr)
milestone: none → 1.0.1
importance: Undecided → Low
Changed in dolfin:
status: Fix Committed → Fix Released
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.