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
Custom ILLinker substitutions for feature switches don't seem to work on .NET 8 #88015
I've just enabled proper trimming of custom feature switches in ComputeSharp (Sergio0694/ComputeSharp#532), and wanted to check the difference on .NET 8 as well to see how it compared to .NET 7 with the feature switches set or not. It seems however that they're not really working on .NET 8, for some reason. If I'm doing something wrong, I'm not sure I'm seeing what that is 😅
Note: I'm testing specifically with NativeAOT, didn't check with just trimming without AOT.
Check the size of the resulting published binary 2️⃣
Expected behavior
I would expect the size of the first binary to be a bit smaller than that of the second binary.
When building with .NET 7, from main, this is exactly what I'm getting.
These are my results on main with .NET 7:
RuntimeHostConfigurationOption-s
x64 binary size
Yes
1.643 KB
No
1.710 KB
Getting about 70 KB of binary size savings, which is nice.
Actual behavior
On .NET 8, doing the steps above, I'm getting this:
RuntimeHostConfigurationOption-s
x64 binary size
Yes
1.587 KB
No
1.587 KB
...? Have there been any changes around runtime configuration options that I was expected to do? 🤔
This should work (we have tests and we rely on this working in many places) but either the resource is not embedded properly, the XML is not correct, or the switch is not getting passed to the compiler. I always need to debug the compiler whenever I do something with these XMLs because the format and mechanism is inscrutable. This is not a publicly supported mechanism because the developer experience around this mechanism is horrible and not self-serviceable. Moving to future.
Ok well, this was indeed just my fault — I had forgotten to update the MSBuild condition for .NET 8, so the ILLinker.Substitutions.xml file was not being embedded on that branch, as it was still just checking for .NET 6 😅
Re-did the tests after fixing that and I can confirm it works just fine, and saves ~73 KB 😄
Activity
teo-tsirpanis commentedon Jun 25, 2023
Can you verify through the MSBuild binary log that the configuration options are passed to the linker?
kant2002 commentedon Jun 25, 2023
The ILLink target no longer run
runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
Line 30 in 0633ecf
This was introduced in #63914
filipnavara commentedon Jun 25, 2023
The switches are interpreted by ILCompiler though and there should be parity in the observed behavior.
Sergio0694 commentedon Jun 25, 2023
Also — that PR (#63914) seems to have been merged in January 2022, so wouldn't that be in .NET 7 as well? 🤔
MichalStrehovsky commentedon Jun 26, 2023
This should work (we have tests and we rely on this working in many places) but either the resource is not embedded properly, the XML is not correct, or the switch is not getting passed to the compiler. I always need to debug the compiler whenever I do something with these XMLs because the format and mechanism is inscrutable. This is not a publicly supported mechanism because the developer experience around this mechanism is horrible and not self-serviceable. Moving to future.
Sergio0694 commentedon Jun 26, 2023
Ok well, this was indeed just my fault — I had forgotten to update the MSBuild condition for .NET 8, so the
ILLinker.Substitutions.xmlfile was not being embedded on that branch, as it was still just checking for .NET 6 😅Re-did the tests after fixing that and I can confirm it works just fine, and saves ~73 KB 😄