-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
iOS (and other Apple platforms): the BCL has P/Invokes to libraries and/or functions that don't exist #47533
Comments
Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq Issue DetailsDescriptionThere are several DllImports in the BCL that references to native functions that don't exist. It's highly preferable to not have any P/Invokes to native functions that don't exist, because it allows the AOT compiler to generate more efficient code. It also makes other performance improvements possible.
This is from the microsoft.netcore.app.runtime.ios-arm64 pack (6.0.0-alpha.1.21063.13). Full output from custom tool I wrote: https://gist.github.com/rolfbjarne/b9a6f16d2a6697c0d8dfc46c39160404
|
Yeah, functions like that one are conditional: runtime/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/pal_ecc.c Lines 6 to 9 in 1d9e50c
Just means that the relevant Interop.cs is being included in the iOS build when it doesn't need to. |
Actually it's worse because in some cases the Interop code is called on the managed side and fails in very unpredictable fashion. This was one reported instance on Discord:
|
…en native libraries are dynamically linked
…en native libraries are dynamically linked
…en native libraries are dynamically linked
…en native libraries are dynamically linked
…es (#11158) * Workaround dotnet/runtime#47533 and avoid listing required symbols when native libraries are dynamically linked * Don't call LibMonoNativeLinkMode on macOS builds * Apply iOS workarounds also for tvOS and Mac Catalyst
@rolfbjarne do you have any info on where you were getting the Readfile pinvoke error from? |
System.Reflection.Metadata had a ReadFile call in one code path. I believe @adamsitnik removed it in one of the refactorings but it may still affect older NuGets. |
This is correct, I've removed it in #50367 for |
I ran my script again (on
|
That library is supposed to exist. Can you double check what is going on please? It may be a packaging issue.
Should be fixed by #54601. |
Yeah, that is strange. Are we going to need to do something about |
Not for now at least, if it becomes a problem we can have a look at it later. |
libSystem.Globalization.Native.dylib not existing is expected, the globalization PAL lib is statically linked into the runtime now since #44505. There's code in the runtime which hijacks the dllimport: https://github.com/dotnet/runtime/blob/main/src/mono/mono/metadata/native-library.c#L935-L941. On wasm we use NO_GLOBALIZATION_SHIM to skip that code |
Is there anything left to be done for this issue? |
I don't think so. @rolfbjarne ? |
I don't think so either. |
Description
There are several DllImports in the BCL for iOS (and the other Apple platforms) that contain references to native functions that don't exist. It's highly preferable to not have any P/Invokes to native functions that don't exist, because it allows the AOT compiler to generate more efficient code. It also makes other performance improvements possible.
System.Diagnostics.Process.dl
SystemNative_ConfigureTerminalForChildProcess
inlibSystem.Native.dylib
, butlibSystem.Native.dylib
doesn't provide that function. Tracked in Annotate APIs throwing PNSE on iOS/tvOS/MacCatalyst #47910System.Net.Quic.dll
MsQuicOpen
Library:libmsquic.dylib
System.Reflection.Metadata.dll
ReadFile
Library:kernel32.dll
System.Security.Cryptography.Algorithms.dll, System.Security.Cryptography.OpenSsl.dll and System.Security.Cryptography.X509Certificates.dll
libSystem.Security.Cryptography.Native.Apple.dylib
of the formAppleCryptoNative_*
orCryptoNative_*
. Tracked in Annotate APIs throwing PNSE on iOS/tvOS/MacCatalyst #47910System.Private.CoreLib.dll
libSystem.Globalization.Native.dylib
of the formGlobalizationNative_*
. I believe this is because of pending work (issue #?)libhostpolicy.dylib
(corehost_resolve_component_dependencies
andcorehost_set_error_writer
). This has also been reported in iOS (and other Apple platforms): System.Private.CoreLib.dll has P/Invokes to a libhostpolicy library that isn't shipped #38543.This is from the microsoft.netcore.app.runtime.ios-arm64 pack (6.0.0-alpha.1.21063.13).
Full output from custom tool I wrote: https://gist.github.com/rolfbjarne/b9a6f16d2a6697c0d8dfc46c39160404
The text was updated successfully, but these errors were encountered: