[igt-dev] [PATCH 1/1] meson: Set up runpath for installed executables
Arkadiusz Hiler
arkadiusz.hiler at intel.com
Mon Mar 12 12:08:08 UTC 2018
On Fri, Jan 19, 2018 at 01:44:07PM +0200, Latvala, Petri wrote:
> Meson builds libigt as a shared library, and executables naturally
> have to find it at runtime. Using default options puts the library to
> a normal search paths, but any modifications to the directory options
> or a non-conventional prefix setting makes using LD_LIBRARY_PATH or
> other library search means mandatory.
>
> Add a build option 'use_rpath' (default: false) that makes meson set
> up DT_RUNPATH at install time, pointing to the library with a path
> relative to the executable, using $ORIGIN. That way the installed
> executables find the library even when not installed to exactly the
> build-time configured prefix path, a setup CI occasionally uses.
>
> Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> Cc: Tomi Sarvela <tomi.p.sarvela at intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
> ---
> meson_options.txt | 4 ++++
> tests/meson.build | 26 ++++++++++++++++++++++++++
> tools/meson.build | 26 ++++++++++++++++++++++++++
> 3 files changed, 56 insertions(+)
> create mode 100644 meson_options.txt
>
> diff --git a/meson_options.txt b/meson_options.txt
> new file mode 100644
> index 00000000..41be35e0
> --- /dev/null
> +++ b/meson_options.txt
> @@ -0,0 +1,4 @@
> +option('use_rpath',
> + type : 'boolean',
> + value : false,
> + description : 'Set runpath on installed executables for libigt.so')
> diff --git a/tests/meson.build b/tests/meson.build
> index 2322217d..b764b7f7 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -255,24 +255,49 @@ if alsa.found() and gsl.found()
> test_deps += alsa
> endif
>
> +if get_option('use_rpath')
> + # Set up runpath for the test executables towards libigt.so.
> + # The path should be relative to $ORIGIN so the library is
> + # still found properly even if installed to a path other than
> + # prefix.
> +
> + # libdir and libexecdir are pathnames relative to
> + # prefix. meson enforces this.
> +
> + # Start from the executable
> + rpathdir = '$ORIGIN'
> + # Executables are installed in libexecdir. Add a .. for each
> + # directory name in it.
> + foreach p : libexecdir.split('/')
> + rpathdir = join_paths(rpathdir, '..')
> + endforeach
> + # Add relative path to libdir
> + rpathdir = join_paths(rpathdir, libdir)
Theoretically there is $LIB which:
"They will be replaced by [...] or either lib - for 32-bit binaries - or
lib64 - for 64-bit binaries - in the case of $LIB"
But I think I like current soultion more.
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
Tested-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
I'll push it in a minute.
I've learend something today, thanks!
--
Cheers,
Arek
More information about the igt-dev
mailing list