aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-02-21 00:23:34 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2018-02-20 23:46:47 +0200
commit74ae71903370da0f7cd0049af8dd83f0afd68bf8 (patch)
tree3b3a41291d1cb44197bbe7ecd095325f7d1c7e20
parent7e0db58f81f2cee2134fb398d6d5b6a2ef05eaff (diff)
downloadmeson-74ae71903370da0f7cd0049af8dd83f0afd68bf8.zip
meson-74ae71903370da0f7cd0049af8dd83f0afd68bf8.tar.gz
meson-74ae71903370da0f7cd0049af8dd83f0afd68bf8.tar.bz2
pkgconfig deps: Add all -L args when using -l args
Also don't resolve -lfoo args only when libpaths are defined. cc.find_library() also searches in the toolchain directories, and the static library might be there.
-rw-r--r--mesonbuild/dependencies/base.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index fefab3f..3357e8e 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -525,10 +525,9 @@ class PkgConfigDependency(ExternalDependency):
if self.static:
if lib.startswith('-L'):
libpaths.append(lib[2:])
- print(lib)
continue
# FIXME: try to handle .la files in static mode too?
- elif lib.startswith('-l') and libpaths:
+ elif lib.startswith('-l'):
args = self.compiler.find_library(lib[2:], self.env, libpaths, libtype='static')
if not args or len(args) < 1:
if lib in static_libs_notfound:
@@ -536,12 +535,6 @@ class PkgConfigDependency(ExternalDependency):
mlog.warning('Static library {!r} not found for dependency {!r}, may '
'not be statically linked'.format(lib[2:], self.name))
static_libs_notfound.append(lib)
- # Preserve the -l arg since we couldn't resolve it to
- # a static library. Also need all previous -L args now.
- for p in libpaths:
- lp = '-L' + p
- if lp not in self.link_args:
- self.link_args.append(lp)
else:
# Replace -l arg with full path to static library
lib = args[0]
@@ -558,6 +551,11 @@ class PkgConfigDependency(ExternalDependency):
lib = shared_lib
self.is_libtool = True
self.link_args.append(lib)
+ # Add all -Lbar args if we have -lfoo args in link_args
+ if static_libs_notfound:
+ # Order of -L flags doesn't matter with ld, but it might with other
+ # linkers such as MSVC, so prepend them.
+ self.link_args = ['-L' + lp for lp in libpaths] + self.link_args
def get_pkgconfig_variable(self, variable_name, kwargs):
options = ['--variable=' + variable_name, self.name]