From 6a2dc7576e00e849510f7bc1f939d66d0b2f6f80 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 14 Nov 2018 19:16:38 +0200 Subject: [PATCH] Store unexpanded library directory paths. Closes #4392. --- mesonbuild/compilers/c.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 4d3b2a2a2..1b198b645 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -219,9 +219,22 @@ class CCompiler(Compiler): def _split_fetch_real_dirs(pathstr, sep=':'): paths = [] for p in pathstr.split(sep): - p = Path(p) - if p.exists() and p.resolve().as_posix() not in paths: - paths.append(p.resolve().as_posix()) + # GCC returns paths like this: + # /usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/lib + # It would make sense to normalize them to get rid of the .. parts + # Sadly when you are on a merged /usr fs it also kills these: + # /lib/x86_64-linux-gnu + # since /lib is a symlink to /usr/lib. This would mean + # paths under /lib would be considered not a "system path", + # which is wrong and breaks things. Store everything, just to be sure. + pobj = Path(p) + unresolved = pobj.as_posix() + resolved = Path(p).resolve().as_posix() + if pobj.exists(): + if unresolved not in paths: + paths.append(unresolved) + if resolved not in paths: + paths.append(resolved) return tuple(paths) def get_compiler_dirs(self, env, name):