-
Notifications
You must be signed in to change notification settings - Fork 282
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
Reflection-free mode support #1047
Comments
Can you give me a sqlclient only repro including the incantations needed to get it compiled to aot and failing? with that I can investigate what reflection is being used for and either make it static or identify the required linker hints. |
@kant2002 thanks for reaching out to us here. Enhancements are based on popularity of the matter. We have more urgent/requested issues or enhancements to solve at the moment. I cannot provide a timeframe on this topic until it becomes a popular/requested item in the community. We will look into this in future. @Wraith2 I really appreciated your offer. If you can take over this based on a provided application we can go over the PR and merge it if it has no conflicts with other in progress PRs or future plans. Thanks. |
Hi @kant2002 A repro would definitely be helpful to understand gaps for Native AOT compilation support but I'm thinking one of the reasons it's failing is due to our Native C++ DLL dependency on Windows (SNI DLLs). As mentioned in documentation for ReadyToRun compilation, C++/CLI binaries are not eligible. |
As the author of the original issue in dotnet/aspnetcore#31561 (comment) I have created a repository https://github.com/LLT21/NativeSQL. Please add in the ConnectionStrings.cs class 2x the database with user and password you can connect to (for the odbc, the driver has to be installed): https://github.com/LLT21/NativeSQL/blob/1d074421a6772176adce97140745e2f2b2e4c11e/ConnectionStrings.cs#L5. In the main program.cs change 2x the table name in: https://github.com/LLT21/NativeSQL/blob/1d074421a6772176adce97140745e2f2b2e4c11e/Program.cs#L23 and Also in the main program.cs change 2x the column name in: Luc |
The error I receive at native execution is: Michal Strehovsky has helped a lot in solving these kind of issues in the aspnetcore https call |
The repro works (in that it fails with that same message) for me. I can also confirm that the Interestingly when i tried it with debug mode the ILCompiler crashed using
And I don't know if I should bother opening an issue for that in runtime since it's with the latest net6 preview tooling @MichalStrehovsky ? |
The first problem is strings from embedded resources. We're using standard framework provided ResourceManager so I think that the advice from the aspnet thread about adding in a property called Another problem is going to be that I think it's going to be trying to use GlobalizationInvariant mode and this library does not and cannot support that mode. We need to be able to load culture specific comparers to correctly decode strings coming from the server using their marked collation. |
That's probably dotnet/runtimelab#1027. It should be fixed now. Note that this is for the very experimental reflection free mode which is more of a tech demo than anything else. Reflection is not a problem for AOT (not more than for trimming in general), except for these obscure modes. |
Ok, if it's still WIP I'll leave alone. I've resolved the embedded resource issue and it's probably worth merging that code into SqlClient anyway so that it'll can work in future, it's not harmful to be included. I've also found that we're going resource loading wrong through the entire library. We use the compiler generated strongly typed accessor to lookup the string and then pass that string to GetFormattedString which attempts to lookup the string as if it were a key when in fact it's already the value. I can address that in a PR as well. I am still interested in this mode though because while it probably won't work because we use GetType() it currently won't open a connection and it doesn't crash, it just hangs with a native thread in FinalizerHelpers.cpp StartFinalize (i think) and I don't think that's right. |
If you consider not only no-reflection mode, current incarnation of SqlClient adds ~33Mb to the produced executable. This is maybe not an issue per-se, but can hint you in parts which are not very optimal and have too much dependencies on each other |
I noticed that the produced binary was very large. But then it's a runtime-less single executable so it contains dependencies from the runtime as well. There are things like the globalization data which is 10Mib of icu data that can't be removed. I haven't worked with AOT or trimming so it will take a while for me to get the hang of the process and tooling but I'll keep looking at it. Just don't expect quick results. |
I'm willing to spend some time into that too. If this project would be accepting discussion on that matter, I more then happy to help. |
Currently Microsoft.Data.SqlClient cannot work when compiled in NativeAOT and Reflection-Free mode.
dotnet/aspnetcore#31561 (comment)
Would be good that this library would be more friendly for this kind of scenarios.
The text was updated successfully, but these errors were encountered: