Skip to content

Commit 56a6ee1

Browse files
eli-schwartzjpakkane
authored andcommitted
find_library with argument beginning in "lib" is a bad idea, warn about it
We need to support cases where the library might be called "foo.so" and therefore we check for exact matches too. But this also allows `cc.find_library('libfoo')` to find libfoo.so, which is strange and won't work in many cases. Emit a warning when this happens. Fixes #10838
1 parent 05da4b0 commit 56a6ee1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mesonbuild/compilers/mixins/clike.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,8 @@ def _find_library_real(self, libname: str, env: 'Environment', extra_dirs: T.Lis
11581158
trial = self._get_file_from_list(env, trials)
11591159
if not trial:
11601160
continue
1161+
if libname.startswith('lib') and trial.name.startswith(libname):
1162+
mlog.warning(f'find_library({libname!r}) starting in "lib" only works by accident and is not portable')
11611163
return [trial.as_posix()]
11621164
return None
11631165

0 commit comments

Comments
 (0)