[lammps-users] Building Lammps with ScaFaCoS Package

Hello Everyone,

I am trying to build Lammps using CMake with the ScaFaCoS package using the option

-D DOWNLOAD_SCAFACOS=yes

and towards the end of the compilation, I get the following ScaFaCoS related errors during linking wherein it recommends using the “-fPIC” flag and recompile.
Check below for more details.

My OS is Ubuntu-18.04 LTS. The compilers that I am using are:

GNU Fortran (Ubuntu 4.8.5-4ubuntu8) 4.8.5, and,
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

The LAMMPS version is stable release from October 29 2020.

I am wondering where I should make the change in the Fortran compiler flags “FCFLAGS” variable to resolve this error.

Any guidance in this regard shall be very helpful. Thanks.

Warm regards,
Vaibhav.

[100%] Linking CXX executable lmp
/usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(fmm_cbindings.o): relocation R_X86_64_32S against .bss' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(fmm_tune.o): relocation R_X86_64_32 against symbol __mp_wrapper_MOD_mp_allnodes’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(mp_wrapper.o): relocation R_X86_64_32 against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(cfmm_tune.o): relocation R_X86_64_32 against symbol __mp_wrapper_MOD_mp_allnodes’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(fmm.o): relocation R_X86_64_32 against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(getcjpa.o): relocation R_X86_64_32 against .rodata’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(getneighbors.o): relocation R_X86_64_32S against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(pvlist.o): relocation R_X86_64_32 against .rodata’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(get_fmmec_0d.o): relocation R_X86_64_32S against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(get_fmmec_3d.o): relocation R_X86_64_32S against .rodata’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(get_fmmec_1d.o): relocation R_X86_64_32S against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(get_fmmec_2d.o): relocation R_X86_64_32S against .rodata’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(fmmmopnp00.o): relocation R_X86_64_32 against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(fmmgradtp00.o): relocation R_X86_64_32 against .rodata’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(fmmoopnp00.o): relocation R_X86_64_32 against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: scafacos_build-prefix/lib/libfcs_fmm.a(caladdr2.o): relocation R_X86_64_32 against .data’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(stop.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(close.o): relocation R_X86_64_32 against .rodata.str1.8’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(file_pos.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(open.o): relocation R_X86_64_32 against .rodata.str1.8’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(transfer.o): relocation R_X86_64_32S against .rodata.bswap_array' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(unit.o): relocation R_X86_64_32 against .rodata.str1.8’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(unix.o): relocation R_X86_64_32 against symbol __pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(write.o): relocation R_X86_64_32 against .rodata.limits.12228’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(string_intrinsics.o): relocation R_X86_64_32S against .bss.zero_length_string' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(compile_options.o): relocation R_X86_64_32 against .rodata.str1.1’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(environ.o): relocation R_X86_64_32S against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(error.o): relocation R_X86_64_32 against .rodata.str1.1’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(main.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(memory.o): relocation R_X86_64_32 against .rodata.str1.1’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(format.o): relocation R_X86_64_32S against .rodata.format_lex.part.3' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(list_read.o): relocation R_X86_64_32S against .rodata.eat_separator’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(read.o): relocation R_X86_64_32S against .rodata.masks.11891' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libgfortran.a(random.o): relocation R_X86_64_32 against symbol __pthread_key_create@@GLIBC_2.2.5’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libgfortran.a(backtrace.o): relocation R_X86_64_32 against `.rodata.str1.1’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
CMakeFiles/lmp.dir/build.make:132: recipe for target ‘lmp’ failed
make[2]: *** [lmp] Error 1
CMakeFiles/Makefile2:546: recipe for target ‘CMakeFiles/lmp.dir/all’ failed
make[1]: *** [CMakeFiles/lmp.dir/all] Error 2
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2

please tell us the entire cmake commands you are using.
or even better the shortest complete cmake commands to reproduce this.

thanks,
axel.

for the record, I just tried compiling with:

cmake -S cmake -B build-scafacos -DPKG_USER-SCAFACOS=on -DBUILD_SHARED_LIBS=on ; cmake --build build-scafacos --parallel 4

on my local fedora 32 machine and there is no problem linking. so the --with-pic flag is properly handed down to the ScaFaCoS configure script when LAMMPS is told to build shared libraries as well.

axel.

Hi Axel,

Thanks for your prompt response and Sorry for the delayed one from my side.

With help from your pointers, I was able to successfully install the ScaFaCoS package with lammps.

First to answer your question:
I was using the following commands to configure Lammps using the attached cmake preset files:

cmake -C …/cmake/presets/vt.cmake -C …/cmake/presets/vt_nolib.cmake …/cmake -DKokkos_ARCH_SKX=yes -DKokkos_ARCH_TURING75=yes -DKokkos_ENABLE_CUDA=yes -DKokkos_ENABLE_OPENMP=yes -DDOWNLOAD_SCAFACOS=yes -DCMAKE_CXX_COMPILER=/home/vthakore/src/gitLammps/lib/kokkos/bin/nvcc_wrapper -DBUILD_SHARED_LIBS=on -DCMAKE_Fortran_COMPILER=/usr/bin/gfortran-4.8 -DLAMMPS_SIZES=bigbig

There were a few things that were happening with my earlier attempt:

  1. Earlier, I was not using the flag -DBUILD_SHARED_LIBS=on.
  2. However, as it happens the -fPIC flag was being passed on correctly by Lammps.
  3. With what you shared and the error messages I was getting, I was able to decipher that the problem was not with Lammps but with the Fortran libraries.
  4. To compile the ScaFaCoS package with LAMMPS, I had installed the gfortran-4.8.5 compiler and that had also generated the associated static and dynamic libraries.
  5. However, these were probably not compatible with the installed gcc-version-7.5.0.
  6. To fix this, I then installed the libgfortran-7-dev: https://launchpad.net/ubuntu/focal/+package/libgfortran-7-dev
    Once I followed the above steps, the compilation worked without any problems for me.

Now, I have a question for you:
Is it possible to have the dependencies for the external libraries for the USER-packages listed on the LAMMPS website?
It would likely be of great service to several users like me…

Thanks.

Warm regards.

Vaibhav.

vt-gpu.cmake (1.07 KB)

vt_nolib.cmake (475 Bytes)

Hi Axel,

Thanks for your prompt response and Sorry for the delayed one from my side.

With help from your pointers, I was able to successfully install the ScaFaCoS package with lammps.

First to answer your question:
I was using the following commands to configure Lammps using the attached cmake preset files:

cmake -C …/cmake/presets/vt.cmake -C …/cmake/presets/vt_nolib.cmake …/cmake -DKokkos_ARCH_SKX=yes -DKokkos_ARCH_TURING75=yes -DKokkos_ENABLE_CUDA=yes -DKokkos_ENABLE_OPENMP=yes -DDOWNLOAD_SCAFACOS=yes -DCMAKE_CXX_COMPILER=/home/vthakore/src/gitLammps/lib/kokkos/bin/nvcc_wrapper -DBUILD_SHARED_LIBS=on -DCMAKE_Fortran_COMPILER=/usr/bin/gfortran-4.8 -DLAMMPS_SIZES=bigbig

There were a few things that were happening with my earlier attempt:

  1. Earlier, I was not using the flag -DBUILD_SHARED_LIBS=on.
  2. However, as it happens the -fPIC flag was being passed on correctly by Lammps.
  3. With what you shared and the error messages I was getting, I was able to decipher that the problem was not with Lammps but with the Fortran libraries.
  4. To compile the ScaFaCoS package with LAMMPS, I had installed the gfortran-4.8.5 compiler and that had also generated the associated static and dynamic libraries.
  5. However, these were probably not compatible with the installed gcc-version-7.5.0.
  6. To fix this, I then installed the libgfortran-7-dev: https://launchpad.net/ubuntu/focal/+package/libgfortran-7-dev
    Once I followed the above steps, the compilation worked without any problems for me.

Now, I have a question for you:
Is it possible to have the dependencies for the external libraries for the USER-packages listed on the LAMMPS website?

your problem was apparently due to misconfiguration of your machine. also, what you are reporting is very specific to your specific Linux distribution and the version of it. there is not other information we can provide than “do not misconfigure your machine”.

dependencies for LAMMPS itself are documented and CMake checks as much as possible.
However, dependencies for dependent libraries like ScaFaCoS is something that you have to ask the ScaFaCoS developers about.

What we do provide are tested container images:
https://cloud.sylabs.io/library/lammps/default/lammps_development

So if you install singularity you can compile and run LAMMPS in a suitable one of those containers (or use the definition files in the tools/singularity folder to build/customize the image yourself). those images are used in integration testing and thus are known to work and have all suitable libraries and tools installed.

axel.

“there is not other information we can provide than “do not misconfigure your machine”.”

Fair enough! ��

Thanks very much for sharing the information regarding singularity. It is very interesting, I will try learning more about this.

Warm regards,
Vaibhav.