From 10a560a411728f747c8394599ef95c9c8caa2086 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 19 Dec 2017 15:42:01 -0800 Subject: compilers: fix unittest "16 prebuilt shared" on dragonfly bsd --- mesonbuild/compilers/compilers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index b14074bae..52dbb56be 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -855,7 +855,10 @@ class Compiler: paths = padding else: paths = paths + ':' + padding - args = ['-Wl,-rpath,' + paths] + args = [] + if mesonlib.is_dragonflybsd(): + args.append('-Wl,-z,origin') + args.append('-Wl,-rpath,' + paths) if get_compiler_is_linuxlike(self): # Rpaths to use while linking must be absolute. These are not # written to the binary. Needed only with GNU ld: -- cgit v1.2.3 From 4620bdd8b4ca6a5619ff2e963f661a8784b89a05 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 19 Dec 2017 15:52:21 -0800 Subject: tests: fix rpath_uses_ORIGIN on dragonflybsd Which always seems to prepend /usr/lib/gcc50 (or whatever version) to the rpath, and $ORIGIN after that. --- mesonbuild/compilers/compilers.py | 5 +++++ run_unittests.py | 22 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 52dbb56be..2602d1495 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -857,6 +857,11 @@ class Compiler: paths = paths + ':' + padding args = [] if mesonlib.is_dragonflybsd(): + # This argument instructs the compiler to record the value of + # ORIGIN in the .dynamic section of the elf. On Linux this is done + # by default, but is not on dragonfly for some reason. Without this + # $ORIGIN in the runtime path will be undefined and any binaries + # linked against local libraries will fail to resolve them. args.append('-Wl,-z,origin') args.append('-Wl,-rpath,' + paths) if get_compiler_is_linuxlike(self): diff --git a/run_unittests.py b/run_unittests.py index 08ad63209..f61544f9a 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -34,8 +34,10 @@ import mesonbuild.environment import mesonbuild.mesonlib import mesonbuild.coredata from mesonbuild.interpreter import ObjectHolder -from mesonbuild.mesonlib import is_linux, is_windows, is_osx, is_cygwin, windows_proof_rmtree -from mesonbuild.mesonlib import python_command, meson_command, version_compare +from mesonbuild.mesonlib import ( + is_linux, is_windows, is_osx, is_cygwin, is_dragonflybsd, + windows_proof_rmtree, python_command, meson_command, version_compare, +) from mesonbuild.environment import Environment, detect_ninja from mesonbuild.mesonlib import MesonException, EnvironmentException from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram @@ -1386,12 +1388,24 @@ int main(int argc, char **argv) { for each in ('prog', 'subdir/liblib1.so', ): rpath = get_rpath(os.path.join(self.builddir, each)) self.assertTrue(rpath) - for path in rpath.split(':'): + if is_dragonflybsd(): + # DragonflyBSD will prepend /usr/lib/gccVERSION to the rpath, + # so ignore that. + self.assertTrue(rpath.startswith('/usr/lib/gcc')) + rpaths = rpath.split(':')[1:] + else: + rpaths = rpath.split(':') + for path in rpaths: self.assertTrue(path.startswith('$ORIGIN'), msg=(each, path)) # These two don't link to anything else, so they do not need an rpath entry. for each in ('subdir/subdir2/liblib2.so', 'subdir/subdir3/liblib3.so'): rpath = get_rpath(os.path.join(self.builddir, each)) - self.assertTrue(rpath is None) + if is_dragonflybsd(): + # The rpath should be equal to /usr/lib/gccVERSION + self.assertTrue(rpath.startswith('/usr/lib/gcc')) + self.assertEqual(len(rpath.split(':')), 1) + else: + self.assertTrue(rpath is None) def test_dash_d_dedup(self): testdir = os.path.join(self.unit_test_dir, '10 d dedup') -- cgit v1.2.3