code-saturne / code_saturne

code_saturne public mirror
https://www.code-saturne.org
GNU General Public License v2.0
215 stars 80 forks source link

7.3 does not build on ubuntu 22.04 / Debian 11 using install_saturne.py #100

Closed paspro closed 1 year ago

paspro commented 1 year ago

When trying to build code_saturne 7.3 on either ubuntu 22.0.4 or Debian 11 using the install_saturne.py script the process fails with a linker error which indicates that the scotch library is not specified for linking. Note that the third-party libraries HDF5, CGNS, MED and Scotch are downloaded, compiled and installed by this script without any errors.

The setup file used is the following:

download yes
debug no
prefix /opt
compC /usr/bin/gcc
mpiCompC /usr/bin/mpicc
compF /usr/bin/gfortran
compCxx /usr/bin/g++
mpiCompCxx /usr/bin/mpicxx
python /usr/bin/python3
disable_gui yes
disable_frontend no
salome no
hdf5    yes  yes  /opt/code_saturne_extras/HDF5
cgns    yes  yes  /opt/code_saturne_extras/CGNS
med     yes  yes  /opt/code_saturne_extras/MED
scotch  yes  yes  /opt/code_saturne_extras/SCOTCH

The error message is the following:

  Code_Saturne (code_saturne CFD tool)
   version: 7.3.0-patch
   url: None
   package: code_saturne
   source_dir: /opt/src/code_saturne-7.3
   install_dir: /opt/code_saturne-7.3.0-patch
   config_opts:  --disable-gui --with-hdf5=/opt/code_saturne_extras/HDF5 
--with-cgns=/opt/code_saturne_extras/CGNS 
--with-med=/opt/code_saturne_extras/MED 
--with-scotch=/opt/code_saturne_extras/SCOTCH 
PYTHON=/usr/bin/python3 --disable-static
/usr/bin/mpicc -c -DHAVE_CONFIG_H -I. -I/opt/src/code_saturne-7.3/src/apps -I../.. -I/opt/src/code_saturne-7.3/src/atmo -I/opt/src/code_saturne-7.3/src/alge -I/opt/src/code_saturne-7.3/src/base -I/opt/src/code_saturne-7.3/src/bft -I/opt/src/code_saturne-7.3/src/cdo -I/opt/src/code_saturne-7.3/src/cogz -I/opt/src/code_saturne-7.3/src/comb -I/opt/src/code_saturne-7.3/src/ctwr -I/opt/src/code_saturne-7.3/src/darc -I/opt/src/code_saturne-7.3/src/elec -I/opt/src/code_saturne-7.3/src/fvm -I/opt/src/code_saturne-7.3/src/gui -I/opt/src/code_saturne-7.3/src/lagr -I/opt/src/code_saturne-7.3/src/mesh -I/opt/src/code_saturne-7.3/src/turb -I"/opt/src/code_saturne-7.3/libple/src" -I"../../libple" -DOMPI_SKIP_MPICXX    -funroll-loops -O2 -Wuninitialized -fexcess-precision=fast -fPIC -DPIC -funsigned-char -W -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wunused -Wfloat-equal -Werror=implicit-function-declaration -Wmisleading-indentation -Wduplicated-cond -fdiagnostics-color=auto -Werror=format-security  -fopenmp /opt/src/code_saturne-7.3/src/apps/cs_solver.c
rm -f libcs_solver.so ; \
/usr/bin/python3 -B /opt/src/code_saturne-7.3/build-aux/cs_link_library.py -o libcs_solver.so --echo --linker /usr/bin/mpicxx --version 7.3 -shared -fPIC -DPIC cs_solver.o -O -Wl,-export-dynamic -fopenmp  -L. -lsaturne-7.3   -L"../../libple/src" -lple     -L/opt/code_saturne_extras/CGNS/lib -Wl,-rpath -Wl,/opt/code_saturne_extras/CGNS/lib -lcgns -L/opt/code_saturne_extras/MED/lib -lmedC -Wl,-rpath -Wl,/opt/code_saturne_extras/MED/lib -L/opt/code_saturne_extras/HDF5/lib -lhdf5  -Wl,-rpath -Wl,/opt/code_saturne_extras/HDF5/lib     -L/opt/code_saturne_extras/SCOTCH/lib -lptscotch -lscotch -lm -Wl,-rpath -Wl,/opt/code_saturne_extras/SCOTCH/lib              -L/usr/lib/gcc/x86_64-linux-gnu/11 -L/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lgfortran -lm -lquadmath -lz   -ldl

/usr/bin/mpicxx -o libcs_solver-7.3.so -Wl,-soname -Wl,libcs_solver-7.3.so cs_solver.o -shared -fPIC -DPIC -O -Wl,-export-dynamic -fopenmp -L. -lsaturne-7.3 -L../../libple/src -lple -L/opt/code_saturne_extras/CGNS/lib -Wl,-rpath -Wl,/opt/code_saturne_extras/CGNS/lib -lcgns -L/opt/code_saturne_extras/MED/lib -lmedC -Wl,-rpath -Wl,/opt/code_saturne_extras/MED/lib -L/opt/code_saturne_extras/HDF5/lib -lhdf5 -Wl,-rpath -Wl,/opt/code_saturne_extras/HDF5/lib -L/opt/code_saturne_extras/SCOTCH/lib -lm -Wl,-rpath -Wl,/opt/code_saturne_extras/SCOTCH/lib -L/usr/lib/gcc/x86_64-linux-gnu/11 -L/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lgfortran -lm -lquadmath -lz -ldl

PYTHONPATH=/opt/src/code_saturne-7.3/python/code_saturne/base \
CS_TOP_BUILDDIR=../.. \
/usr/bin/python3 -B /opt/src/code_saturne-7.3/build-aux/cs_compile_build.py \
libcs_solver.so
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_stratExit'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphCheck'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_dgraphBuild'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_dgraphCheck'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_stratInit'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphBuild'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphPartFixed'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphPart'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphOrderComputeList'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_dgraphPart'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_dgraphInit'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphOrderExit'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_dgraphSave'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphExit'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_dgraphExit'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphOrderInit'
/usr/bin/ld: /opt/src/code_saturne-7.3.build/src/apps/libsaturne.so: undefined reference to `SCOTCH_graphInit'
collect2: error: ld returned 1 exit status

Note that the line:

/usr/bin/mpicxx -o libcs_solver-7.3.so -Wl,-soname -Wl,libcs_solver-7.3.so cs_solver.o 
-shared -fPIC -DPIC -O -Wl,-export-dynamic -fopenmp -L. -lsaturne-7.3 
-L../../libple/src -lple 
-L/opt/code_saturne_extras/CGNS/lib -Wl,-rpath -Wl,/opt/code_saturne_extras/CGNS/lib -lcgns 
-L/opt/code_saturne_extras/MED/lib -lmedC -Wl,-rpath -Wl,/opt/code_saturne_extras/MED/lib 
-L/opt/code_saturne_extras/HDF5/lib -lhdf5 -Wl,-rpath -Wl,/opt/code_saturne_extras/HDF5/lib 
-L/opt/code_saturne_extras/SCOTCH/lib -lm -Wl,-rpath -Wl,/opt/code_saturne_extras/SCOTCH/lib
-L/usr/lib/gcc/x86_64-linux-gnu/11 
-L/lib/x86_64-linux-gnu 
-L/usr/lib/x86_64-linux-gnu 
-lgfortran -lm -lquadmath -lz -ldl

does not contain the required -lscotch -lptscotch command line options.

YvanFournier commented 1 year ago

Hello,

Yes, the lines relative to scotch/ptscotch are explicitely excluded in build_aux/cs_link_library.py (search for "scotch").

This is a quick workaround on Linux to allow linking with a static-onlyn scotch (because scotch 7.0 alllows CMake-based build, but that option does not include shared libraries yet). A cleaner solution would be to test for each detected library whether is is a .a archive or .so library (is it the same on Mac) ? That would involve more tests in .am files, and at some point, rewriting all of this in python would allow better code factorization, but might be a significant project.

A solution here would simply be to replace:

    for o in other:
        if o in ("-lptscotch", "-lscotch"):
            continue
        if o[:2] == '-R':
            cmd += ["-Wl,-rpath", "-Wl,"+o[2:]]
        else:
            cmd.append(o)

With:

    exclude_list =  ("-lptscotch", "-lscotch")
    import platform
    if platform.system() == 'Darwin':
        exclude_list = []
    for o in other:
        if o in exclude_list:
            continue
        if o[:2] == '-R':
            cmd += ["-Wl,-rpath", "-Wl,"+o[2:]]
        else:
            cmd.append(o)

Can you try that ?

paspro commented 1 year ago

This problem is not on macOS but on Ubuntu 22.0.4 and Debian 11.

YvanFournier commented 1 year ago

Sorry, I confused this with the other bug report.

In this case, we'll need more advanced tests, but this is not the priority in the coming weeks.

I'm not surprised that the linker on Ubuntu is picky (it always seems to have strict + stupid settings, since this issue has never been solved: https://bugs.launchpad.net/ubuntu/+source/code-saturne/+bug/1672585.

I'm more surprised on Debian 11, since I don't think I have the issue on Arch Linux (I'll test again). I'll have access to a Scibian-11 based system soon, so I can try that.

In the meantime, I woulnd't expect that you will have much of a performance difference not using PT-Scotch at all and using the built-in partitioner instead, which will work around this issue (PT-Scotch becomes really interesting at higher node and core counts).

YvanFournier commented 1 year ago

An alternative approach might be to add --warn-unresolved-symbols to the linker flags.

paspro commented 1 year ago

An alternative approach might be to add --warn-unresolved-symbols to the linker flags.

I tried this option but had no results.

YvanFournier commented 1 year ago

Now that PT-Scotch 7.0.3 has better CMake build options, we use an empty "exclude_list" by default, so the issue should be solved (assuming your build of PT-Scotch uses shared libraries).

Commits ea3d91f3 on master, 4482f38b on v8.0, 01f8711b on v7.3.