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

    <tr>
        <th>Summary</th>
        <td>
            [libc][test] make DeathTestExecutors and FPExceptionHelpers hermetic
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          nickdesaulniers
      </td>
    </tr>
</table>

<pre>
    Towards the goal of being able to cross compile full builds, I hit a snag yesterday when cross compiling some of the unit tests.  With some other smaller fixes to our cmake, I can cross compile (and run in QEMU) _some_ unit tests, but quite a few still fail to build.

80cf21dad150a added a [TODO](https://github.com/llvm/llvm-project/blob/c39fba209ce655cf5997878b0bf794da269f008a/libc/test/UnitTest/CMakeLists.txt#L29-L30) that implies that the LibcDeathTestExecutors and LibcFPExceptionHelpers are indeed not yet hermetic.  (It then unsets `LLVM_LIBC_FULL_BUILD` which changes the set compiler options from `_get_common_test_compile_options`).

Here's an example failure:
```
llvm-project/libc/test/UnitTest/LibcDeathTestExecutors.cpp:15:10: fatal error: 'assert.h' file not found
   15 | #include <assert.h>
      | ^~~~~~~~~~
```

I suspect we can start relying on hdr/ for these from the UnitTests.

So that needs to get fixed first, before we can cross compile the entire unit test suite.

cc @lntue 

---

FWIW, my cmake invocation is:
```
$ cmake ../runtimes -GNinja -DLLVM_ENABLE_LLD=ON -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_RUNTIMES="libc" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_LIBC_FULL_BUILD=ON -DLIBC_TARGET_TRIPLE=aarch64-linux-gnu -DCMAKE_CROSSCOMPILING_EMULATOR=qemu-aarch64 -DLIBC_KERNEL_HEADERS=/tmp/sysroot/include
```
and my kernel headers were built via:
```
$ make LLVM=1 ARCH=arm64 INSTALL_HDR_PATH=/tmp/sysroot headers_install
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVUtzo7wS_TXypssuLIwfCy-wgYlryOM6zp25K0qIxmgiJI8kknhzf_tXAnsemcziS6USQN19-px-iFkrjgpxTaINoVQJ_lyhZZ1UAo0llJIoGbHONdqs3x2OSl2d1wf9ykxlwTUIR80k6BpKFOoIrJQITgM32lrguj0JiVB3UkLZCVlZQrewg0Y4YGAVO8IZrUNTsTO8Nqh-c_QBrW7Rh_dQnRIOHFpnJwBfhGsup65BA7ZlUqKBWryh9SnozgBv2TMOkJypd1kRumSqAtMpEAr-k94-EbqCwscsfsHy7mXn4HsnHAKDGl_BOiEl1ExIj9Qzm5AgJkG8DHhNpxWrplHAgFUVVsCARJvDfXJPooTQZePcyZIwJjQjNDsK13TlhOuW0EzKl-u_8cnob8gdoVkpdUloxsNVXTIarDjOo4jX0Wq1WC6WZVDWi9WsYnS-qoNgyXwAUXJCM58_odmTEu4wPG5v2TPmwkvo3hyhYU5X4zwMPHPXMAeiPUnhBfQvXvRclDxB5hofIX1D3jltLHjl_FH2kL5xPDmh1Q3KE_ojgyBUhViB0g7O6KBB06ITfAJe9V0fWUGnLDoLZB7k-X9vi3y32RbZU54Xm6ddnpB5AK-N4A3whqkjDu1m0V0LaED3uBZqo1sfpjiiK7huW60Kz724WBYXQzL3RC-VukGDhC48FcA31p58ozIhO4O-OEHsrYffIH5Xkb_q-7FaE346kTCeRv5PQMIYauaYBDRGG_9K6IJZi8ZNGkIXUPv29NrVulMVCWIAmEZAFlsgNBSKy65CIOH2h1OYDlYAg1WU_v_6844JCeId2M6ekDt4xX4urGPGgUF59iOnFTSVITSDWhsvusVBYa__lau9qPioh1ZRiFU_dkd0_QxWUAvjNdlCibU2eAX7fQh9TFROmF_GG6wftQsA50BmgVSuQxi-jMfj4SH7svvi47fnYdBBqBfNmS81CPtnEQmdXQwnE0Iz0yknWrQw_nQn1DcG46Tvw_Qu3uRpkecJCZP7Oxgn29v4cz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