blt icon indicating copy to clipboard operation
blt copied to clipboard

-lmpi creeping in when using new blt mpi imported targets

Open cyrush opened this issue 4 years ago • 2 comments

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.

cyrush avatar Apr 28 '21 18:04 cyrush

I'm sure you know this but CMake will add any target it doesn't know as a system library in hopes that it will find it.

target_link_library(foo some_unknown_target)

ends up as -lsome_unknown_target.

If you would like some help tracking this down, I can make myself available.

white238 avatar Apr 28 '21 18:04 white238

yep, it could still be a straympi somewhere.

I did review for quite a bit and tried to change any mpi related depends on in conduit's cmake to use the name conduit_blt_mpi_deps, I thought I found them all - but is pretty hard to search for just mpi (lots of false positives)

cyrush avatar Apr 28 '21 18:04 cyrush