dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.37k stars 4.75k forks source link

[NativeAOT] Implement a compiler "optimize for application" switch analogous to /GA for MSVC #87642

Open VSadov opened 1 year ago

VSadov commented 1 year ago

The flag indicates that the compiled module is a singlefile executable and can drive some optimizations.

Single file executable is a common enough scenario that c++ compiler has a switch for it. ILC could benefit from such switch as well.

Re: https://github.com/dotnet/runtime/pull/87148#discussion_r1226018085

ghost commented 1 year ago

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas See info in area-owners.md if you want to be subscribed.

Issue Details
The flag indicates that the compiled module is a singlefile executable and can drive some optimizations. Single file executable is a common enough scenario that c++ compiler has a switch for it. ILC could benefit from such switch as well.
Author: VSadov
Assignees: -
Labels: `area-NativeAOT-coreclr`
Milestone: -
NCLnclNCL commented 1 year ago

The flag indicates that the compiled module is a singlefile executable and can drive some optimizations.

Single file executable is a common enough scenario that c++ compiler has a switch for it. ILC could benefit from such switch as well.

Re: #87148 (comment)

it will do reduce file size ??

VSadov commented 1 year ago

it will do reduce file size ??

Yes. linker can replace more complex code for the dynamic case with more efficient instructions if it is known at link time that we are linking an executable. However, the size redundancy will still be there.

The size difference would vary between platforms. On some platforms like linux-x64 the size difference is relatively small, but on others it would be more noticeable: See for example https://github.com/dotnet/runtime/pull/87148#discussion_r1234559333