Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CustomOP]Support find include/c++/v1 include dirs automatically #32404

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions python/paddle/utils/cpp_extension/extension_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,34 @@ def find_paddle_includes(use_cuda=False):

if OS_NAME.startswith('darwin'):
# NOTE(Aurelius84): Ensure to find std v1 headers correctly.
std_v1_includes = '/Library/Developer/CommandLineTools/usr/include/c++/v1/'
include_dirs.append(std_v1_includes)
std_v1_includes = find_clang_cpp_include()
if std_v1_includes is not None and os.path.exists(std_v1_includes):
include_dirs.append(std_v1_includes)

return include_dirs


def find_clang_cpp_include(compiler='clang'):
std_v1_includes = None
try:
compiler_version = subprocess.check_output([compiler, "--version"])
if six.PY3:
compiler_version = compiler_version.decode()
infos = compiler_version.split("\n")
for info in infos:
if "InstalledDir" in info:
v1_path = info.split(':')[-1].strip()
if v1_path and os.path.exists(v1_path):
std_v1_includes = os.path.join(
os.path.dirname(v1_path), 'include/c++/v1')
except Exception:
# Just raise warnings because the include dir is not required.
warnings.warn(
"Failed to search `include/c++/v1/` include dirs. Don't worry because it's not required."
)
return std_v1_includes


def find_cuda_libraries():
"""
Use heuristic method to find cuda static lib path
Expand Down