[all-commits] [llvm/llvm-project] d0397a: [clang] Adding an Atomic Line Logger (#195885)

Qiongsi Wu via All-commits all-commits at lists.llvm.org
Fri Jun 5 16:31:42 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d0397a6d7d78888e278823c4d32749f8c896ef9c
      https://github.com/llvm/llvm-project/commit/d0397a6d7d78888e278823c4d32749f8c896ef9c
  Author: Qiongsi Wu <qiongsiwu at gmail.com>
  Date:   2026-06-05 (Fri, 05 Jun 2026)

  Changed paths:
    A clang/include/clang/Basic/AtomicLineLogger.h
    A clang/lib/Basic/AtomicLineLogger.cpp
    M clang/lib/Basic/CMakeLists.txt
    A clang/unittests/Basic/AtomicLineLoggerTest.cpp
    M clang/unittests/Basic/CMakeLists.txt

  Log Message:
  -----------
  [clang] Adding an Atomic Line Logger (#195885)

This PR adds an atomic line logger to `clang`. 

Situations have arisen where `clang` performs multi-threaded tasks (such
as dependency scanning), and race conditions may happen. Such race
conditions are difficult to debug using either `lldb` or with
`llvm::errs()`.

This logger provides atomic logging per line to a file on disk with time
stamps at each line to facilitate such investigations. Specifically, the
logger is designed with the following properties:

1. Each line is atomically written to the backing file. This avoids
concurrent writes making the output text interleaving.
2. Each line is prefixed with a timestamp, a process ID and a thread ID.
3. `LogLine` implements a `<<` operator to allow arbitrary printable
types to be piped into it.
4. The `LogLine`'s user does not need to check if it is setup or valid.
A LogLine is always valid and can always accept input from `<<`. It
becomes a no-op if the `LogLine` object is returned from a default
constructed `AtomicLineLogger`.
5. The write happens when a `LogLine` object goes out of scope. 

The logger is inspired by the
[OnDiskCASLogger](https://github.com/llvm/llvm-project/blob/09abee845d2136630fc3f50524148daa55a740a8/llvm/include/llvm/CAS/OnDiskCASLogger.h#L33).
A followup PR https://github.com/llvm/llvm-project/pull/195896 wires up
this logger to clang's dependency scanning stack.

Assisted-by: claude-opus-4.6

rdar://39907408



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list