However, sometimes it seems that the entire PCH gets unloaded (so the “my_cppfile.cpp” fails to compile even). Am I doing something obviously wrong? I’ve tried to search for examples, but I couldn’t find many. I also tried to have two transactions, one in loadFile, one in process, to pass the same one, or to do unload(2), but I had no lock.
Unloading is the toughest operation for cling - it’s something clang really doesn’t do, ever, and we know of issues with it.
As an alternative you could consider starting a child interpreter. That mostly depends on the complexity of the code in the PCH: if clang implemented AST copying / injection for it you can set up a parent interpreter with the PCH, and then move any subsequent operations into a short-lived child interpreter. See the constructor here: cling: cling::Interpreter Class Reference
(And we really need to get our CI to update those doxygen pages…)
Hi Axel, just to report back - it seems that for the particular PCH, clang didn’t do whatever is supposed to do, so if I create the child interpreter, none of the symbols from PCH are visible (unless I pass the PCH again via -include-pch, but that causes a significant startup hit).
Thank you anyway for the software, it’s a pleasure tinkering with it.
Hmm that’s surprising, I did not expect complete failure with the child interpreter…
OK well, so we need to figure out what fails in the unloading case. Can you provide us with a minimal reproducer of m_cppfile that shows this issue of unloading and reloading?