Incorrect MPI configuration
- Dominant language
- C++
- Stars
- 42
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
On my system, the build configuration could not detect MPI installation automatically:
```bash
/usr/bin/mpic++ --showme
g++ -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/include -pthread -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi
```
Thus, I inspected the provided config files and the CMakeLists.txt file to figure out the configuration:
```bash
set(CMAKE_CXX_FLAGS "-I/usr/lib/x86_64-linux-gnu/openmpi/include -pthread -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/" CACHE STRING ""
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi" CACHE STRING "")
```
However, this generates incorrect linking step:
```bash
/usr/bin/c++ -I/usr/lib/x86_64-linux-gnu/openmpi/include -pthread -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ -Wall -Wextra -O3 -ffast-math -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi CMakeFiles/kripke.exe.dir/src/kripke.cpp.o -o bin/kripke.exe lib/libRAJA.a lib/libkripke.a lib/libRAJA.a -ldl
```
Since linking flags are included before static libraries, the paths are never resolved. The correct approach would be to paste additional linking options at the end of this command.
Furthermore, wouldn't it be simpler to use the default CMake module to provide MPI paths?
```cmake
find_package(MPI REQUIRED)
include_directories(${MPI_C_INCLUDE_PATH})
SET(MPI_INCLUDE_PATH ${MPI_C_INCLUDE_PATH})
SET(MPI_LINK_FLAGS ${MPI_C_LIBRARIES})
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the repository's CMakeLists.txt and the provided configuration files, then reproduce the MPI build and inspect the generated linker command. Verify how MPI include and link settings are detected and ordered relative to the static libraries. Done means the project detects the installed MPI configuration and links successfully without manual flags.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100