From 20eb948b974a96b3933d42db524fd584cb60c8b7 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 25 May 2019 19:01:44 +0200 Subject: gnome: make sure the target build directory is passed first for linking determine_rpath_dirs() can return paths to external dependencies not in the build dir and passing them first as a link path leads to g-ir-scanner for example linking against the already installed library instead of the just built one. This was reported in g-i: https://gitlab.gnome.org/GNOME/gobject-introspection/issues/272 and comes up quite often when a library adds some new symbols which aren't present in the system library, which then makes linking fail. The first place where the order is changed is _scan_gir_targets(), which looks like an unintentional change in the refactoring in 8377ea45aa61efbe8e1a75b74 The second place in _get_link_args() has always been that way and only the rpath order is changed, but it looks to me as if the same rules should apply here too. --- mesonbuild/modules/gnome.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mesonbuild/modules/gnome.py') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index e20bae6..a223b78 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -299,6 +299,9 @@ class GnomeModule(ExtensionModule): if isinstance(lib, build.SharedLibrary): libdir = os.path.join(state.environment.get_build_dir(), state.backend.get_target_dir(lib)) link_command.append('-L' + libdir) + if include_rpath: + link_command.append('-Wl,-rpath,' + libdir) + depends.append(lib) # Needed for the following binutils bug: # https://github.com/mesonbuild/meson/issues/1911 # However, g-ir-scanner does not understand -Wl,-rpath @@ -308,9 +311,6 @@ class GnomeModule(ExtensionModule): link_command.append('-L' + d) if include_rpath: link_command.append('-Wl,-rpath,' + d) - if include_rpath: - link_command.append('-Wl,-rpath,' + libdir) - depends.append(lib) if gir_has_option(self.interpreter, '--extra-library') and use_gir_args: link_command.append('--extra-library=' + lib.name) else: @@ -553,6 +553,11 @@ class GnomeModule(ExtensionModule): libname = girtarget.get_basename() else: libname = os.path.join("@PRIVATE_OUTDIR_ABS_%s@" % girtarget.get_id(), girtarget.get_filename()) + ret += ['--library', libname] + # need to put our output directory first as we need to use the + # generated libraries instead of any possibly installed system/prefix + # ones. + ret += ["-L@PRIVATE_OUTDIR_ABS_%s@" % girtarget.get_id()] # Needed for the following binutils bug: # https://github.com/mesonbuild/meson/issues/1911 # However, g-ir-scanner does not understand -Wl,-rpath @@ -560,11 +565,6 @@ class GnomeModule(ExtensionModule): for d in state.backend.determine_rpath_dirs(girtarget): d = os.path.join(state.environment.get_build_dir(), d) ret.append('-L' + d) - ret += ['--library', libname] - # need to put our output directory first as we need to use the - # generated libraries instead of any possibly installed system/prefix - # ones. - ret += ["-L@PRIVATE_OUTDIR_ABS_%s@" % girtarget.get_id()] return ret -- cgit v1.1