[all-commits] [llvm/llvm-project] 6d4fd9: [clang] Reland Adding an Atomic Line Logger (#1958...
Qiongsi Wu via All-commits
all-commits at lists.llvm.org
Thu Jun 11 08:28:09 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6d4fd946e4486f13d6b4ea1cc54d2aae5ee2f03d
https://github.com/llvm/llvm-project/commit/6d4fd946e4486f13d6b4ea1cc54d2aae5ee2f03d
Author: Qiongsi Wu <qiongsiwu at gmail.com>
Date: 2026-06-11 (Thu, 11 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] Reland Adding an Atomic Line Logger (#195885) (#202428)
This PR relands #195885. The original PR caused a Windows [build
failure](https://github.com/llvm/llvm-project/pull/195885#issuecomment-4636690409)
because of differences in const capture support in MSVC and `clang`. The
unit test is fixed by capturing everything.
***********
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