dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.43k stars 200 forks source link

Question: NativeAOT-LLVM: PublishTrimming= true would be advantageous #1998

Closed yowl closed 11 months ago

yowl commented 2 years ago

Is this a similar optimisation to LLVM Link Time Optimisation (LTO)?

From emscripten's web page

https://emscripten.org/docs/optimizing/Optimizing-Code.html


LTO

Link Time Optimization (LTO) lets the compiler do more optimizations, as it can inline across separate compilation units, and even with system libraries. LTO is enabled by compiling objects files with -flto. The effect of this flag is to emit LTO object files (technically this means emitting bitcode). The linker can handle a mix wasm object files and LTO object files. Passing -flto at link time will also trigger LTO system libraries to be used.

Thus, to allow maximal LTO opportunities with the LLVM wasm backend, build all source files with -flto and also link with flto.

Currently PublishTrimming is broken in the NativeAOT-LLVM targets. User reports that possibly this is because it is being done at the wrong stage.

jkotas commented 2 years ago

PublishTrimming is done implicitly by the native AOT compiler (ilc.exe). It does not require an extra step.

If you see PublishTrimming property not behaving as expected, it can be possibly due to msbuild targets in this branch being out of sync with the current .NET SDK.