You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iOS (and other Apple platforms): the BCL has P/Invokes to libraries and/or functions that don't exist #47533
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.
Numerous references to functions in libSystem.Globalization.Native.dylib of the form GlobalizationNative_*. I believe this is because of pending work (issue #?)
System.Security.Cryptography.Algorithms.dll
Library: libSystem.Security.Cryptography.Native.Apple.dylib Function: AppleCryptoNative_EccGenerateKey
❌ The function AppleCryptoNative_EccGenerateKey does not exist in libSystem.Security.Cryptography.Native.Apple.dylib
Regarding ReadFile pinvoke to kernel32.dll in System.Reflection.Metadata.dll - built for the apple mobile targets (e.g. using ./build.sh --arch x64 --os tvossimulator --configuration Release), this assembly doesn't contain any invocation of Interop.Kernel32.ReadFile
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.
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 net6.0. We still have it for netstandard1.1 and netstandard2.0 where there is no Stream.Read(Span<byte>) which could be used instead
@rolfbjarne do you have any info on where you were getting the Readfile pinvoke error from?
I ran my script again (on 6.0.0-preview.7.21324.1), and it only reports issues in System.Private.CoreLib.dll (full results).
There are numerous P/Invokes to GlobalizationNative_* functions in a libSystem.Globalization.Native.dylib, but there's no libSystem.Globalization.Native.dylib.
Two functions from libhostpolicy.dylib (corehost_resolve_component_dependencies and corehost_set_error_writer), but there's no libhostpolicy.dylib.
There are numerous P/Invokes to GlobalizationNative_* functions in a libSystem.Globalization.Native.dylib, but there's no libSystem.Globalization.Native.dylib.
That library is supposed to exist. Can you double check what is going on please? It may be a packaging issue.
Two functions from libhostpolicy.dylib (corehost_resolve_component_dependencies and corehost_set_error_writer), but there's no libhostpolicy.dylib.
There are numerous P/Invokes to GlobalizationNative_* functions in a libSystem.Globalization.Native.dylib, but there's no libSystem.Globalization.Native.dylib.
That library is supposed to exist. Can you double check what is going on please? It may be a packaging issue.
Yeah, that is strange.
Are we going to need to do something about ReadFile for older versions?
Activity
bartonjs commentedon Jan 27, 2021
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.
11 remaining items
MaximLipnin commentedon Jun 28, 2021
Regarding
ReadFilepinvoke tokernel32.dllinSystem.Reflection.Metadata.dll- built for the apple mobile targets (e.g. using./build.sh --arch x64 --os tvossimulator --configuration Release), this assembly doesn't contain any invocation ofInterop.Kernel32.ReadFilesteveisok commentedon Jun 28, 2021
@rolfbjarne do you have any info on where you were getting the Readfile pinvoke error from?
filipnavara commentedon Jun 29, 2021
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.
adamsitnik commentedon Jun 29, 2021
This is correct, I've removed it in #50367 for
net6.0. We still have it fornetstandard1.1andnetstandard2.0where there is noStream.Read(Span<byte>)which could be used insteadrolfbjarne commentedon Jun 29, 2021
I ran my script again (on
6.0.0-preview.7.21324.1), and it only reports issues in System.Private.CoreLib.dll (full results).GlobalizationNative_*functions in alibSystem.Globalization.Native.dylib, but there's nolibSystem.Globalization.Native.dylib.corehost_resolve_component_dependenciesandcorehost_set_error_writer), but there's nolibhostpolicy.dylib.filipnavara commentedon Jun 29, 2021
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.
steveisok commentedon Jun 29, 2021
Yeah, that is strange.
Are we going to need to do something about
ReadFilefor older versions?rolfbjarne commentedon Jun 29, 2021
Not for now at least, if it becomes a problem we can have a look at it later.
akoeplinger commentedon Jun 29, 2021
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
but I'm wondering how it works there since that doesn't change the dllimport itself. edit: wasm is statically linking all libraries and uses https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs to patch up the dllimportsfilipnavara commentedon Jul 20, 2021
Is there anything left to be done for this issue?
steveisok commentedon Jul 20, 2021
I don't think so. @rolfbjarne ?
rolfbjarne commentedon Jul 20, 2021
I don't think so either.