mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
Try to autodetect the location of the clang standard libraries.
On some linuxes, /usr/include belongs to GCC and the standard libraries that work with clang are in /usr/lib/clang/8.0.0 or some variation thereof. This results in errors such as: ``` /../lib64/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../include/c++/8.3.0/bits/cxxabi_init_exception.h:38:10: fatal error: 'stddef.h' file not found ``` during extraction.
This commit is contained in:
parent
a175b21e4b
commit
4612db54ac
@ -14,6 +14,7 @@ import textwrap
|
||||
from clang import cindex
|
||||
from clang.cindex import CursorKind
|
||||
from collections import OrderedDict
|
||||
from glob import glob
|
||||
from threading import Thread, Semaphore
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
@ -240,6 +241,20 @@ if __name__ == '__main__':
|
||||
sysroot_dir = os.path.join(sdk_dir, next(os.walk(sdk_dir))[1][0])
|
||||
parameters.append('-isysroot')
|
||||
parameters.append(sysroot_dir)
|
||||
elif platform.system() == 'Linux':
|
||||
# clang doesn't find its own base includes by default on Linux,
|
||||
# but different distros install them in different paths.
|
||||
# Try to autodetect, preferring the highest numbered version.
|
||||
def clang_folder_version(d):
|
||||
return [int(ver) for ver in re.findall(r'(?<!lib)(?<!\d)\d+', d)]
|
||||
clang_include_dir = max((
|
||||
path
|
||||
for libdir in ['lib64', 'lib', 'lib32']
|
||||
for path in glob('/usr/%s/clang/*/include' % libdir)
|
||||
if os.path.isdir(path)
|
||||
), default=None, key=clang_folder_version)
|
||||
if clang_include_dir:
|
||||
parameters.extend(['-isystem', clang_include_dir])
|
||||
|
||||
for item in sys.argv[1:]:
|
||||
if item.startswith('-'):
|
||||
|
Loading…
Reference in New Issue
Block a user