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

dllmap for native libraries shipped with .NET #10950

Closed
rolfbjarne opened this issue Mar 24, 2021 · 0 comments · Fixed by #12323
Closed

dllmap for native libraries shipped with .NET #10950

rolfbjarne opened this issue Mar 24, 2021 · 0 comments · Fixed by #12323
Assignees
Labels
dotnet An issue or pull request related to .NET (6) dotnet-pri0 .NET 6: required for stable release feature A feature to be implemented
Milestone

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented Mar 24, 2021

Now that we've added support for PINVOKE_OVERRIDE (#10504), we have to look into this to see if something needs to be done:

if (app.MonoNativeMode != MonoNativeMode.None) {
#if NET
// Mono doesn't support dllmaps for Mac Catalyst / macOS in .NET for now:
// macOS: https://github.com/dotnet/runtime/issues/43204
// Mac Catalyst: https://github.com/dotnet/runtime/issues/48110
var addDllMap = App.Platform != ApplePlatform.MacCatalyst && app.Platform != ApplePlatform.MacOSX;
#else
var addDllMap = true;
#endif
if (addDllMap) {
string mono_native_lib;
if (app.LibMonoNativeLinkMode == AssemblyBuildTarget.StaticObject)
mono_native_lib = "__Internal";
else
mono_native_lib = app.GetLibNativeName () + ".dylib";
sw.WriteLine ();
sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Native\", NULL, \"{mono_native_lib}\", NULL);");
sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Security.Cryptography.Native.Apple\", NULL, \"{mono_native_lib}\", NULL);");
sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Net.Security.Native\", NULL, \"{mono_native_lib}\", NULL);");
sw.WriteLine ();
}
}

@rolfbjarne rolfbjarne added dotnet An issue or pull request related to .NET (6) dotnet-pri0 .NET 6: required for stable release feature A feature to be implemented labels Mar 24, 2021
@rolfbjarne rolfbjarne added this to the .NET 6 milestone Mar 24, 2021
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Jul 26, 2021
…ng statically. Fixes xamarin#10950, xamarin#11145 and xamarin#12100.

* Add support for Mono Components.

* Modifies how we look up symbols from native libraries shipped with Mono:

This also meant propagating how libmono is linked from the MSBuild code to the Application
class so that our existing logic is able to correctly determine which native mono
lib to use.

Fixes xamarin#10950.
Fixes xamarin#11145.
Fixes xamarin#12100.
@rolfbjarne rolfbjarne self-assigned this Jul 27, 2021
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Aug 2, 2021
…ng statically. Fixes xamarin#10950, xamarin#11145 and xamarin#12100.

* Add support for Mono Components.

* Modify how we look up symbols from native libraries shipped with Mono: we keep
  track of which native libraries we linked with, and depending on how we linked
  to those assemblies, we look the symbols up at runtime in either the current executable
  (if linking statically), or the actual library (where the P/Invoke says they're
  supposed to be).

* This means that we have to propagate how libmono is linked from the MSBuild code
  to the Application class so that our existing logic is able to correctly determine
  which native mono lib to use.

* Modify how we list the P/Invokes we need to preserve by taking into account the
  list of native libraries from Mono we have to link with (for .NET). For legacy
  Xamarin, I've reverted the logic to how it was before we started adding .NET support.

Fixes xamarin#10950.
Fixes xamarin#11145.
Fixes xamarin#12100.
rolfbjarne added a commit that referenced this issue Aug 3, 2021
…ng statically. Fixes #10950, #11145 and #12100. (#12323)

* Add support for Mono Components.

* Modify how we look up symbols from native libraries shipped with Mono: we keep
  track of which native libraries we linked with, and depending on how we linked
  to those assemblies, we look the symbols up at runtime in either the current executable
  (if linking statically), or the actual library (where the P/Invoke says they're
  supposed to be).

* This means that we have to propagate how libmono is linked from the MSBuild code
  to the Application class so that our existing logic is able to correctly determine
  which native mono lib to use.

* Modify how we list the P/Invokes we need to preserve by taking into account the
  list of native libraries from Mono we have to link with (for .NET). For legacy
  Xamarin, I've reverted the logic to how it was before we started adding .NET support.

Fixes #10950.
Fixes #11145.
Fixes #12100.
@ghost ghost locked as resolved and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dotnet An issue or pull request related to .NET (6) dotnet-pri0 .NET 6: required for stable release feature A feature to be implemented
Projects
None yet
1 participant