Before a complete re-installation of Julia in early December, MPI.jl worked for me. Now I cannot install the MPI.jl package anymore - it fails building:
julia> import Pkg; Pkg.add("MPI")
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Resolving package versions...
Updating `~/.julia/environments/v1.0/Project.toml`
[da04e1cc] + MPI v0.7.2
Updating `~/.julia/environments/v1.0/Manifest.toml`
[da04e1cc] + MPI v0.7.2
julia> Pkg.build("MPI")
Building MPI → `~/.julia/packages/MPI/U5ujD/deps/build.log`
┌ Error: Error building `MPI`:
│ -- The Fortran compiler identification is Cray 8.7
│ -- The C compiler identification is Cray 8.7
│ -- Cray Programming Environment 2.5.15 Fortran
│ -- Check for working Fortran compiler: /opt/cray/pe/craype/2.5.15/bin/ftn
│ -- Check for working Fortran compiler: /opt/cray/pe/craype/2.5.15/bin/ftn -- works
│ -- Detecting Fortran compiler ABI info
│ -- Detecting Fortran compiler ABI info - done
│ -- Checking whether /opt/cray/pe/craype/2.5.15/bin/ftn supports Fortran 90
│ -- Checking whether /opt/cray/pe/craype/2.5.15/bin/ftn supports Fortran 90 -- yes
│ -- Cray Programming Environment 2.5.15 C
│ -- Check for working C compiler: /opt/cray/pe/craype/2.5.15/bin/cc
│ -- Check for working C compiler: /opt/cray/pe/craype/2.5.15/bin/cc -- works
│ -- Detecting C compiler ABI info
│ -- Detecting C compiler ABI info - done
│ -- Found Git: /usr/bin/git (found version "2.12.3")
│ -- Found MPI_C: /opt/cray/pe/craype/2.5.15/bin/cc
│ -- Found MPI_Fortran: /opt/cray/pe/craype/2.5.15/bin/ftn
│ -- Detecting Fortran/C Interface
│ -- Detecting Fortran/C Interface - Found GLOBAL but not MODULE mangling
│ -- Looking for MPI_Comm_c2f
│ -- Looking for MPI_Comm_c2f - not found
│ -- Configuring done
│ -- Generating done
│ -- Build files have been written to: /users/omlins/.julia/packages/MPI/U5ujD/deps/build
│ Scanning dependencies of target gen_constants
│ [ 11%] Building Fortran object CMakeFiles/gen_constants.dir/gen_constants.f90.o
│ [ 22%] Linking Fortran executable gen_constants
│ [ 22%] Built target gen_constants
│ Scanning dependencies of target gen_functions
│ [ 33%] Building C object CMakeFiles/gen_functions.dir/gen_functions.c.o
│ [ 44%] Linking C executable gen_functions
│ [ 44%] Built target gen_functions
│ Scanning dependencies of target mpijl
│ [ 55%] Generating compile-time.jl
│ [ 55%] Built target mpijl
│ Scanning dependencies of target mpijl-build
│ [ 66%] Generating mpi-build.jl
│ [ 66%] Built target mpijl-build
│ Scanning dependencies of target juliampi
│ [ 77%] Building C object CMakeFiles/juliampi.dir/juliampi.c.o
│ [ 88%] Building Fortran object CMakeFiles/juliampi.dir/test_mpi.f90.o
│ [100%] Linking Fortran shared library libjuliampi.so
│ /opt/cray/pe/cce/8.7.3/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld: CMakeFiles/juliampi.dir/juliampi.c.o: relocation R_X86_64_32 against symbol `finalize_atexit' can not be used when making a shared object; recompile with -fPIC
│ /opt/cray/pe/cce/8.7.3/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld: final link failed: Nonrepresentable section on output
│ /usr/bin/X11/sha1sum: libjuliampi.so: No such file or directory
│ CMakeFiles/juliampi.dir/build.make:120: recipe for target 'libjuliampi.so' failed
│ make[2]: *** [libjuliampi.so] Error 1
│ CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/juliampi.dir/all' failed
│ make[1]: *** [CMakeFiles/juliampi.dir/all] Error 2
│ Makefile:149: recipe for target 'all' failed
│ make: *** [all] Error 2
│ [ Info: Attempting to create directory /users/omlins/.julia/packages/MPI/U5ujD/deps/build
│ [ Info: Changing directory to /users/omlins/.julia/packages/MPI/U5ujD/deps/build
│ ERROR: LoadError: failed process: Process(`make`, ProcessExited(2)) [2]
│ Stacktrace:
│ [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
│ [2] pipeline_error at ./process.jl:705 [inlined]
│ [3] #run#504(::Bool, ::Function, ::Cmd) at ./process.jl:663
│ [4] run(::Cmd) at ./process.jl:661
│ [5] macro expansion at ./logging.jl:306 [inlined]
│ [6] run(::BinDeps.SynchronousStepCollection) at /users/omlins/.julia/packages/BinDeps/ZEval/src/BinDeps.jl:518
│ [7] macro expansion at ./logging.jl:306 [inlined]
│ [8] run(::BinDeps.SynchronousStepCollection) at /users/omlins/.julia/packages/BinDeps/ZEval/src/BinDeps.jl:518
│ [9] macro expansion at ./logging.jl:306 [inlined]
│ [10] run(::BinDeps.SynchronousStepCollection) at /users/omlins/.julia/packages/BinDeps/ZEval/src/BinDeps.jl:518
│ [11] satisfy!(::BinDeps.LibraryDependency, ::Array{DataType,1}) at /users/omlins/.julia/packages/BinDeps/ZEval/src/dependencies.jl:944
│ [12] satisfy!(::BinDeps.LibraryDependency) at /users/omlins/.julia/packages/BinDeps/ZEval/src/dependencies.jl:922
│ [13] top-level scope at /users/omlins/.julia/packages/BinDeps/ZEval/src/dependencies.jl:977
│ [14] include at ./boot.jl:317 [inlined]
│ [15] include_relative(::Module, ::String) at ./loading.jl:1044
│ [16] include(::Module, ::String) at ./sysimg.jl:29
│ [17] include(::String) at ./client.jl:392
│ [18] top-level scope at none:0
│ in expression starting at /users/omlins/.julia/packages/MPI/U5ujD/deps/build.jl:54
└ @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1097
The error message suggests to recompile with -fPIC. How can I make Julia do that?
Or do you believe the problem is elsewhere?
In any case, it should not be a big issue as MPI.jl worked before…
What version of CMake are you using? It looks like there was a bug that was fixed in version 3.11. According to that thread, setting CRAYPE_LINK_TYPE=dynamic and adding -fPIC to CMAKE_C_FLAGS is a workaround. You may also need to add the flag to CMAKE_Fortran_FLAGS because there is a Fortran file in there too.
@JaredCrean2: The default CMake on the system, version 3.5.2, was used. I tried now also with the newest version available, version 3.8.1. Yet, it still fails. Note that I had always set CRAYPE_LINK_TYPE=dynamic (without that, it had failed much earlier in the build).
How do I properly modify the CMAKE flags that Julia is going to use for the build when calling Pkg.build("MPI")?
The -fPIC flag is definitely not getting to the compiler (both C and Fortran), which is weird because the CMakeLists.txt definitely uses CMAKE_C_FLAGS. Do you have GNU compilers available on your machine. If so, try doing module swap PrgEvn-cray PrgEnv-gnu (or similar depending on the module names). I want to see if this works with GNU compilers to see if this really is a bug with CMake and the Cray compilers.
Yes, if I swap to PrgEnv-gnu, then it works. See the following (done after a fresh login):
> export CRAYPE_LINK_TYPE=dynamic
> module switch PrgEnv-cray/6.0.4 PrgEnv-gnu
> julia
julia> import Pkg; Pkg.build("MPI")
Building MPI → `~/.julia/packages/MPI/U5ujD/deps/build.log`
julia>
> cat ~/.julia/packages/MPI/U5ujD/deps/build.log
-- The Fortran compiler identification is GNU 6.2.0
-- The C compiler identification is GNU 6.2.0
-- Cray Programming Environment 2.5.15 Fortran
-- Check for working Fortran compiler: /opt/cray/pe/craype/2.5.15/bin/ftn
-- Check for working Fortran compiler: /opt/cray/pe/craype/2.5.15/bin/ftn -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /opt/cray/pe/craype/2.5.15/bin/ftn supports Fortran 90
-- Checking whether /opt/cray/pe/craype/2.5.15/bin/ftn supports Fortran 90 -- yes
-- Cray Programming Environment 2.5.15 C
-- Check for working C compiler: /opt/cray/pe/craype/2.5.15/bin/cc
-- Check for working C compiler: /opt/cray/pe/craype/2.5.15/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: /usr/bin/git (found version "2.12.3")
-- Found MPI_C: /opt/cray/pe/craype/2.5.15/bin/cc
-- Found MPI_Fortran: /opt/cray/pe/craype/2.5.15/bin/ftn
-- Detecting Fortran/C Interface
-- Detecting Fortran/C Interface - Found GLOBAL and MODULE mangling
-- Looking for MPI_Comm_c2f
-- Looking for MPI_Comm_c2f - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /users/omlins/.julia/packages/MPI/U5ujD/deps/build
Scanning dependencies of target gen_constants
[ 11%] Building Fortran object CMakeFiles/gen_constants.dir/gen_constants.f90.o
[ 22%] Linking Fortran executable gen_constants
[ 22%] Built target gen_constants
Scanning dependencies of target gen_functions
[ 33%] Building C object CMakeFiles/gen_functions.dir/gen_functions.c.o
[ 44%] Linking C executable gen_functions
[ 44%] Built target gen_functions
Scanning dependencies of target mpijl-build
[ 55%] Generating mpi-build.jl
[ 55%] Built target mpijl-build
Scanning dependencies of target mpijl
[ 66%] Generating compile-time.jl
[ 66%] Built target mpijl
Scanning dependencies of target juliampi
[ 77%] Building C object CMakeFiles/juliampi.dir/juliampi.c.o
[ 88%] Building Fortran object CMakeFiles/juliampi.dir/test_mpi.f90.o
[100%] Linking Fortran shared library libjuliampi.so
[100%] Built target juliampi
[ 22%] Built target gen_constants
[ 44%] Built target gen_functions
[ 55%] Built target mpijl-build
[ 66%] Built target mpijl
[100%] Built target juliampi
Install the project...
-- Install configuration: ""
-- Installing: /users/omlins/.julia/packages/MPI/U5ujD/deps/src/./compile-time.jl
-- Installing: /users/omlins/.julia/packages/MPI/U5ujD/deps/usr/lib/libjuliampi.so
[ Info: Attempting to create directory /users/omlins/.julia/packages/MPI/U5ujD/deps/build
[ Info: Changing directory to /users/omlins/.julia/packages/MPI/U5ujD/deps/build
It must be a problem with CMake and the Cray compilers. You can try building a newer version of CMake yourself (something newer than 3.11) and see if that works with the Cray compilers.
The long answer is MPI.jl uses the Fortran MPI interface, but many MPI-aware libraries use the C interface. The MPI standard requires that either a C and Fortran communicator must be the same or the MPI library must provide functions to convert one to the other. The configure phase checks to see if the C to Fortran conversion function exists, and uses that information to define the proper conversion function wrappers in Julia.