Skip to content
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

Wasm backend LTO docs and testing #8942

Merged
merged 3 commits into from
Jul 15, 2019
Merged

Wasm backend LTO docs and testing #8942

merged 3 commits into from
Jul 15, 2019

Conversation

kripken
Copy link
Member

@kripken kripken commented Jul 8, 2019

Documents the -flto and WASM_OBJECT_FILES=0 options, which are not identical as the latter also affects system libraries. Also document that --llvm-lto 1 is needed to actually run lto opts (otherwise we pass --lto-O0 to wasm-ld).

Add a test for -flto and WASM_OBJECT_FILES=0 emitting bitcode files as expected.

- The ``-flto`` flag tells the compiler to emit bitcode in object files, but does *not* affect system libraries.
- The ``-s WASM_OBJECT_FILES=0`` also flag tells the compiler to emit bitcode to object files, and also to use bitcode system libraries.

Thus, to allow maximal LTO opportunities with the LLVM wasm backend, build all source files with ``-s WASM_OBJECT_FILES=0`` and link with ``-s WASM_OBJECT_FILES=0 --llvm-lto 1``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK as a documentation of the existing status quo, but it's still pretty awkward and there are a lot of combinations of flags/behavior, not all of which are not useful. So it would be nice to simplify or line up with native a bit better. For example WASM_OBJECT_FILES is a legacy and it controls a lot of code that we can rip out once fastcomp is gone (we should be able to do what native platforms do and use lld to drive the LTO pipeline rather than driver code). Also if the only delta from -flto to NATIVE_OBJECT_FILES is that it also affects system libraries, then the name should reflect that, and it should only be required/allowed at link time. And --llvm-lto is a meaningless name when everything is done with LLVM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed about simplifying this stuff later, yes.

@kripken kripken merged commit 0b8ae39 into incoming Jul 15, 2019
@kripken kripken deleted the flto branch July 15, 2019 22:32
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
Documents the -flto and WASM_OBJECT_FILES=0 options, which are not identical as the latter also affects system libraries. Also document that --llvm-lto 1 is needed to actually run lto opts (otherwise we pass --lto-O0 to wasm-ld).

Add a test for -flto and WASM_OBJECT_FILES=0 emitting bitcode files as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants