From f056b585a2ace2831f22023031d4ac28b9f55aea Mon Sep 17 00:00:00 2001
From: Dylan Baker <dylan@pnwbakers.com>
Date: Mon, 8 May 2017 10:38:55 -0700
Subject: [PATCH] Implement a cpp blacklist for LLVM dependency

This adds a set of private flags that are removed from the output of
`llvm-config --cppflags` before storing them. This is unfortunately
necessary since some versions of LLVM include absolute garbage like
'-DNDEBUG' in their CPP flags, and we don't want to pass those.
---
 mesonbuild/dependencies.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py
index ef7be3a5e..ea5660e2a 100644
--- a/mesonbuild/dependencies.py
+++ b/mesonbuild/dependencies.py
@@ -1631,6 +1631,7 @@ class LLVMDependency(Dependency):
     llvmconfig = None
     _llvmconfig_found = False
     __best_found = None
+    __cpp_blacklist = {'-DNDEBUG'}
 
     def __init__(self, environment, kwargs):
         super().__init__('llvm-config', kwargs)
@@ -1676,7 +1677,7 @@ class LLVMDependency(Dependency):
             p, out = Popen_safe([self.llvmconfig, '--cppflags'])[:2]
             if p.returncode != 0:
                 raise DependencyException('Could not generate includedir for LLVM.')
-            self.cargs = shlex.split(out)
+            self.cargs = list(mesonlib.OrderedSet(shlex.split(out)).difference(self.__cpp_blacklist))
 
             p, out = Popen_safe([self.llvmconfig, '--components'])[:2]
             if p.returncode != 0: