-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use ccache for emscripten library build #25392
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
39d2b25
Try ccache for lib build
dschuff 68d1165
smaller build
dschuff 3bc90a5
absolute directory, print stats, restore cache
dschuff 7e6a05f
use a new key
dschuff 7f32ac3
rename phase
dschuff 4312b65
fix env var
dschuff 7ae8ffd
debug ccache
dschuff 6fe5544
unset CCACHE_DIR
dschuff 8156345
name restore step
dschuff 010f7a2
bigger test
dschuff 98ffe31
rename
dschuff 54d3efc
restore all steps
dschuff cf6fe42
cache based on clang version
dschuff eaf7d42
remove extraneous change
dschuff 588b0f8
zero the stats before persisting the cache
dschuff be30413
conditionalize main vs PR
dschuff 50466f5
do a minimal build
dschuff a408894
try it with named branch
dschuff 0ec58b1
try with repo match
dschuff e22c0f2
update condition
dschuff 831178e
switch event
dschuff 6ee7b08
use name
dschuff 9a5f05a
undo temporary changes
dschuff 048bdf4
Merge branch 'main' into ccache-libs
dschuff 1ec1225
update condition
dschuff 4f7de3d
use PR_NUMBER
dschuff c79c297
use not-main
dschuff 1756551
remove debug prints
dschuff e9ad070
fix posixtestsuite
dschuff dfb4244
remove unnecessary condition, and add comment
dschuff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule posixtestsuite
updated
5 files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is enough. I know that @juj had a custom patch for ccache and added a specific
_EMCC_CCACHE
feature to support it. See #13681There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I saw that but I don't really see why it's necessary. I figured I'd try the easy thing first, and if it looks like it works, dig more into that. It may be that since we just want to use it for library compilation, it's enough.
@juj can you say more about why you wanted ccache to wrap the entire emscripten driver rather than just the underlying clang?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @dschuff is trying to integrate ccache in another way: in the backend between emcc and clang.
My emsdk support is placed in
user -> ccache -> emcc -> clang
. This looks like is doinguser -> emcc -> ccache -> clang
.Would be fantastic to see what the performance difference of this approach ends up being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance-wise, the main difference would obviously be that we still have to run all the python code of the driver. Since this is a compile and not a link, there's not a huge amount of stuff that gets done, but certainly there's a little cost. Probably the builtin profiling support could estimate how much. But mostly I just picked this way because I didn't want to bother with a fork of ccache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason was performance. Then it would also work for final link, and e.g. wrap over binaryen invocations of wasm-opt and so on.
However I have to say that in my approach, I found performance gains to be very small, so we didn't end up deploying it at Unity. I do have an itch to re-try though, and see if I could optimize the ccache implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, @juj, we are trying this out as way to speed up our CI here in circleci. Currently there is no caching so each needs to build everything from scratch.
We are looking at some kind of shared cache in combination with
heuristic_clear_cache.py
, or maybe just relying on ccache to notice when llvm changes.BTW, how do your building handle LLVM changes? I guess you somehow clobber the build when llvm changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I was under the impression that ccache doesn't work for linking or other cases that aren't basically just source -> object file. It just falls back to the underlying compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My ccache port looked at git hash if it was detected (developer installation), or if not, then emscripten-version.txt.
Additionally the contents of EM_CONFIG was hashed into the state.
The implementation can be seen here: ccache/ccache@master...juj:ccache:emscripten
Err actually, now that I scan through my fork, I think you are right: ccache does not cache link commands, only compile commands. So my fork didn't end up helping cache any wasm-opt calls either.
I haven't worked on the ccache fork in a while now - it looks like something has changed in CMake that it does not build with CMake >= 4 anymore. So it would need some freshening to bring up to speed again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My plan is to just key on the git version of clang or the emsdk installed by CI. Since I'm just trying to cache clang's output and not emscripten's, I think everything should be included in the clang version, the flags, the file inputs (i.e. the headers and sources).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't currently actually know whether ccache automatically takes the compiler version into account or not, but in order to have CircleCI automatically save and restore the cache across builds, I have to give it a cache key anyway.