llnl / llnl/blt

-lmpi creeping in when using new blt mpi imported targets

Open
#489 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
296
Forks
66
Avg merge
1h 3m
Merged PRs (30d)
1

Description

symptom:

```
/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/bin/../libexec/gcc/x86_64-redhat-linux/8/ld: cannot find -lmpi
collect2: error: ld returned 1 exit status
```
or, in other cases, `lmpi` silently links to system mpi if it exists - causing MPI hangs b/c multiple MPIs are in play.

I tried to export blt mpi targets using:

```
set(BLT_TPL_DEPS_EXPORTS)
# cmake < 3.15, we use BLT's mpi target and need to export
# it for use downstream
if( ${CMAKE_VERSION} VERSION_LESS "3.15.0" )
blt_list_append(TO BLT_TPL_DEPS_EXPORTS ELEMENTS mpi IF ENABLE_MPI)
endif()

foreach(dep ${BLT_TPL_DEPS_EXPORTS})
# If the target is EXPORTABLE, add it to the export set
get_target_property(_is_imported ${dep} IMPORTED)
if(NOT ${_is_imported})
install(TARGETS ${dep}
EXPORT conduit
DESTINATION lib)
# Namespace target to avoid conflicts
set_target_properties(${dep} PROPERTIES EXPORT_NAME conduit::blt_${dep})
endif()
endforeach()
```

I'll admit there could be a bug in that logic, but reverting to older BLT fixed the issue for me.

The fact that unbound `mpi` can sneak in if you use new imported targets (if you don't re-export, or if you try to and maybe fail like me) is confusing. Especially in the case that it causes multiple mpis to be linked.

In this case the downstream lib was using an older BLT, so that might be a factor.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the linker failure with the new BLT MPI imported targets and inspect the shown BLT_TPL_DEPS_EXPORTS export logic in the downstream library using an older BLT. Done means downstream linking resolves the intended MPI target without an unbound -lmpi or accidental system MPI.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.