Skip to content

Fix embedding: NoRuntime atexit guard + redirectable cling::outs()#564

Open
0xeb wants to merge 1 commit intoroot-project:masterfrom
lallouslab:fix/embedding-runtime
Open

Fix embedding: NoRuntime atexit guard + redirectable cling::outs()#564
0xeb wants to merge 1 commit intoroot-project:masterfrom
lallouslab:fix/embedding-runtime

Conversation

@0xeb
Copy link

@0xeb 0xeb commented Mar 23, 2026

Summary

Two fixes for embedding cling in other applications:

  • Guard atexit interception with NoRuntime check: PCH files generated with -noruntime included atexit declarations, causing redefinition errors when consumer interpreters loaded the PCH. The guard matches the existing pattern used for gCling/RuntimeUniverse preamble.

  • Make cling::outs() redirectable: Adds setOuts(raw_ostream*) API so embedders can capture or redirect cling's output stream. Pass nullptr to restore the default (std::cout wrapper).

Test plan

  • Tested on ARM64 Linux, Windows x64 (MSVC), and MinGW cross-build
  • PCH generation with -noruntime works cleanly with the atexit guard
  • Output capture via setOuts() verified in embedding test suite
  • 34/34 tests pass

Two fixes for embedding cling in other applications:

1. Guard atexit interception with NoRuntime check: PCH files generated
   with -noruntime included atexit declarations, causing redefinition
   errors when consumer interpreters loaded the PCH. The guard matches
   the existing pattern used for gCling/RuntimeUniverse preamble.

2. Make cling::outs() redirectable: adds setOuts(raw_ostream*) API so
   embedders can capture or redirect cling's output stream. Pass
   nullptr to restore the default (std::cout wrapper).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant