Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future of dllmap / NativeLibrary? #37084

Closed
TheSpydog opened this issue May 27, 2020 · 4 comments
Closed

Future of dllmap / NativeLibrary? #37084

TheSpydog opened this issue May 27, 2020 · 4 comments
Labels
area-System.Runtime.InteropServices question Answer questions and provide assistance, not an issue with source code or documentation. untriaged New issue has not been triaged by the area owner

Comments

@TheSpydog
Copy link
Contributor

I work on a game framework that makes use of Mono's dllmap feature for supporting varying native library names across different platforms. I've found the dllmap mechanism to be plenty sufficient for the needs of the project (and far simpler to use than .NET Core's NativeLibrary API), but I'm wondering how future-proof it is.

Since .NET Core 3.0 introduced NativeLibrary, and the Core and Mono runtimes are in the process of being unified for .NET 5+, is dllmap going to be removed from Mono in favor of NativeLibrary? Or will they coexist? Or will NativeLibrary be exclusive to .NET Core?

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Meta untriaged New issue has not been triaged by the area owner labels May 27, 2020
@filipnavara
Copy link
Member

filipnavara commented May 27, 2020

First of all, NativeLibrary works on all .NET 5 runtimes (CoreCLR, Mono and CoreRT). The Mono DllMap code is currently disabled in the .NET 5 code base.

I don't think there is concensus on whether the DllMap support will be re-enabled or not. It may still be useful for AOT compilation where the declarative approach can be evaluated at compile time easily. For CoreCLR there were originally plans to reimplement DllMap on top of NativeLibrary functionality but as far as I know they never materialized.

Note that it is possible to combine the loading flexibility of NativeLibrary with the traditional P/Invoke approach. For example, the System.Drawing.Common library does that.

@TheSpydog
Copy link
Contributor Author

TheSpydog commented May 27, 2020

First of all, NativeLibrary works on all .NET 5 runtimes (CoreCLR, Mono and CoreRT).

Ah, good to know!

I don't think there is concensus on whether the DllMap support will be re-enabled or not.

I'm curious why it wouldn't be re-enabled? CoreCLR I understand since the feature didn't exist in the first place, but for Mono, why remove something that's already implemented and is known to work?

For CoreCLR there were originally plans to reimplement DllMap on top of NativeLibrary functionality but as far as I know they never materialized.

That's a shame, having a built-in compatibility shim seems like a great solution.

@filipnavara
Copy link
Member

I'm curious why it wouldn't be re-enabled? CoreCLR I understand since the feature didn't exist in the first place, but for Mono, why remove something that's already implemented and is known to work?

Both the native library loading code and the assembly loading code was substantially reworked to align the behavior with CoreCLR and add support for the new APIs (NativeLoader, AssemblyLoadContext). It now follows the same file name fallback logic (eg. trying "lib" prefixes, ".dll"/".dylib"/".so" suffixes, "libc" fallback, etc.). The simple answer is that the baseline was to match CoreCLR APIs in this regard. Adding DllMap back into the mix would not be too difficult (in fact, it was already prototyped once) but the focus currently seems on getting all the libraries working perfectly on the new Mono runtime (https://github.com/dotnet/runtime/projects/48), especially on mobile platforms.

@AaronRobinsonMSFT AaronRobinsonMSFT added area-System.Runtime.InteropServices question Answer questions and provide assistance, not an issue with source code or documentation. and removed area-Meta labels May 28, 2020
@jkotas
Copy link
Member

jkotas commented May 31, 2020

Duplicate of #37213 that has more in-depth discussion on this topic.

@jkotas jkotas closed this as completed May 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime.InteropServices question Answer questions and provide assistance, not an issue with source code or documentation. untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

5 participants