Skip to content

Construct DSO names without local strings - #12515

Open
simonrozsival wants to merge 10 commits into
dev/simonrozsival/replace-simple-local-stringsfrom
dev/simonrozsival/simplify-dso-name
Open

Construct DSO names without local strings#12515
simonrozsival wants to merge 10 commits into
dev/simonrozsival/replace-simple-local-stringsfrom
dev/simonrozsival/simplify-dso-name

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

Remove CLR/NativeAOT local strings from DSO-name and path construction without introducing libc++ ownership or fixed-size limits.

Changes

  • centralize conditional lib prefix and .so suffix construction
  • make DSO-name and full-path formatters return the negative required capacity including NUL
  • retry through non-template helpers with explicit stack-buffer capacities
  • return either the caller's stack buffer or exact-size malloc() storage, with no heap out-parameters
  • free returned storage only when it differs from the caller-owned stack buffer
  • preserve the original separator insertion and P/Invoke name-normalization behavior

Validation

  • Local native builds intentionally skipped; relying on CI validation

Copilot AI lite review requested due to automatic review settings August 25, 2026 13:39

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

This PR factors out repeated DSO name normalization (optional lib prefix + mandatory .so suffix) into a shared helper and uses it in both CoreCLR DSO path construction and P/Invoke override loading to reduce duplicated string manipulation.

Changes:

  • Added Util::append_dso_name() helper to normalize DSO names (prefix/suffix).
  • Updated AndroidSystem::get_full_dso_path() to use the shared helper.
  • Updated P/Invoke override loading to use the shared helper when rewriting short library names.
Show a summary per file
File Description
src/native/clr/runtime-base/android-system.cc Uses shared helper for full DSO path construction while preserving rooted/path-qualified handling.
src/native/clr/include/runtime-base/util.hh Introduces shared helper for DSO name normalization.
src/native/clr/include/host/pinvoke-override-impl.hh Uses shared helper when rewriting [DllImport] names like log/liblog.

Review details

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

Comment thread src/native/clr/include/runtime-base/util.hh Outdated
@simonrozsival simonrozsival added the drop-libcpp Work to remove the libc++ dependency from Android NativeAOT label Aug 25, 2026
@simonrozsival simonrozsival changed the title Share DSO name construction Use fixed buffers for DSO name construction Aug 25, 2026
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 67f7f33 to 51ef76a Compare August 25, 2026 15:09
@simonrozsival
simonrozsival changed the base branch from main to dev/simonrozsival/replace-simple-local-strings August 25, 2026 15:10
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch 2 times, most recently from 355d3d7 to 4c9090e Compare August 25, 2026 15:35
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 4c9090e to 390be0f Compare August 25, 2026 15:42
@simonrozsival simonrozsival changed the title Use fixed buffers for DSO name construction Construct DSO names without local strings Aug 25, 2026
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 390be0f to 2a53b4d Compare August 25, 2026 15:54
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch 2 times, most recently from 2ea7b1e to 19e08dc Compare August 25, 2026 18:53
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 19e08dc to 821de28 Compare August 25, 2026 21:27
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 821de28 to 0c6fa97 Compare August 25, 2026 21:32
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 0c6fa97 to cc5e351 Compare August 25, 2026 21:41
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from cc5e351 to 7dc6df9 Compare August 25, 2026 21:51
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 7dc6df9 to 4e4a627 Compare August 25, 2026 22:23
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 4e4a627 to 67f2853 Compare August 26, 2026 07:34
simonrozsival and others added 10 commits August 26, 2026 15:13
Use one helper to conditionally add the lib prefix and .so suffix for runtime DSO lookup and P/Invoke override loading.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Return formatted DSO and lookup-path lengths through caller-owned buffers, removing the remaining local strings from both normalization paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve the unbounded behavior of dynamic local strings without introducing libc++ ownership.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Return the malloc-allocated joined path directly after releasing the temporary DSO name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Calculate complete DSO sizes first, use the sensible local buffer when possible, and allocate only larger names and paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Return the selected stack or heap buffer from DSO formatters and report the exact required capacity when local storage is too small.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rely on free(nullptr) and name stack-backed DSO storage explicitly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use non-template DSO helpers and make callers provide each stack buffer capacity.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove heap-buffer out parameters and free returned DSO strings only when they differ from their stack buffers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`get_full_dso_path` gained a second overload whose parameter list is
identical to the existing one and differs only in its return type, which is
not a valid overload.

Rename the raw `ssize_t` variant to `format_full_dso_path` and leave the
`char*` wrapper as the only `get_full_dso_path`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0a35a0db-502d-48c0-8468-e73b5dd0ab2e
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-dso-name branch from 67f2853 to c915f61 Compare August 26, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

drop-libcpp Work to remove the libc++ dependency from Android NativeAOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants