From a76542e191944083f5cdf61ea98bdc1d21aa4cf7 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 22 Feb 2022 23:22:38 +0100 Subject: [PATCH] meson: Let the linker create RPATH instead of RUNPATH tag Running meson test from the build directory in a jhbuild environment picks up libraries which have been installed previously because LD_LIBRARY_PATH takes precendence over RUNPATH. Make the linker generate the RPATH tag again. Part-of: --- meson.build | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/meson.build b/meson.build index 404885404..898a67fa0 100644 --- a/meson.build +++ b/meson.build @@ -59,6 +59,20 @@ i18n = import('i18n') fs = import('fs') cc = meson.get_compiler('c') +add_project_link_arguments( + cc.get_supported_link_arguments( + # meson automatically adds -rpath to targets and strips them when they + # are installed. ld adds a RUNPATH tag for -rpath arguments by default. + # This makes ld add a RPATH tag instead (as it did some time ago). + # The reason why we want RPATH and not RUNPATH is that LD_LIBRARY_PATH + # takes precedence over RUNPATH but not over RPATH. Since we usually run + # development builds in jhbuild which sets up LD_LIBRARY_PATH this can + # result in wrong dependencies being picked up by the linker. + '-Wl,--disable-new-dtags', + ), + language : 'c', +) + prefix = get_option('prefix') bindir = join_paths(prefix, get_option('bindir'))