-
Notifications
You must be signed in to change notification settings - Fork 515
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
[dotnet] Prevent linking out code referenced by P/Invoke #10182
Conversation
A unit test like this should be adapted: xamarin-macios/tests/mtouch/MTouch.cs Lines 92 to 120 in 72c7b1f
|
@@ -89,6 +89,7 @@ protected override void TryProcess () | |||
Steps.Add (new ExtractBindingLibrariesStep ()); | |||
Steps.Add (new RegistrarStep ()); | |||
Steps.Add (new GenerateMainStep ()); | |||
Steps.Add (new GenerateReferencesStep ()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear in PR but it seems to be after sweeping/cleaning.
Do check that enabling the linker result in less generated symbols (to keep around)
build |
Build failure |
build |
Build failure Test results62 tests failed, 28 tests passed.Failed tests
|
build |
Build success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor things left, this is looking very good!
case SymbolMode.Linker: | ||
case SymbolMode.Default: | ||
foreach (var symbol in required_symbols) { | ||
var item = new MSBuildItem { Include = "-u" + symbol.Prefix + symbol.Name }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need a space here:
var item = new MSBuildItem { Include = "-u" + symbol.Prefix + symbol.Name }; | |
var item = new MSBuildItem { Include = "-u " + symbol.Prefix + symbol.Name }; |
although that might have to be treated as two different MSBuildItems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually checked it and the space is not necessary. In fact the space would create a problem because it would pass the whole thing quoted to the linker and the linker would expect the space to be part of the symbol name.
build |
Build failure Test results1 tests failed, 92 tests passed.Failed tests
|
The failed test is related:
The output suggests that it's indeed missing |
Not sure how to solve it. Seems like System.Net.Security.Native is missing from tvOS builds (https://github.com/dotnet/runtime/blob/3c39a5d3b8310d9adcb906718cf985d3e40122da/src/libraries/Native/Unix/CMakeLists.txt#L224) so the failure is somewhat warranted. I can place |
Something like this: case "System.Net.Security.Native":
#if NET
if (app.Platform == ApplePlatform.tvOS)
break; // tvOS does not ship with System.Net.Security.Native due to https://github.com/dotnet/runtime/issues/####
#endif basically file an issue and hide the problem (and add the issue to the list here: #8901) |
Done. You'll have to link dotnet/runtime#45535 in #8901 yourself since I cannot edit other people's issues :-) |
build |
Build success |
can someone from the xamarin team look at the https://github.com/xamarin/xamarin-macios/issues/10884 issue? |
Fixes running the following code:
which resulted into call to
xamarin_IntPtr_objc_msgSend_IntPtr
which was linked out from the native code.This adds a step to dotnet-linker that mimics what mmp/mtouch was doing. Depending on symbol mode setting it either generates: a) references.m file that contains code referencing all the P/Invoked symbols to prevent the native linker from linking them out, or b)
-u<symbol>
linker flags that mark the symbols to be preserved.