From: Kefu Chai Date: Mon, 10 Feb 2020 14:06:24 +0000 (+0800) Subject: pybind: check arguments also when searching for "clang" X-Git-Tag: v15.1.1~476^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33177%2Fhead;p=ceph.git 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 --- diff --git a/src/pybind/cephfs/setup.py b/src/pybind/cephfs/setup.py index 84767b460ac..19ae6c329af 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 fe51bcd4e0d..e2c56964040 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 b1f84987414..634484f1402 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 cb5024820b5..eb1591a460a 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',