---
# System prepended metadata

title: Inject host site versions of l

---

# Inject site host libfabric and UCX



## Injection of amazon EFA with patchelf



```

# Force libmpi to resolve unavailable libraries to the system versions

cp /opt/amazon/openmpi/lib64/libmpi.so.40 .

patchelf --replace-needed libhwloc.so.5 /lib64/libhwloc.so.5 libmpi.so.40

patchelf --replace-needed libevent_core-2.0.so.5 /lib64/libevent_core-2.0.so.5 libmpi.so.40

patchelf --replace-needed libevent_pthreads-2.0.so.5 /lib64/libevent_pthreads-2.0.so.5 libmpi.so.40

# Do the same for libfabric (I'm forcing use of system `libefa` here) 

cp /opt/amazon/efa/lib64/libfabric.so.1 .

patchelf --replace-needed libefa.so.1 /lib64/libefa.so.1 libfabric.so.1 

patchelf --add-needed /lib64/libnl-route-3.so.200 libfabric.so.1  # Required by system libefa

patchelf --add-needed /lib64/libnl-3.so.200 libfabric.so.1        # Required by system libefa

# Make libmpi depend on the patched libfabric thereby effectively forcing a preload of that lib

patchelf --add-needed $PWD/libfabric.so.1 libmpi.so.40 

```



## Letting EESSI find the host site libraries with `host_injections`



Once there is a patch for `libfabric.so.40` and `libmpi.so.40` that makes sure all host site libfabric are picked up. These files can be added to the host_injections path in the EESSI repository. This is a variant symlink. please take a look at the documentation ...



>**_NOTE:_** Add link to the host injections page once https://github.com/EESSI/docs/pull/188 is merged




On neoverse_n1:
```

mkdir -p $EESSI_HOST_INJECTIONS/2023.06/software/linux/aarch64/neoverse_n1/rpath_overrides/OpenMPI/system/lib

mv libfabric.so.1 libmpi.so.40 $EESSI_HOST_INJECTIONS/2023.06/software/linux/aarch64/neoverse_n1/rpath_overrides/OpenMPI/system/lib

```
On haswell:
```

mkdir -p $EESSI_HOST_INJECTIONS/2023.06/software/linux/x86_64/intel/haswell/rpath_overrides/OpenMPI/system/lib

mv libfabric.so.1 libmpi.so.40 $EESSI_HOST_INJECTIONS/2023.06/software/linux/x86_64/intel/haswell/rpath_overrides/OpenMPI/system/lib

```


Since the EasyBuild hook for rpath is used on the current installations in EESSI there is no extra steps required to force the executables to find the host site libraries. Thus when the modified `libmpi` is found this should be fully replacing the MPI/libfabric of the applications.



## Check if the injected libraries are picked up



```

source /cvmfs/software.eessi.io/versions/2023.06/init/bash

module load GROMACS

ldd $(which gmx_mpi)

libmpi.so.40 => /cvmfs/software.eessi.io/host_injections/2023.06/software/linux/x86_64/intel/haswell/rpath_overrides/OpenMPI/system/lib/libmpi.so.40 (0x0000155162cdb000)
``` 