I would like to share a problem which I stumbled upon when building AOSP for HiKey960. It is a generic problem and I post it here because I couldn’t find a solution anywhere in the Internet. So just in case somebody suffers from it, here’s the spoiler: DON’T USE NFS for building AOSP.
Since building AOSP takes a lot of storage space I used remote storage mouted via NFS for AOSP build. Then I entered into dex2oat build failures:
dex2oatd E 12-10 20:52:06 41013 41013 dex2oat.cc:2329] Cannot lock profiles: Failed to lock file 'out/target/product/hikey960/obj/JAVA_LIBRARIES/services_intermediates/profile.prof': Bad file descriptor dex2oatd E 12-10 20:52:06 41013 41013 dex2oat.cc:3093] Failed to process profile file
The root cause is that AOSP uses
flock() to lock the files and it does not work over NFS
I switched to locally mounded file system and the build succeeded. So again, don’t use NFS storage for building AOSP.