-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[OpenMP][libc++] including <iostream> when targeting amdgpu caues error: use of undeclared identifier '__not_found' #67938
Comments
@jhuber6 We should get rid of these headers ... for now, can you check out the proposed solutions? |
@llvm/issue-subscribers-openmp
There seems to be a header inclusion bug in https://github.com/llvm/llvm-project/blob/a7517e12caab0750d3dfd7c0c6faec9acc7e5a2b/clang/lib/Headers/__clang_hip_math.h#L18
That header file doesn't seems to have an actual need for `<algorithm>` but its inclusion cases failures down the line.
For example:
```
#include <iostream>
int main() {
#pragma omp target
{}
return 0;
}
```
Compiling the program causes a header related error only when targeting amdgpu:
```
// clang++ -std=c++17 -stdlib=libc++ -fexperimental-library -fopenmp --offload-arch=gfx1036 mp_sample.cpp -O2 # -Xclang -ast-dump
// In file included from mp_sample.cpp:1:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/iostream:43:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/ios:222:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/__locale:16:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/__mutex/once_flag.h:21:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/tuple:268:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/compare:145:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/__compare/compare_partial_order_fallback.h:13:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/__compare/partial_order.h:14:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/__compare/weak_order.h:14:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/__compare/strong_order.h:20:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/lib/clang/18/include/openmp_wrappers/cmath:17:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/cmath:319:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/lib/clang/18/include/openmp_wrappers/math.h:55:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/lib/clang/18/include/__clang_hip_math.h:18:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/algorithm:1977:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/iterator:683:
// In file included from /home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/__iterator/common_iterator.h:31:
/// home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/variant:402:21: error: use of undeclared identifier '__not_found'
// 402 | size_t __result = __not_found;
// | ^
/// home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/variant:405:23: error: use of undeclared identifier '__not_found'
// 405 | if (__result != __not_found) {
// | ^
/// home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/variant:406:16: error: use of undeclared identifier '__ambiguous'
// 406 | return __ambiguous;
// | ^
/// home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/variant:419:45: error: use of undeclared identifier '__not_found'
// 419 | struct __find_unambiguous_index_sfinae_impl<__not_found> {};
// | ^
/// home/tom/software/llvm-ompt/96adadf8f722/bin/../include/c++/v1/variant:422:45: error: use of undeclared identifier '__ambiguous'
// 422 | struct __find_unambiguous_index_sfinae_impl<__ambiguous> {};
// | ^
// ... goes on...
```
Targeting nvptx works as expected.
Manually removing `#include <algorithm>` in `__clang_hip_math.h` works, and so does adding `#include <algorithm>` before `#include <iostream>` in the reproducer program.
The actual cause seems to be an ordering issue, as In case it matters: > clang++
clang version 18.0.0 (git@<!-- -->github.com:tom91136/llvm-project.git 96adadf8f7227f6543537056f27f98cb18bbe8ce)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tom/software/llvm-ompt/96adadf8f722/bin
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/12
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/12
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/12
Candidate multilib: .;@<!-- -->m64
Candidate multilib: 32;@<!-- -->m32
Selected multilib: .;@<!-- -->m64
Found HIP installation: /opt/rocm, version 5.5.30202 |
Summary: The `algorithm` header included here sometimes caused issues when using `libc++` over `libstdc++`. This was primarily because of the order they were included in. This patch just gets rid of this dependency as it was only used for min and max which are trivial to reimplement. Fixes: llvm#67938
…67981) Summary: The `algorithm` header included here sometimes caused issues when using `libc++` over `libstdc++`. This was primarily because of the order they were included in. This patch just gets rid of this dependency as it was only used for min and max which are trivial to reimplement. Fixes: #67938
There seems to be a header inclusion bug in
llvm-project/clang/lib/Headers/__clang_hip_math.h
Line 18 in a7517e1
That header file doesn't seems to have an actual need for
<algorithm>
but its inclusion cases failures down the line.For example:
Compiling the program causes a header related error only when targeting amdgpu:
Targeting nvptx works as expected.
Manually removing
#include <algorithm>
in__clang_hip_math.h
works, and so does adding#include <algorithm>
before#include <iostream>
in the reproducer program.The actual cause seems to be an ordering issue, as
__not_found
is defined in<tuple>
but that header's include chain eventually leads to__iterator/common_iterator.h
which depends on<variant>
in OpenMP target's amdgpu case, and<variant>
expects some of the symbols from<tuple>
(which isn't defined just yet).In case it matters:
The text was updated successfully, but these errors were encountered: