diff options
author | Fini Jastrow <ulf.fini.jastrow@desy.de> | 2020-11-25 14:43:11 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-01-20 19:00:25 +0000 |
commit | 49cde9653c904b7f3ddc6b42bb4cf1bd4646d162 (patch) | |
tree | 8a9664a95ce919567d74118a369eb472c772be17 /mesonbuild/backend | |
parent | 3c304bbb79ac5562ad401c722801a7d9ad4de0c6 (diff) | |
download | meson-49cde9653c904b7f3ddc6b42bb4cf1bd4646d162.zip meson-49cde9653c904b7f3ddc6b42bb4cf1bd4646d162.tar.gz meson-49cde9653c904b7f3ddc6b42bb4cf1bd4646d162.tar.bz2 |
ninjabackend: Correct RPATH order
[why]
If we build and test a library we need to make sure that we find the
currently build library object first, before an older system installed
one.
This can be broken if the library in question is installed in a custom
path, and another library we depend on also is installed there.
[how]
Just move the rpath to the current build artifacts to the front.
Solves #8030.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index c1c4c93..400433f 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2904,6 +2904,26 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) # Now we will add libraries and library paths from various sources + # Set runtime-paths so we can run executables without needing to set + # LD_LIBRARY_PATH, etc in the environment. Doesn't work on Windows. + if has_path_sep(target.name): + # Target names really should not have slashes in them, but + # unfortunately we did not check for that and some downstream projects + # now have them. Once slashes are forbidden, remove this bit. + target_slashname_workaround_dir = os.path.join( + os.path.dirname(target.name), + self.get_target_dir(target)) + else: + target_slashname_workaround_dir = self.get_target_dir(target) + (rpath_args, target.rpath_dirs_to_remove) = ( + linker.build_rpath_args(self.environment, + self.environment.get_build_dir(), + target_slashname_workaround_dir, + self.determine_rpath_dirs(target), + target.build_rpath, + target.install_rpath)) + commands += rpath_args + # Add link args to link to all internal libraries (link_with:) and # internal dependencies needed by this target. if linker_base == 'STATIC': @@ -2951,25 +2971,6 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) dep_targets = [] dep_targets.extend(self.guess_external_link_dependencies(linker, target, commands, internal)) - # Set runtime-paths so we can run executables without needing to set - # LD_LIBRARY_PATH, etc in the environment. Doesn't work on Windows. - if has_path_sep(target.name): - # Target names really should not have slashes in them, but - # unfortunately we did not check for that and some downstream projects - # now have them. Once slashes are forbidden, remove this bit. - target_slashname_workaround_dir = os.path.join( - os.path.dirname(target.name), - self.get_target_dir(target)) - else: - target_slashname_workaround_dir = self.get_target_dir(target) - (rpath_args, target.rpath_dirs_to_remove) = ( - linker.build_rpath_args(self.environment, - self.environment.get_build_dir(), - target_slashname_workaround_dir, - self.determine_rpath_dirs(target), - target.build_rpath, - target.install_rpath)) - commands += rpath_args # Add libraries generated by custom targets custom_target_libraries = self.get_custom_target_provided_libraries(target) commands += extra_args |