[NativeAOT] Migrate runtime utility logging to printf#12148
Open
simonrozsival wants to merge 3 commits into
Open
[NativeAOT] Migrate runtime utility logging to printf#12148simonrozsival wants to merge 3 commits into
simonrozsival wants to merge 3 commits into
Conversation
Convert NativeAOT-reachable environment, file, mmap, and shared-host diagnostics to the printf helpers introduced by #12140. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f63eb7-6599-414c-a947-d860705aa0fa
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the NativeAOT libc++ reduction work by migrating remaining formatted logging in NativeAOT-reachable shared runtime utilities away from std::format/{}-style logging and onto the printf-checked log_*f() and Helpers::abort_applicationf() APIs introduced in the stacked dependency PR #12140.
Changes:
- Convert runtime utility and environment diagnostics to
log_*f()with bounded%.*sforstd::string_viewand null-safeoptional_string()forconst char*. - Replace a fatal
mmap()failure path’sstd::formatallocation withHelpers::abort_applicationf()and migrate detailed mmap diagnostics to printf formatting. - Migrate Android system-property and shared host (JNI class-name lookup) diagnostics to
log_*f()with correct format specifiers.
Show a summary per file
| File | Description |
|---|---|
| src/native/clr/runtime-base/util.cc | Migrates directory creation, fopen, and chmod/fchmod error logging to log_*f(). |
| src/native/clr/runtime-base/android-system-shared.cc | Migrates system property warnings and max-gref override diagnostics to log_warnf() with correct size_t/long formats. |
| src/native/clr/include/runtime-base/util.hh | Migrates env-var and mmap-related diagnostics to log_*f() / abort_applicationf(), using bounded %.*s formatting. |
| src/native/clr/host/host-shared.cc | Migrates Java class-name lookup failures to log_errorf() (including %p). |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 0
This was referenced Jul 17, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f63eb7-6599-414c-a947-d860705aa0fa
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f63eb7-6599-414c-a947-d860705aa0fa
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.
Summary
Continue the printf-style native logging migration started by #12140.
This stacked PR converts formatted logging in NativeAOT-reachable shared runtime utilities to the
log_*f()andHelpers::abort_applicationf()APIs introduced by #12140, avoiding additionalstd::formatinstantiations in those paths.Base/dependency: #12140 must merge first. This PR targets
dev/simonrozsival/nativeaot-printf-loggingrather thanmainso its diff contains only this second-stage migration.Part of #12139.
Scope
The change is deliberately limited to four files that are compiled into the Android NativeAOT host:
src/native/clr/include/runtime-base/util.hhsrc/native/clr/runtime-base/util.ccsrc/native/clr/runtime-base/android-system-shared.ccsrc/native/clr/host/host-shared.ccThese files do not overlap the currently open sibling work:
Changes
Runtime and environment utilities
fopen,chmod, andfchmoddiagnostics to printf-style logging;std::string_viewoutput through%.*s;optional_string().Memory-mapped APK diagnostics
std::formatallocation in the fatalmmap()error path withHelpers::abort_applicationf();%p,%zu,%d, and%.*sformatting;std::string_viewis NUL-terminated.Android system properties
size_tformat;debug.mono.max_grefcvalues while preserving the compile-time property-name length;longformat.Shared host diagnostics
Formatting and behavior preservation
%pand are explicitly passed asvoid*;size_tuses%zu,longuses%ld, and descriptors use%d;%.*swith an explicit length;Non-goals
os-bridge.cc; that path also writes the formatted text to files and needs a separate design.std::formatuse in one change.Validation
git diff --check;std::string_viewlengths, pointer conversions, category semantics, and varargs use.The higher-level native project builds were also attempted, but the local Gradle 9.4.1 distribution failed while starting the unrelated
manifestmergerbuild, before native compilation. The direct checks above use the repository-generated production NDK compile commands and generated headers.