Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Add libclang API to set temporary directory location (especially for preamble-*.pch files) #51472

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52505
Status NEW
Importance P enhancement
Reported by Igor Kushnir (igorkuo@gmail.com)
Reported on 2021-11-15 01:13:57 -0800
Last modified on 2021-11-15 01:13:57 -0800
Version unspecified
Hardware PC Linux
CC klimek@google.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
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: https://invent.kde.org/kdevelop/kdevelop/-
/merge_requests/283.

Related bug reports: Bug 52489, Bug 30673.