From 956c6f3e50b4bd96e3263aad7f92f8f3b0c520c6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 10 Feb 2020 22:06:24 +0800 Subject: [PATCH] pybind: check arguments also when searching for "clang" if "ccache" is used, compiler[0] would be "ccache", and compiler[1] would be "clang", in this case, we should search for "clang" until an argument starting with "-" is found. it signals be the first cflag passed to the compiler. Signed-off-by: Kefu Chai --- src/pybind/cephfs/setup.py | 5 +++-- src/pybind/rados/setup.py | 5 +++-- src/pybind/rbd/setup.py | 5 +++-- src/pybind/rgw/setup.py | 4 +++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pybind/cephfs/setup.py b/src/pybind/cephfs/setup.py index 84767b460ac97..19ae6c329afa7 100755 --- a/src/pybind/cephfs/setup.py +++ b/src/pybind/cephfs/setup.py @@ -9,12 +9,13 @@ import tempfile import textwrap from distutils.ccompiler import new_compiler from distutils.errors import CompileError, LinkError -from itertools import filterfalse +from itertools import filterfalse, takewhile import distutils.sysconfig def filter_unsupported_flags(compiler, flags): - if 'clang' in compiler: + args = takewhile(lambda argv: not argv.startswith('-'), [compiler] + flags) + if any('clang' in arg for arg in args): return list(filterfalse(lambda f: f in ('-mcet', '-fstack-clash-protection', diff --git a/src/pybind/rados/setup.py b/src/pybind/rados/setup.py index fe51bcd4e0d9e..e2c5696404089 100755 --- a/src/pybind/rados/setup.py +++ b/src/pybind/rados/setup.py @@ -2,7 +2,7 @@ from __future__ import print_function import distutils.sysconfig from distutils.errors import CompileError, LinkError from distutils.ccompiler import new_compiler -from itertools import filterfalse +from itertools import filterfalse, takewhile import os import pkgutil @@ -14,7 +14,8 @@ import textwrap def filter_unsupported_flags(compiler, flags): - if 'clang' in compiler: + args = takewhile(lambda argv: not argv.startswith('-'), [compiler] + flags) + if any('clang' in arg for arg in args): return list(filterfalse(lambda f: f in ('-mcet', '-fstack-clash-protection', diff --git a/src/pybind/rbd/setup.py b/src/pybind/rbd/setup.py index b1f849874149f..634484f14029b 100755 --- a/src/pybind/rbd/setup.py +++ b/src/pybind/rbd/setup.py @@ -9,12 +9,13 @@ import tempfile import textwrap from distutils.ccompiler import new_compiler from distutils.errors import CompileError, LinkError -from itertools import filterfalse +from itertools import filterfalse, takewhile import distutils.sysconfig def filter_unsupported_flags(compiler, flags): - if 'clang' in compiler: + args = takewhile(lambda argv: not argv.startswith('-'), [compiler] + flags) + if any('clang' in arg for arg in args): return list(filterfalse(lambda f: f in ('-mcet', '-fstack-clash-protection', diff --git a/src/pybind/rgw/setup.py b/src/pybind/rgw/setup.py index cb5024820b5ff..eb1591a460ae8 100755 --- a/src/pybind/rgw/setup.py +++ b/src/pybind/rgw/setup.py @@ -10,11 +10,13 @@ import tempfile import textwrap from distutils.ccompiler import new_compiler from distutils.errors import CompileError, LinkError +from itertools import filterfalse, takewhile import distutils.sysconfig def filter_unsupported_flags(compiler, flags): - if 'clang' in compiler: + args = takewhile(lambda argv: not argv.startswith('-'), [compiler] + flags) + if any('clang' in arg for arg in args): return list(filterfalse(lambda f: f in ('-mcet', '-fstack-clash-protection', -- 2.39.5