mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Use -isystem for system includes in C++ extensions (#11459)
Summary: I noticed warnings from within pybind11 being shown when building C++ extensions. This can be avoided by including non-user-supplied headers with `-isystem` instead of `-I` I hope this works on Windows. soumith ezyang Pull Request resolved: https://github.com/pytorch/pytorch/pull/11459 Differential Revision: D9764444 Pulled By: goldsborough fbshipit-source-id: b288572106078f347f0342f158f9e2b63a58c235
This commit is contained in:
parent
d32b41003a
commit
01c7542f43
|
|
@ -817,15 +817,21 @@ def _write_ninja_file(path,
|
|||
# Turn into absolute paths so we can emit them into the ninja build
|
||||
# file wherever it is.
|
||||
sources = [os.path.abspath(file) for file in sources]
|
||||
includes = [os.path.abspath(file) for file in extra_include_paths]
|
||||
user_includes = [os.path.abspath(file) for file in extra_include_paths]
|
||||
|
||||
# include_paths() gives us the location of torch/torch.h
|
||||
includes += include_paths(with_cuda)
|
||||
system_includes = include_paths(with_cuda)
|
||||
# sysconfig.get_paths()['include'] gives us the location of Python.h
|
||||
includes.append(sysconfig.get_paths()['include'])
|
||||
system_includes.append(sysconfig.get_paths()['include'])
|
||||
|
||||
# Windoze does not understand `-isystem`.
|
||||
if sys.platform == 'win32':
|
||||
user_includes += system_includes
|
||||
system_includes.clear()
|
||||
|
||||
common_cflags = ['-DTORCH_EXTENSION_NAME={}'.format(name)]
|
||||
common_cflags += ['-I{}'.format(include) for include in includes]
|
||||
common_cflags += ['-I{}'.format(include) for include in user_includes]
|
||||
common_cflags += ['-isystem {}'.format(include) for include in system_includes]
|
||||
|
||||
if is_binary_build():
|
||||
common_cflags += ['-D_GLIBCXX_USE_CXX11_ABI=0']
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user