[clang] [clang-repl] Fix inconsistent flushing between in-process and out-of-process (PR #166368)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 18 06:02:02 PST 2025


================
@@ -352,6 +352,20 @@ int main(int argc, const char **argv) {
     Interp = ExitOnErr(clang::Interpreter::create(std::move(CI), Config));
   }
 
+  if (Config.IsOutOfProcess) {
+    static const char *const InitUnbufferedStreams = R"(
+      #include <stdio.h>
+      __attribute__((constructor))
+      static void __clang_repl_ioinit(void) {
+        setvbuf(stdout, NULL, _IONBF, 0);
+        setvbuf(stderr, NULL, _IONBF, 0);
----------------
vgvassilev wrote:

Ok, we cannot afford including headers. How about declaring `void __clang_repl_ioinit(void)` and defining it in the compiled code like we do with the `__clang_Interpreter_SetValue`.

@lhames, can you think of any other way to handle this problem?

https://github.com/llvm/llvm-project/pull/166368


More information about the cfe-commits mailing list