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

    <tr>
        <th>Summary</th>
        <td>
            Replace the use of C++ standard library in libFuzzer
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            compiler-rt:fuzzer
      </td>
    </tr>

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

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

<pre>
    libFuzzer implementation uses C++ standard library but that introduces a number of issues:

* When libFuzzer is built against libc++, but the application uses libstdc++, we cannot use the two together.
* When libc++ itself is instrumented (for example with ASan), we cannot use it for libFuzzer.
* When the application is implemented in C, we may want to avoid a dependency on the C++ library.

The current solution is to use a private version of libc++, which was introduced in [D37631](https://reviews.llvm.org/D37631), but this introduces additional complexity and overhead to the build (since we need to build libc++ twice).

We should consider replacing the use of C++ standard library altogether and instead use custom implementation of the necessary containers and other utilities.

libFuzzer primarily uses `std::string`, `std::vector`, `std::unordered_map` and `std::set`. Rather than reimplementing these ourselves, we should be able to use stripped down and simplified implementations from LLVM ADT, which is strategy which was also [adopted for sanitizers](https://github.com/llvm/llvm-project/blob/dd639eb15aacfc865409915516f52385c4381923/compiler-rt/lib/sanitizer_common/sanitizer_dense_map.h).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVUGP2zgP_TXKhWhgy4kzOfiQ6SCnfpd-xfZY0BIdc1eWDIlOmvn1CznJTDLtAruXBDBFvsfHRwlT4oMnatT6Wa1fFjhJH2IzksQ-JPpr0QZ7bhy3--n1lSLwMDoayAsKBw9TogSflX5W-hmSoLcYLThuI8YztJOA9CjAXmKwk6EECH4aWooQOuCUJkqq2qniRRW3X72D7z15uANN0E7sBPCA7JPkkLmAKv35CkOA4-jY3BFz3CaxdydPBAa9D5Ljc46cAkg4kPQUl78SuOYCSyKXCUPGj1NWgCwo_dSFCPQTsyxw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