<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Add libclang API to set temporary directory location (especially for preamble-*.pch files)"
   href="https://bugs.llvm.org/show_bug.cgi?id=52505">52505</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Add libclang API to set temporary directory location (especially for preamble-*.pch files)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>libclang
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>igorkuo@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>klimek@google.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>preamble-*.pch files generated by libclang can occupy a lot of disk space. So
it is important for an IDE, which uses libclang, to prevent accumulation of
these files after a crash. This can be done by setting libclang's temporary
directory to a per-session value and removing this directory with all leftover
files after a possible previous crash when the session starts.

It is possible to configure clang's temporary directory location via
platform-dependent environment variables (e.g. TMPDIR, TMP). Setting the
environment variables works well if libclang lives in a separate process (e.g.
in Qt Creator). But when libclang runs in the same process as the rest of the
IDE (like in KDevelop), setting the environment variables is problematic,
because they are inherited by the IDE's code and all child processes it spawns
(compiler, build system and user-provided executables). The IDE must then
remove the temporary directory environment variable from each child process
where it can cause undesirable behavior. A libclang API function to configure
the temporary directory location would greatly simplify cleanup implementation
in this case. Here is the discussion of a rejected implementation of this
feature in KDevelop:
<a href="https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/283">https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/283</a>.

Related bug reports: <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clangd can exhaust all disk space in /tmp by writing preamble-*.pch files"
   href="show_bug.cgi?id=52489">Bug 52489</a>, <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Allow lit's temporary directory to be specified in the local lit config"
   href="show_bug.cgi?id=30673">Bug 30673</a>.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>