emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.83k stars 3.31k forks source link

Build Emscripten with PGO #19671

Open zamazan4ik opened 1 year ago

zamazan4ik commented 1 year ago

Hi!

Clang supports building with Profile-Guided Optimization (PGO), and it helps with achieving +20% compilation speed. I think would be a good idea to try to build Emscripten itself with PGO. I've performed searching across the repository about it but didn't find the results. If you already have any - please share them with me.

Thanks in advance!

sbc100 commented 1 year ago

When you say "Emscripten itself" I assume you mean the llvm and binaryen binaries?

We currently build them with LTO and but not PGO. We don't do anything special when building llvm or binaryen so I assume any options for using PGO in CMake projects would work as expected, but I've never done it myself.

zamazan4ik commented 1 year ago

When you say "Emscripten itself" I assume you mean the llvm and binaryen binaries?

Yes.

We currently build them with LTO and but not PGO. We don't do anything special when building llvm or binaryen so I assume any options for using PGO in CMake projects would work as expected, but I've never done it myself.

Well, LLVM-provided multistage CMake scripts are designed specifically for Clang. So in general you cannot easily just use them. Anyway, I guess would be quite easy try to adopt them to binaryen.

sbc100 commented 1 year ago

When you say "Emscripten itself" I assume you mean the llvm and binaryen binaries?

Yes.

We currently build them with LTO and but not PGO. We don't do anything special when building llvm or binaryen so I assume any options for using PGO in CMake projects would work as expected, but I've never done it myself.

Well, LLVM-provided multistage CMake scripts are designed specifically for Clang. So in general you cannot easily just use them. Anyway, I guess would be quite easy try to adopt them to binaryen.

If your goal is faster compile times than I would start with llvm/clang. That should get you a lot of the benefits. I would get that working first before turning your attention to binaryen.