[native] Delete the std::format logging machinery from the CoreCLR host - #12536
Closed
simonrozsival wants to merge 1 commit into
Closed
Conversation
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
Contributor
There was a problem hiding this comment.
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::formatlogging macros/templates fromsrc/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 intocommon/include/shared/log_functions.hhand removes the duplicated MonoVM copy. - Keeps lane-specific
log_types.hhfocused 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 | ||
| { |
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
deleted the
dev/simonrozsival/clr-drop-log-format-machinery
branch
August 27, 2026 09:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #12533. Stacked on top of #12534.
Why
#12534 converted every CoreCLR-lane logging call site to the printf-style
log_*ffunctions. That leaves thestd::format-based macros and templates inclr/include/shared/log_types.hhwith zero users.They generated no code — the templates were never instantiated, which is why #12534 already showed the
std::formatfingerprint disappearing from every object file. But they kept<format>and the wholestd::formatAPI reachable from every CoreCLR translation unit, so it was one carelesslog_debug (LOG_X, "{}", x)away from coming back.What
std::formatmacros and templates fromclr/include/shared/log_types.hh. The file is now byte-for-byte identical to the existing NativeAOT stub.std::string_viewoverload oflog_write(used bycommon/runtime-base/timing-internal.cc). It was duplicated in both the CoreCLR and MonoVM copies oflog_types.hh; it now lives once incommon/include/shared/log_functions.hh, shared by all three lanes, and the MonoVM duplicate is removed.No size change — and that's expected
This removes dead declarations, not dead code. The win is that
std::formatcan no longer be reintroduced into the CoreCLR host by accident, not fewer bytes.Result
std::formatis now completely absent from theclr/,common/andnativeaot/trees:std::format#include <format>clr/common/(shared)nativeaot/mono/Only MonoVM still uses it — that's the remaining work on #12533.
Verification
Built the CoreCLR, MonoVM and NativeAOT lanes for
arm64-v8aRelease. All clean.