aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-08-08 04:31:09 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2018-08-24 03:20:49 +0530
commitf552869ed3db3d2f9662a9a59d0dccc68d92e90c (patch)
treee77848eb7d257f653623f06072a56f530b735900
parent111a8325bddb8a8352473ec897485b68915a51fd (diff)
downloadmeson-f552869ed3db3d2f9662a9a59d0dccc68d92e90c.zip
meson-f552869ed3db3d2f9662a9a59d0dccc68d92e90c.tar.gz
meson-f552869ed3db3d2f9662a9a59d0dccc68d92e90c.tar.bz2
PkgConfigDependency: Don't try to resolve internal compiler libs
-lc -lm -ldl -lrt -lpthread are special linker arguments that should never be resolved to on-disk libraries. Closes https://github.com/mesonbuild/meson/issues/3879
-rw-r--r--mesonbuild/compilers/c.py11
-rw-r--r--mesonbuild/compilers/compilers.py3
-rw-r--r--mesonbuild/dependencies/base.py12
3 files changed, 20 insertions, 6 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 47cb568..5056b30 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -47,11 +47,14 @@ from .compilers import (
RunResult,
)
+gnu_compiler_internal_libs = ('m', 'c', 'pthread', 'dl', 'rt')
+
class CCompiler(Compiler):
library_dirs_cache = {}
program_dirs_cache = {}
find_library_cache = {}
+ internal_libs = gnu_compiler_internal_libs
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
# If a child ObjC or CPP class has already set it, don't set it ourselves
@@ -903,10 +906,13 @@ class CCompiler(Compiler):
# First try if we can just add the library as -l.
# Gcc + co seem to prefer builtin lib dirs to -L dirs.
# Only try to find std libs if no extra dirs specified.
- if not extra_dirs:
+ if not extra_dirs or libname in self.internal_libs:
args = ['-l' + libname]
if self.links(code, env, extra_args=args):
return args
+ # Don't do a manual search for internal libs
+ if libname in self.internal_libs:
+ return None
# Not found or we want to use a specific libtype? Try to find the
# library file itself.
patterns = self.get_library_naming(env, libtype)
@@ -1186,7 +1192,8 @@ class IntelCCompiler(IntelCompiler, CCompiler):
class VisualStudioCCompiler(CCompiler):
std_warn_args = ['/W3']
std_opt_args = ['/O2']
- ignore_libs = ('m', 'c', 'pthread')
+ ignore_libs = gnu_compiler_internal_libs
+ internal_libs = ()
def __init__(self, exelist, version, is_cross, exe_wrap, is_64):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 25835a3..cb3ed23 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -661,6 +661,9 @@ class Compiler:
# Libraries to ignore in find_library() since they are provided by the
# compiler or the C library. Currently only used for MSVC.
ignore_libs = ()
+ # Libraries that are internal compiler implementations, and must not be
+ # manually searched.
+ internal_libs = ()
# Cache for the result of compiler checks which can be cached
compiler_check_cache = {}
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index f087db6..0e9a79d 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -621,12 +621,16 @@ class PkgConfigDependency(ExternalDependency):
# arguments as-is and then adding the libpaths at the end.
else:
args = None
- if args:
+ if args is not None:
libs_found.add(lib)
# Replace -l arg with full path to library if available
- # else, library is provided by the compiler and can't be resolved
- if not args[0].startswith('-l'):
- lib = args[0]
+ # else, library is either to be ignored, or is provided by
+ # the compiler, can't be resolved, and should be used as-is
+ if args:
+ if not args[0].startswith('-l'):
+ lib = args[0]
+ else:
+ continue
else:
# Library wasn't found, maybe we're looking in the wrong
# places or the library will be provided with LDFLAGS or