[NativeAOT] Remove std::format from host compilation - #12446
Conversation
Keep the std::format logging surface available to CoreCLR while compiling it out of the NativeAOT host. Avoid pulling timing implementation headers into NativeAOT declarations and migrate the remaining shared call sites to printf or direct logging. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR advances the NativeAOT host-dependency reduction work by compiling the std::format-based logging surface only for non-NativeAOT builds (CoreCLR), while migrating remaining NativeAOT-reachable logging to printf-style / direct logging and reducing timing-related header inclusion.
Changes:
- Gate
<format>/std::formatmacros & templates behind!XA_HOST_NATIVEAOTwhile keeping CoreCLR’s existingstd::formatlogging surface. - Switch several call sites to
*_f(printf-style) orlog_writeto avoidstd::formatusage in NativeAOT-reachable paths. - Avoid pulling full timing implementation into NativeAOT host declarations via conditional include and forward declarations.
Show a summary per file
| File | Description |
|---|---|
| src/native/clr/include/shared/log_types.hh | Conditionalize <format> usage and logging macro/templates for non-NativeAOT builds; introduce a string_view log_write overload. |
| src/native/clr/include/runtime-base/internal-pinvokes.hh | Avoid including timing headers for NativeAOT by forward-declaring managed_timing_sequence. |
| src/native/clr/include/host/host.hh | Avoid timing include and timing accessor/state for NativeAOT builds. |
| src/native/clr/host/os-bridge.cc | Replace non-printf logging calls with log_warnf for NativeAOT compatibility. |
| src/native/clr/host/internal-pinvokes-shared.cc | Route managed log messages through log_write instead of format-based wrappers. |
| src/native/clr/host/gc-bridge.cc | Replace std::format-surface logging with log_errorf. |
| src/native/clr/host/bridge-processing.cc | Replace std::format-surface logging with log_errorf. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
Use the existing printf-style logging APIs throughout code shared by CoreCLR and NativeAOT. Keep timing implementation dependencies out of shared declarations so NativeAOT does not pull in libc++ formatting support. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 99f3f0fa-70d4-4920-a0e5-798643faac81
Restore all CoreCLR-only implementation changes. Give NativeAOT lightweight logging and internal-pinvoke headers through its existing include-path precedence, and update only host code compiled by both runtimes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 99f3f0fa-70d4-4920-a0e5-798643faac81
Keep the NativeAOT logging header limited to the printf-style declarations and log bounded shared messages directly with a precision specifier. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 99f3f0fa-70d4-4920-a0e5-798643faac81
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
Review summary
No actionable findings in the changed native host code. The NativeAOT compatibility headers and shared printf-style logging changes preserve the existing CoreCLR behavior and keep the host-specific include-path split intact.
CI is still in progress; all completed checks observed so far are passing.
Generated by Android PR Reviewer for #12446 · gpt56 · 141.2 AIC · ⌖ 17.3 AIC · ⊞ 25.7K
Comment /review to run again
Summary
Remove
<format>from the Android NativeAOT host compilation without changing CoreCLR-only implementations or introducing astring_viewlogging surface.This is the next implementation step from #12139. Code compiled by both NativeAOT and CoreCLR uses the existing printf-style logging APIs, while CoreCLR-specific code keeps its current
std::formatimplementation for the later libc++ removal effort.Changes
string_viewlogging overload;HostCommoninstead of the CoreCLR-specificHostdeclaration;No CoreCLR-only implementation files differ from
main, and the PR introduces no newstring_viewusage.Validation
<format>header;to_chars, locale, or charconv symbols;