<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56929>56929</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[openmp] use of std::equal in an offloaded region
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
paulromano
</td>
</tr>
</table>
<pre>
Trying to use `std::equal` within a `#pragma omp target` region targeting an NVIDIA GPU currently results in an error at link-time because of an undefined reference to `memcmp`. Here's a quick reproducer:
<details>
<summary>Reproducer (main.cpp)</summary>
```C++
#include <algorithm>
int main() {
#pragma omp target
{
int x[2];
int y[2];
bool eq = std::equal(x, x + 2, y);
}
return 0;
}
```
</details>
<details>
<summary>Compile line</summary>
`clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp`
</details>
<details>
<summary>Compile output</summary>
```
nvlink error : Undefined reference to 'memcmp' in '/tmp/main-43c562-nvptx64-nvidia-cuda-sm_70-fcf375.cubin'
/soft/compilers/llvm/master-nightly/bin/clang-linker-wrapper: error: 'nvlink' failed
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
```
</details>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVEtv2zgQ_jXShZAhUa_ooEMS17u9FMViu9eCJkcyW4pU-HDsf79DybGRZBfNoQZhjjjvbx57I8793_Ys9Ui8IcEBSZrceZGU93jgKTCFD-RZ-oPUhEVuQsvZsnFixEwz8cyO4KOMhVEafXmIBpkmX_75vP18T_74-o3wYC1or84o6ILyjkSDmoC1xhLmiZL6Z-blBGQPnMVQzBAFghYwSA0CFQdAGxxirOhygolPMxIb8icyEto6DPEpSP4TZWdrROBgYyr5NskxoUcBnknlkvLT9cmFaWL2jE9_XVVIQu8mJvWGz3NCO5RK6O4meNFd_xGQ5aDIQzzrKy2l5ioIxLN8ZGo0FhGc3uhK7Ul0g97QC0nam_Z7hBcOuQkR_EUDp6R-oEm9Tco3jPN_MfbGKAJPGNWWvCkzvTsl9JGcMPkHQiN5XnJ_uLnevpAWfLCa5FfulXfF4xVIC4DvwP9QVR4RA6kgtgf8ohBcMT2uZSDZYGbQCN8Lka04opetPs7-1FTkWuLfH60Jfg7-Q42zfupj7P_LNCDW5T359j-NT9tL49M2zhBe6MTH713MKKtKXjc0u2SJtxSSZTwIlrnpe5tnAx_Ktt7wsI-917403c6ZwePF1xysQ1qp47TYdR5spuV4wAnGh0VztwCexcCR-WzZPC_jtmYRCbS-JhZjHRA2EKu3VbNoXkmvhgj6n5gWF_ll9xA4SY8MnKciDmfcDtkxouEAEISj4czj9okN-_E2TKEvmrpryiLPy1T0pejKjqVeegU9Ts_aODhC5LKNXk_MZYGZYVCGiaVMcQOmwar-4P3soizd4RkxhbDfYGI3SOOV4cL5ATyCLp0LEBGvm4526aEv67zu8o4WZc6oaO7aoa26osurqqZdnRepYntQLsaZUKrhmSwmkMaAU9nTnNL8Lq-KpmwquhEVrYphXwOvi6LpRFLlgN2iNjGOjbFjavslpH0YHTKVdN7dmMw5OWpYYIn2WfAHY_uZBWUNVsuki_d-if5feBDnXw">