[petsc-users] Configuring PETSc to use a relative RPATH with $ORIGIN

Satish Balay balay.anl at fastmail.org
Mon Feb 24 10:57:42 CST 2025


I see you are referring to https://urldefense.us/v3/__https://www.baeldung.com/linux/rpath-change-in-binary__;!!G_uCfscf7eWS!f7FgqvyBSVkObSDsRA2uRpI9SqxQm_45esiwkTgdj0eKkrGQn5C-j-bU-DR-T7stFHid-jUbqwu9_gXjsiU_4KPp7pg$ 

I suspect its easier to do this  by "manually modifying the libraries after their creation" than fix up build tools to support it.

configure accepts 'LIBS' option that can potentially be used - but I suspect the '$ORIGIN' might not survive different layers
of shell escapes that might occur.

./configure LIBS=-Wl,-rpath,'$ORIGIN'/foo1

Satish

On Mon, 24 Feb 2025, Eric Chamberland via petsc-users wrote:

> Hello,
> 
> We would like to make the libraries generated from PETSc compilation and
> installation more easily relocatable. Currently, we work around this
> limitation by using LD_LIBRARY_PATH in the environment and manually modifying
> the RPATH recorded in the libraries to remove it.
> 
> Recently, we discovered an interesting approach: during the build process, we
> can set a relative RPATH using the $ORIGIN variable, which corresponds to the
> directory containing the library. This allows libpetsc.so dependencies to be
> referenced relatively instead of absolutely, making the library "movable"
> without requiring LD_LIBRARY_PATH modifications. We can also apply the same
> approach to our binaries.
> 
> To avoid manually modifying the libraries after their creation, we were
> wondering if there is a way to configure PETSc to use a relative RPATH with
> $ORIGIN directly?
> 
> I looked through PETSc's configuration options and files but couldn't find
> anything mentioning $ORIGIN, and very little related to RPATH.
> 
> A SPACK newbie question: is this achievable with SPACK?
> 
> Thanks in advance for your help!
> 
> Eric
> 
> 



More information about the petsc-users mailing list