diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-08-08 04:31:09 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-08-11 04:16:18 -0700 |
commit | ae5ebd258f45cbca94197c8d380628095680544d (patch) | |
tree | 84547775db7b037c73b160db0191e61bef718958 /mesonbuild/compilers/c.py | |
parent | 9ddc305e0727f5c89a61459c15325b31bf88f7da (diff) | |
download | meson-ae5ebd258f45cbca94197c8d380628095680544d.zip meson-ae5ebd258f45cbca94197c8d380628095680544d.tar.gz meson-ae5ebd258f45cbca94197c8d380628095680544d.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
Diffstat (limited to 'mesonbuild/compilers/c.py')
-rw-r--r-- | mesonbuild/compilers/c.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 2530adf..2dfe794 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 @@ -905,10 +908,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) @@ -1188,7 +1194,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) |