aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-10-23 18:46:40 +0200
committerGitHub <noreply@github.com>2017-10-23 18:46:40 +0200
commitcc4a9bcf35eafb56a48545b700b064c2231d48f2 (patch)
treeccc17381b0368b2c0ace11c7d1a864f0a1221e1e
parent562c50f229cfe0a28abdfc2c56360f5a82c83b57 (diff)
parent9262236322140f0b2cb94a53baeb67188c247f59 (diff)
downloadmeson-cc4a9bcf35eafb56a48545b700b064c2231d48f2.zip
meson-cc4a9bcf35eafb56a48545b700b064c2231d48f2.tar.gz
meson-cc4a9bcf35eafb56a48545b700b064c2231d48f2.tar.bz2
Merge pull request #2516 from dcbaker/submit/llvm-fix-lib-path
LLVM: Don't add -L<system path> to link args
-rw-r--r--mesonbuild/dependencies/base.py11
-rw-r--r--mesonbuild/dependencies/dev.py4
-rw-r--r--mesonbuild/environment.py18
3 files changed, 31 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 0d9742d..9913a0b 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -640,3 +640,14 @@ def find_external_dependency(name, env, kwargs):
raise pkg_exc
mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO'))
return pkgdep
+
+
+def strip_system_libdirs(environment, link_args):
+ """Remove -L<system path> arguments.
+
+ leaving these in will break builds where a user has a version of a library
+ in the system path, and a different version not in the system path if they
+ want to link against the non-system path version.
+ """
+ exclude = {'-L{}'.format(p) for p in environment.get_compiler_system_dirs()}
+ return [l for l in link_args if l not in exclude]
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index b0e54c6..308ae55 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -23,6 +23,7 @@ from .. import mlog
from .. import mesonlib
from ..mesonlib import version_compare, Popen_safe, stringlistify, extract_as_list
from .base import DependencyException, ExternalDependency, PkgConfigDependency
+from .base import strip_system_libdirs
class GTestDependency(ExternalDependency):
def __init__(self, environment, kwargs):
@@ -172,8 +173,7 @@ class LLVMDependency(ExternalDependency):
[self.llvmconfig, '--libs', '--ldflags'])[:2]
if p.returncode != 0:
raise DependencyException('Could not generate libs for LLVM.')
- self.link_args = shlex.split(out)
-
+ self.link_args = strip_system_libdirs(environment, shlex.split(out))
p, out = Popen_safe([self.llvmconfig, '--cppflags'])[:2]
if p.returncode != 0:
raise DependencyException('Could not generate includedir for LLVM.')
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 2f33a03..a746cab 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -887,6 +887,24 @@ class Environment:
def get_datadir(self):
return self.coredata.get_builtin_option('datadir')
+ def get_compiler_system_dirs(self):
+ for comp in self.coredata.compilers.values():
+ if isinstance(comp, compilers.ClangCompiler):
+ index = 1
+ break
+ elif isinstance(comp, compilers.GnuCompiler):
+ index = 2
+ break
+ else:
+ # This option is only supported by gcc and clang. If we don't get a
+ # GCC or Clang compiler return and empty list.
+ return []
+
+ p, out, _ = Popen_safe(comp.get_exelist() + ['-print-search-dirs'])
+ if p.returncode != 0:
+ raise mesonlib.MesonException('Could not calculate system search dirs')
+ out = out.split('\n')[index].lstrip('libraries: =').split(':')
+ return [os.path.normpath(p) for p in out]
def get_args_from_envvars(compiler):
"""