Skip to content

[native] Delete the std::format logging machinery from the CoreCLR host - #12536

Closed
simonrozsival wants to merge 1 commit into
dev/simonrozsival/clr-remove-std-formatfrom
dev/simonrozsival/clr-drop-log-format-machinery
Closed

[native] Delete the std::format logging machinery from the CoreCLR host#12536
simonrozsival wants to merge 1 commit into
dev/simonrozsival/clr-remove-std-formatfrom
dev/simonrozsival/clr-drop-log-format-machinery

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Part of #12533. Stacked on top of #12534.

Why

#12534 converted every CoreCLR-lane logging call site to the printf-style log_*f functions. That leaves the std::format-based macros and templates in clr/include/shared/log_types.hh with zero users.

They generated no code — the templates were never instantiated, which is why #12534 already showed the std::format fingerprint disappearing from every object file. But they kept <format> and the whole std::format API reachable from every CoreCLR translation unit, so it was one careless log_debug (LOG_X, "{}", x) away from coming back.

What

  • Deletes the std::format macros and templates from clr/include/shared/log_types.hh. The file is now byte-for-byte identical to the existing NativeAOT stub.
  • The one piece worth keeping was the std::string_view overload of log_write (used by common/runtime-base/timing-internal.cc). It was duplicated in both the CoreCLR and MonoVM copies of log_types.hh; it now lives once in common/include/shared/log_functions.hh, shared by all three lanes, and the MonoVM duplicate is removed.

No size change — and that's expected

before after
undefined libc++ refs (arm64 Release archive) 76 76

This removes dead declarations, not dead code. The win is that std::format can no longer be reintroduced into the CoreCLR host by accident, not fewer bytes.

Result

std::format is now completely absent from the clr/, common/ and nativeaot/ trees:

lane std::format #include <format>
clr/ 0 0
common/ (shared) 0 0
nativeaot/ 0 0
mono/ 45 2

Only MonoVM still uses it — that's the remaining work on #12533.

Verification

Built the CoreCLR, MonoVM and NativeAOT lanes for arm64-v8a Release. All clean.

With every CoreCLR-lane call site converted to the printf-style `log_*f`
functions, the `std::format`-based macros and templates in
`clr/include/shared/log_types.hh` have no users left. They generated no
code (the templates were never instantiated), but they kept `<format>`
and the whole `std::format` API reachable from CLR translation units.

`clr/include/shared/log_types.hh` is now byte-for-byte identical to the
NativeAOT stub.

The only piece worth keeping was the `std::string_view` overload of
`log_write`, which is used by `common/runtime-base/timing-internal.cc`
and was previously duplicated in both the CoreCLR and MonoVM copies of
`log_types.hh`. It moves to `common/include/shared/log_functions.hh`, so
all three lanes share a single definition, and the duplicate is dropped
from `mono/shared/log_types.hh`.

There is no code size change - this removes dead declarations, not dead
code. `std::format` is now entirely absent from the `clr/`, `common/` and
`nativeaot/` trees; only MonoVM still uses it.

Verified by building the CoreCLR, MonoVM and NativeAOT lanes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0a35a0db-502d-48c0-8468-e73b5dd0ab2e
Copilot AI lite review requested due to automatic review settings August 27, 2026 09:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the (now-unused) std::format-based logging wrappers from the CoreCLR host lane to keep <format> and the std::format API from being accidentally reintroduced via header usage, while deduplicating a small helper overload shared across runtime lanes.

Changes:

  • Deletes std::format logging macros/templates from src/native/clr/include/shared/log_types.hh, leaving a minimal stub that routes through shared logging functions.
  • Moves the log_write(LogCategories, LogLevel, std::string_view) convenience overload into common/include/shared/log_functions.hh and removes the duplicated MonoVM copy.
  • Keeps lane-specific log_types.hh focused on lane behavior, with common helpers centralized.
Show a summary per file
File Description
src/native/mono/shared/log_types.hh Removes the duplicated std::string_view log_write overload now centralized in common shared logging helpers.
src/native/common/include/shared/log_functions.hh Adds <string_view> include and centralizes the log_write convenience overload for shared use across lanes.
src/native/clr/include/shared/log_types.hh Deletes the std::format macro/template machinery and reduces the header to a minimal stub including shared logging functions.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +20 to +24
// `message` must be a NUL-terminated string, `std::string_view` is used here merely to avoid
// having to call `.data ()` at every call site that uses a string literal.
[[gnu::always_inline]]
static inline void log_write (LogCategories category, LogLevel level, std::string_view const& message) noexcept
{
@simonrozsival

Copy link
Copy Markdown
Member Author

Folded into #12534 — the change is small and inseparable from the call-site conversion it depends on, so it doesn't warrant a separate review pass.

@simonrozsival
simonrozsival deleted the dev/simonrozsival/clr-drop-log-format-machinery branch August 27, 2026 09:35
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.

2 participants