Skip to content

Handle 'lib' variants in ModuleNameVariations to generate DirectPInvokes#118285

Merged
jtschuster merged 8 commits intodotnet:mainfrom
jtschuster:DirectPInvokeLib
Aug 5, 2025
Merged

Handle 'lib' variants in ModuleNameVariations to generate DirectPInvokes#118285
jtschuster merged 8 commits intodotnet:mainfrom
jtschuster:DirectPInvokeLib

Conversation

@jtschuster
Copy link
Copy Markdown
Member

In ILC, when a DirectPInvokes item was prefixed with 'lib', it wouldn't recognize the library and wouldn't generate a direct pinvoke. There are a lot of places within the repo (and I assume other codebases) that use the 'lib' prefix in DirectPInvokes, so it seems to make more sense to handle that case rather than remove the prefix from all usages.

fixes #118284

@jtschuster jtschuster added this to the 10.0.0 milestone Aug 1, 2025
@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 1, 2025
@jtschuster jtschuster added area-NativeAOT-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Aug 1, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 fixes an issue where the ILC (ILCompiler) wasn't recognizing library names with the 'lib' prefix when generating DirectPInvokes. The fix enhances the ModuleNameVariations method to handle library name variations that include the common 'lib' prefix.

Key changes:

  • Added logic to detect and handle the 'lib' prefix in library names
  • Generate additional name variations by stripping the 'lib' prefix
  • Handle cases where both 'lib' prefix and shared library extensions are present

Comment thread src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs Outdated
Comment thread src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs Outdated
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jkotas
Copy link
Copy Markdown
Member

jkotas commented Aug 1, 2025

Drop the lib prefixes in https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets#L151 to make the msbuild targets simpler?

Comment thread src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets Outdated
Comment thread src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets Outdated
Comment thread src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets Outdated
@jtschuster jtschuster merged commit 1bfcb85 into dotnet:main Aug 5, 2025
90 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Aug 5, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ilc doesn't recognize library names prefixed with 'lib' for DirectPInvokes

3 participants