Hello, I try to use PGO for my native applications on Android, but I can not find PGO profile raw file. Here is what I do:
The NDK Version is 22.1.7171670, Device API level is 30.
Adding -fprofile-generate to cpp flags.
Calling the __llvm_profile_write_file function before the end of workload.
However, after executing the app, no profile file named default_unique_id_0.profraw was found in /data/local/tmp on Android.
Although I set up LLVM_PROFILE_FILE env to /data/local/tmp, nothing happened.
Do I miss something? Looking forward to answering, thank you.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/78503996-6c41-4679-8209-dace5f09adb7n%40googlegroups.com.
On Fri, Dec 10, 2021 at 11:31 AM enh <e...@google.com> wrote:ah, thanks ... that probably explains what the submitter of https://github.com/android/ndk/issues/1622 (which i'm guessing is the same person as here) found confusing in the docs.i'll update the docs to explicitly point out that /data/local/tmp isn't usually accessible.+Pirama Arumuga Nainar --- can we just fix this in LLVM? if i'm understanding the docs right, they're implying that /data/local/tmp is the *default*[1], so there's already some Android-specific code here. can we just make it a bit cleverer? on recent versions of Android, $TMPDIR should be set correctly to a usable directory[2], so even if it's hard to do the perfect thing on old OS versions, it should be easy on new OS versions (and that shouldn't give _worse_ behavior on old OS versions).
https://source.android.com/devices/tech/perf/pgo describes how to use PGO for code in the platform image (target audience being an OEM or a vendor).
In that case, the Android build system sets the default path to /data/local/tmp (https://android.googlesource.com/platform/build/soong/+/refs/heads/master/cc/pgo.go#42).
I think it makes sense to have LLVM default to $TMPDIR if $LLVM_PROFILE_FILE is empty. I'll file a bug internally to track this.