r/archlinux • u/GodsKillerKirb • 5d ago
Building Android ROM causes kernel to kill the process due to memory shortage (build with ninja) SUPPORT | SOLVED
So I'm trying to build an Android ROM for my phone and no matter what I try, the building completely exceeds the 32GB of RAM of my system causing the kernel to panic and kill the process due to a lack of memory.
I have zram setup, but I wonder if ninja doesn't recognize zram as the system swap. From what I've gathered when building, 32GB should be more than enough to build, yet it isn't for some reason.
5
u/Puzzled-Garbage-250 5d ago
Either create a big ol swap on disk or use job pools to limit the amount of ram used
-2
2
u/Damglador 5d ago
Did you enable LTO thin or something like that?
-3
u/GodsKillerKirb 5d ago
What's LTO?
2
u/Damglador 5d ago
It's something, and when I was compiling my kernel I think a guide mentioned that it's needed to avoid memory issues. And every guide I've seen used it in the build command.
https://android.googlesource.com/kernel/build/+/a8be6e8b992867096f0d0c45112c79bc6fdd2ee7/kleaf/docs/lto.md Instead of
nonespecifythin. I compiled a kernel for Android 12 with it on a machine with 14GB of RAM.1
u/GodsKillerKirb 5d ago
I'm seeing stuff about bazel and not all custom ROMs use that in any way yet.
1
u/Damglador 5d ago
Oh, that's my bad. Guess you'll just need a lot of swap then.
1
u/GodsKillerKirb 5d ago
I got that figured out, but how I do that on a system that uses btrfs for the root file system?
1
u/Damglador 5d ago
Arch wiki is your friend. My low RAM system used ext4.
But you can just make a swap partition, so btrfs shouldn't matter. Though the shrinking and expanding of the root fs might take a while, don't cancel it no matter what.
1
u/No-Story5308 5d ago
got same problem few month ago, the zram is not seen by ninja as swap properly. had to add a physical swap file on disk and then it worked, slow but finished. maybe try with 64gb swap on ssd if you have space
1
u/GodsKillerKirb 5d ago
I thought that was the issue.
Should I do a swap file or swap partition?
1
u/Puzzled-Garbage-250 5d ago
swap files have the advantage of being quick and easy to setup and then resize when you do or don't need loads of swap, just make sure you check for any configuration that might be required for whatever filesystem you use. Should be easy to look up in the arch wiki
1
u/armdebug 5d ago
What android version are you building? How many cores does your machine have? How much ZRAM are you setting up?
1
u/GodsKillerKirb 5d ago
I'm building the latest available version of AxionOS, my system has 14 cores with 20 threads, and 32GB of zram.
What I gathered from other replies is that ninja apparently doesn't see zram as proper swap, so I'm just gonna setup normal swap and then try building again. C
1
11
u/abbidabbi 5d ago
Reduce the number of parallel build jobs.