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 ++++- mesonbuild/mesonlib.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'mesonbuild') 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: diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 3b3299637..8793dff77 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -285,6 +285,9 @@ def is_cygwin(): def is_debianlike(): return os.path.isfile('/etc/debian_version') +def is_dragonflybsd(): + return platform.system().lower() == 'dragonfly' + def for_windows(is_cross, env): """ Host machine is windows? -- cgit v1.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') 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.3 From 3a0f8ab0cf56d4036251be3f8d593b3f93c07c47 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 21 Dec 2017 09:01:10 -0800 Subject: dependencies/dev: remove unused imports flake8 complains about them, and I prefer to have a clean error log in vim. --- mesonbuild/dependencies/dev.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 91414d5b0..e039bd670 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -17,11 +17,10 @@ import os import re -import shutil from .. import mlog from .. import mesonlib -from ..mesonlib import version_compare, Popen_safe, stringlistify, extract_as_list +from ..mesonlib import version_compare, stringlistify, extract_as_list from .base import ( DependencyException, ExternalDependency, PkgConfigDependency, strip_system_libdirs, ConfigToolDependency, -- cgit v1.3 From 448ba5b6f300dcaae018e7bb03017f488a0a92a3 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 21 Dec 2017 09:40:49 -0800 Subject: LLVM: work around bug in dragonfly bsd llvm-config for shared libs Of course there are OS specific bugs for llvm-config as well, so work around those too. --- mesonbuild/dependencies/dev.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index e039bd670..2be9be4bf 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -173,6 +173,16 @@ class LLVMDependency(ConfigToolDependency): def _set_new_link_args(self): """How to set linker args for LLVM versions >= 3.9""" + if (mesonlib.is_dragonflybsd() and not self.static and + version_compare(self.version, '>= 4.0')): + # llvm-config on DragonFly BSD for versions 4.0, 5.0, and 6.0 have + # an error when generating arguments for shared mode linking, even + # though libLLVM.so is installed, because for some reason the tool + # expects to find a .so for each static library. This works around + # that. + self.link_args = self.get_config_value(['--ldflags'], 'link_args') + self.link_args.append('-lLLVM') + return link_args = ['--link-static', '--system-libs'] if self.static else ['--link-shared'] self.link_args = self.get_config_value( ['--libs', '--ldflags'] + link_args + list(self.required_modules), -- cgit v1.3 From 660dee1e10b5293c38d372b7a8ddfce49cc14936 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 21 Dec 2017 13:33:57 -0800 Subject: LLVM: use DragonFly BSD workaround on FreeBSD as well --- mesonbuild/dependencies/dev.py | 14 +++++++------- mesonbuild/mesonlib.py | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 2be9be4bf..4a163ea1e 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -173,13 +173,13 @@ class LLVMDependency(ConfigToolDependency): def _set_new_link_args(self): """How to set linker args for LLVM versions >= 3.9""" - if (mesonlib.is_dragonflybsd() and not self.static and - version_compare(self.version, '>= 4.0')): - # llvm-config on DragonFly BSD for versions 4.0, 5.0, and 6.0 have - # an error when generating arguments for shared mode linking, even - # though libLLVM.so is installed, because for some reason the tool - # expects to find a .so for each static library. This works around - # that. + if ((mesonlib.is_dragonflybsd() or mesonlib.is_freebsd()) and not + self.static and version_compare(self.version, '>= 4.0')): + # llvm-config on DragonFly BSD and FreeBSD for versions 4.0, 5.0, + # and 6.0 have an error when generating arguments for shared mode + # linking, even though libLLVM.so is installed, because for some + # reason the tool expects to find a .so for each static library. + # This works around that. self.link_args = self.get_config_value(['--ldflags'], 'link_args') self.link_args.append('-lLLVM') return diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 8793dff77..b7d29921a 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -288,6 +288,9 @@ def is_debianlike(): def is_dragonflybsd(): return platform.system().lower() == 'dragonfly' +def is_freebsd(): + return platform.system().lower() == 'freebsd' + def for_windows(is_cross, env): """ Host machine is windows? -- cgit v1.3 From a9210c57e1bbd95716a46760dad3198d067b5cb0 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 21 Dec 2017 16:30:52 -0800 Subject: LLVM: work around FreeBSD specific static linking problems Because FreeBSD's llvm-config adds -l/usr/lib/libexecinfo.so when asked for system-libs, which is bogus. We'll remove the leading -l from any argument that also ends with .so. --- mesonbuild/dependencies/dev.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 4a163ea1e..25316df0e 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -170,6 +170,24 @@ class LLVMDependency(ConfigToolDependency): else: self._set_old_link_args() self.link_args = strip_system_libdirs(environment, self.link_args) + self.link_args = self.__fix_bogus_link_args(self.link_args) + + @staticmethod + def __fix_bogus_link_args(args): + """This function attempts to fix bogus link arguments that llvm-config + generates. + + Currently it works around the following: + - FreeBSD: when statically linking -l/usr/lib/libexecinfo.so will + be generated, strip the -l in cases like this. + """ + new_args = [] + for arg in args: + if arg.startswith('-l') and arg.endswith('.so'): + new_args.append(arg.lstrip('-l')) + else: + new_args.append(arg) + return new_args def _set_new_link_args(self): """How to set linker args for LLVM versions >= 3.9""" -- cgit v1.3