[clang] [CUDA][HIP] improve error message for missing cmath (PR #122155)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 8 11:02:54 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
@llvm/pr-subscribers-clang
Author: Yaxun (Sam) Liu (yxsamliu)
<details>
<summary>Changes</summary>
One common error seen in CUDA/HIP compilation is:
fatal error: 'cmath' file not found
which is due to inproper installation of standard C++ libraries.
Since it happens with #include_next, users may feel confusing which cmath is not found and how to fix it.
Add an error directive to help users resolve this issue.
---
Full diff: https://github.com/llvm/llvm-project/pull/122155.diff
1 Files Affected:
- (modified) clang/lib/Headers/cuda_wrappers/cmath (+4)
``````````diff
diff --git a/clang/lib/Headers/cuda_wrappers/cmath b/clang/lib/Headers/cuda_wrappers/cmath
index 45f89beec9b4df..7deca678bf252e 100644
--- a/clang/lib/Headers/cuda_wrappers/cmath
+++ b/clang/lib/Headers/cuda_wrappers/cmath
@@ -24,7 +24,11 @@
#ifndef __CLANG_CUDA_WRAPPERS_CMATH
#define __CLANG_CUDA_WRAPPERS_CMATH
+#if __has_include_next(<cmath>)
#include_next <cmath>
+#else
+#error "Could not find standard C++ header 'cmath'. Add -v to your compilation command to check the include paths being searched. You may need to install the appropriate standard C++ library package corresponding to the search path."
+#endif
#if defined(_LIBCPP_STD_VER)
``````````
</details>
https://github.com/llvm/llvm-project/pull/122155
More information about the cfe-commits
mailing list