-
Notifications
You must be signed in to change notification settings - Fork 497
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
Use sccache to accelerate android build #9587
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/9587
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 3 Unrelated FailuresAs of commit 0ce7cc2 with merge base 7248b19 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
.github/workflows/_android.yml
Outdated
# Use sccache for NDK compiler as well | ||
export CMAKE_CXX_COMPILER_LAUNCHER=sccache | ||
export CMAKE_C_COMPILER_LAUNCHER=sccache |
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.
What are your thoughts on exporting this in .ci/scripts/setup-linux.sh so we get it for all CI builds?
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 would rely on https://github.com/pytorch/executorch/blob/main/.ci/docker/common/install_cache.sh#L47 to trigger sccache for general linux.
Seems that if I put these in https://github.com/pytorch/executorch/blob/main/.ci/scripts/setup-linux.sh, it will be used not only on android, but generic, and I would avoid doing that to mess up with the set up above.
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.
Generally, I'm hoping we can find one place to change and export these variables instead of multiple places. If someone adds another android job, they do not get caching if they forget these lines
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.
IMO, you could try the simpler fix to install NDK before sccache in https://github.com/pytorch/executorch/blob/main/.ci/docker/ubuntu/Dockerfile#L57-L83. We install sccache as part of building Docker image and /opt/cache/bin
is added to PATH in https://github.com/pytorch/executorch/blob/main/.ci/docker/common/install_cache.sh#L43. Atm, installing NDK happens after installing sccache, so I guess NDK path takes the priority?
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.
Sorry not sure if that's the situation here. Currently for android build, clang path is /opt/ndk/toolchains/llvm/prebuilt/...bin and we should not use /opt/cache/bin/clang (stub which points to the system clang)?
Basically for android, we need /opt/ndk/.../clang to point to a stub as well?
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.
Using a stub works transparently as part of the Docker image. Setting CMAKE_CXX_COMPILER_LAUNCHER
needs to be done later, i.e. people need to remember to set that explicitly.
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.
Honestly I feel like it's hard to do stub... In NDK we have so many variants of clang
armv7a-linux-androideabi21-clang i686-linux-android29-clang++ x86_64-linux-android21-clang
armv7a-linux-androideabi21-clang++ i686-linux-android30-clang x86_64-linux-android21-clang++
armv7a-linux-androideabi22-clang i686-linux-android30-clang++ x86_64-linux-android22-clang
armv7a-linux-androideabi22-clang++ i686-linux-android31-clang x86_64-linux-android22-clang++
armv7a-linux-androideabi23-clang i686-linux-android31-clang++ x86_64-linux-android23-clang
armv7a-linux-androideabi23-clang++ i686-linux-android32-clang x86_64-linux-android23-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.
@kirklandsign I think you can use $ANDROID_NDK/ndk-which clang to get the specific location
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.
@jathu I can have a try - just use clang
instead of these variants (which are basically for clang --target=x86_64-linux-android21
stuff)
I was just worried if somehow android NDK triggered clang
via x86_64-linux-android21-clang
not 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.
@huydhn @jathu I feel like for android it's still hard to get the stub working. See error like https://github.com/pytorch/executorch/actions/runs/14115338695/job/39544105035?pr=9587 for my version f2e12cb#diff-0a862d15a4e6dff44196719a594b983aece596c7dc38eba416d83e12a95206e6R92.
@@ -89,10 +89,26 @@ init_sccache() { | |||
as_ci_user sccache --zero-stats || true | |||
} | |||
|
|||
function write_android_sccache_stub() { | |||
BINARY=$1 | |||
mv "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$1" "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/.$1" |
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.
/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
Android didn't use sccache because it has its own NDK clang. Now use env var to trigger clang from sccache.