-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
NativeAOT: Quote whole commands to make it easier to consume linker args by Xamarin #88294
Conversation
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsWorkaround for xamarin/xamarin-macios#18531. I realise it's fragile, the general integration issues are tracked in #87187.
|
Is this going to reintroduce problem fixed by #87669 ? |
@MichalStrehovsky Thoughts on how to handle this? |
I don't know. I don't even understand what the problem was that I fixed in #87669. The quoting is all very confusing even without Xamarin rewriting in the picture. I don't understand the transformation Xamarin is doing there. It feels like the real solution would be to extract the NativeAOT-common linker args into some separate ItemGroup that Xamarin can consume. I doubt Xamarin wants us to control the RPath to begin with, so that would take care of this specific argument. |
Both ILC and Xamarin linker step have the linker arguments as ItemGroup. The difference is that Xamarin expect to do the quoting itself for each item, while ILC expects the content of each item to be already quoted. Ideally we would unify the approach since the transformation between these two is painful and error prone. |
I agree that unifying the approaches for quoting would be desirable. Using Xamarin's approach will also solve make sure there aren't any issues with paths with spaces (because we don't do any parsing, we only quote when needed). For instance this doesn't work if there's a space in any of the paths in @(NativeLibrary): |
Which There's name of the object file (we have that in a property). Then there's the .a libraries that are our implementation details. We have those in an itemgroup. Then there's list of Apple frameworks we need - those are also in itemgroups. I'm wondering if we could construct the linker command line on the Xamarin side from these, without having to hardcode NativeAOT implementation details (the fact that we depend on "some native libraries" and "some frameworks" from an ItemGroup would be fine to hardcode and we can leave a comment on the ItemGroup that this is now a contract). We could put the really odd ones like |
IMHO it's the other way around: which linker flags does NativeAOT require? I'm assuming all of the linker flags in LinkerArgs - because if there's a LinkerArgs that's not needed, then why's it in LinkerArgs in the first place? |
There's a whole category of switches that are needed for compliance - I assume if Xamarin runs the same compliance tooling these would be already present for the non-NativeAOT scenarios and can be reused. Such as: runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets Lines 139 to 145 in bb69c0b
Then we have switches that kind of make sense for the embedded to control, since we don't control where native dependencies go to in Xamarin scenarios, like the rpath parameter this PR is touching. I don't really see much else than these categories. Most of the extra switches are excluded for Apple platforms. Maybe we're really only talking about the categories I enumerated above. |
I just realized the compliance ones are also excluded on apple and nobody probably ran binskim on apple executables to see what is the compliance requirement there (if binskim even supports macho) |
So I looked at the effective list of things in LinkerArg we're ending up with for a console app (so that I don't need to decypher it from .targets). Here's the full list that I broke down into categories: 1. Things that are implementation details needed by NativeAOT:
2. Things that Xamarin would want to control and we should not really be passing when invoked as part of Xamarin build
3. Things that are common sense and Xamarin would probably already include when people want debuggable code.
So basically we're only talking about category 1 above. Things in category 1 are mostly already exposed in other properties/ItemGroup. I would be happy to make those part of the official protocol instead of the The items are (in order):
@filipnavara is there any chance the THUNKS could live in the TEXT section so that we don't need the extra linker argument? If not, it's not a huge problem, we could introduce a It is possible to construct a linker command line from this on the Xamarin side and I think this protocol is much cleaner - it avoids the issue with quoting or the |
Unfortunately not. The DATA and TEXT parts of THUNKS have to be next to each other in the final executable, and there's no way to guarantee that with TEXT section since its contents are linked together from multiple object files. |
That would be great! |
Ok, took at shot at this in #89916. |
Closing since we shouldn't need this after #89916. We may also be able to close #87187 and xamarin/xamarin-macios#18531. |
Workaround for xamarin/xamarin-macios#18531. I realise it's fragile, the general integration issues are tracked in #87187.