<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/134029>134029</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Cross compiling with libc++ headers cause reference to unresolved using declaration
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          neko-para
      </td>
    </tr>
</table>

<pre>
    Refering #133934 

I'm cross compiling to x86_64-linux-gnu on macos, with a sysroot containing linux 4.4 & glibc 2.23 (ubuntu 16.04). With the following commands strange errors shows.

MacOS clang 20.1.1 from HomeBrew
Sysroot built by crosstool-ng
Libcxx 16.0.6

According to [documents of 16.0.0](https://releases.llvm.org/16.0.0/projects/libcxx/docs/) and [documents of 17.0.0](https://releases.llvm.org/17.0.1/projects/libcxx/docs/), seems that libcxx of version below 17 should work for glibc 2.23. (In 17.0.1 `Only glibc-2.24 and later and no other libc is officially supported` appears)

However, I've already build clang 16.0.6 directly on linux (by an older version clang 12), which currently just works fine.

---

```
clang++ --target=x86_64-unknown-linux-gnu 1.cpp -o 1 --sysroot /Volumes/T8/x-tools/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot -fuse-ld=lld --gcc-toolchain=/Volumes/T8/x-tools/x86_64-unknown-linux-gnu -isystem /Volumes/T8/clang-amd64-cross/include/c++/v1 -L/Volumes/T8/clang-amd64-cross/lib -stdlib=libc++
```

type A
```
In file included from 1.cpp:1:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/iostream:43:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/ios:221:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/__locale:18:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/mutex:191:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/__memory/shared_ptr.h:31:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/__memory/unique_ptr.h:17:
/Volumes/T8/clang-amd64-cross/include/c++/v1/__functional/hash.h:43:12: error: reference to unresolved using declaration
   43 | _VSTD::memcpy(&__r, __p, sizeof(__r));
      | ^
/Volumes/T8/clang-amd64-cross/include/c++/v1/cstring:80:1: note: using declaration annotated with 'using_if_exists' here
   80 | using ::memcpy _LIBCPP_USING_IF_EXISTS;
      | ^
```

type B
```
In file included from 1.cpp:1:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/iostream:43:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/ios:221:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/__locale:18:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/mutex:191:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/__memory/shared_ptr.h:42:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/atomic:2668:
In file included from /Volumes/T8/clang-amd64-cross/include/c++/v1/cmath:317:
/Volumes/T8/clang-amd64-cross/include/c++/v1/math.h:388:31: error: use of undeclared identifier 'FP_NAN'
  388 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                  
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsV01z2zYT_jXQZYccEvwQddCBsq03mnFsT-zk7fTCgcCliAQEVADUR399BySdOE7Spk3dUzycMSHu14PdfYBl1oqdQlySbEWyyxnrXavNUuEHHeyZYbOtrs_LN9igEWoHhCZxkiySFEhUkqjcEDrvgBttLXDd7YX0Uk7DqcirPA2kUP0p2KketIKOcW0JvYCjcC0wsGdrtHbAtXJMKK85yEMapkBoDjspthxoSBMgtOi3vXI9xHkYpYQuQvi_N-NahEZLqY9en-uuY6q2YJ1haoeAxmhjwbb6aMMx5teM394Dl0ztgEZhHMbQGN3BK93hyuCRROX9FNm2F9LB9jwidFrLQO1IVF6LLT-dhlDCfLRacq5NPaEn2arWvO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