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.
0.44
Nirbheek Chauhan 7 years ago
parent c21b1a58cd
commit 8b5286e133
  1. 14
      mesonbuild/dependencies/base.py

@ -490,10 +490,9 @@ class PkgConfigDependency(ExternalDependency):
if self.static: if self.static:
if lib.startswith('-L'): if lib.startswith('-L'):
libpaths.append(lib[2:]) libpaths.append(lib[2:])
print(lib)
continue continue
# FIXME: try to handle .la files in static mode too? # 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') args = self.compiler.find_library(lib[2:], self.env, libpaths, libtype='static')
if not args or len(args) < 1: if not args or len(args) < 1:
if lib in static_libs_notfound: if lib in static_libs_notfound:
@ -501,12 +500,6 @@ class PkgConfigDependency(ExternalDependency):
mlog.warning('Static library {!r} not found for dependency {!r}, may ' mlog.warning('Static library {!r} not found for dependency {!r}, may '
'not be statically linked'.format(lib[2:], self.name)) 'not be statically linked'.format(lib[2:], self.name))
static_libs_notfound.append(lib) 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: else:
# Replace -l arg with full path to static library # Replace -l arg with full path to static library
lib = args[0] lib = args[0]
@ -523,6 +516,11 @@ class PkgConfigDependency(ExternalDependency):
lib = shared_lib lib = shared_lib
self.is_libtool = True self.is_libtool = True
self.link_args.append(lib) 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): def get_pkgconfig_variable(self, variable_name, kwargs):
options = ['--variable=' + variable_name, self.name] options = ['--variable=' + variable_name, self.name]

Loading…
Cancel
Save