From a9210c57e1bbd95716a46760dad3198d067b5cb0 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 21 Dec 2017 16:30:52 -0800 Subject: [PATCH] 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(+) 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"""