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

Add precached LTO variants of libraries #67

Closed
RReverser opened this issue May 11, 2020 · 7 comments
Closed

Add precached LTO variants of libraries #67

RReverser opened this issue May 11, 2020 · 7 comments

Comments

@RReverser
Copy link

I've noticed that, when building with LTO (most of my projects), the standard libraries are rebuilt on each invocation of docker run. This is noticeable from logs e.g.:

cache:INFO: generating system library: libc-wasm.a... (this will be cached in "/emsdk_portable/.data/cache/wasm-lto/libc-wasm.a" for subsequent builds)

At the same time, /emsdk_portable/.data/cache/wasm are available within the container.

It appears that the reason is that images are shipped with standard C / C++ libraries precompiled and cached as part of the image, but only without LTO flag (LTO uses LLVM IR bitcode as object files, so has to be compiled separately).

Would it be possible to add LTO variants too?

@trzecieu
Copy link
Owner

I think so! Good idea!

@trzecieu
Copy link
Owner

trzecieu commented Jun 3, 2020

Hi, I see that there is an attempt in your case to create a new cache entry under wasm-lto but I have a difficult to reproduce it. Simple command doesn't work.

em++ test.cpp -flto -o test.js -s WASM=1

Is it possible for you to share compilation flags?

@trzecieu
Copy link
Owner

trzecieu commented Jun 4, 2020

I've addressed blindly this issue in the commit ec1eaff, I will update images soon with that change.

@RReverser
Copy link
Author

em++ test.cpp -flto -o test.js -s WASM=1

Hmm, I'll need some time to get around but could you try adding optimisation and/or debug flags?

@trzecieu
Copy link
Owner

trzecieu commented Jun 4, 2020

I've tested a various of flags under 1.39.5 - nothing has worked unfortunately.
Some images have been already updated with precompiled LTO, i.e:

@RReverser
Copy link
Author

Ah, it probably depends on contents of your test.cpp and which libraries end up being linked. If it's not using the standard library, it might be skipping these compilations altogether.

as I've found that this emscripten-core/emscripten#10603 might be related

Unlikely - that issue is just about size inefficiency, which is not very related.

@trzecieu
Copy link
Owner

trzecieu commented Jun 4, 2020

So I've added a bunch of most common libs to cache with lto, please check if something missing I can add explicitly to the list : )

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants