Rust development on device

I’ve always avoided rust as its syntax seems even more cryptic than latest C++2x…, but it seems to be weirdly functional on device. Importantly do not attempt to ‘pkcon install rust cargo’ as you’ll end up with shell stumps that complain about scratchbox and 300+ mb less on your rootfs. Rust installs nicely through curl:

No devel-su needed, gracefully installs in ~/.cargo so no need to worry about rootfs at all. First thing I tried took 5 minutes to ‘cargo run’ compiling some 390 crates and worked flawlessly out of the box (keys.openpgp.org / hagrid · GitLab). Not much use on device (unless you feed it keys and use as a drop in replacement for hkp, should work), so tried with sequoia-sq, gplv2 replacement for gnupg, sadly this OOMs, even with extra 4Gb swap. I believe it’s because of /tmp size, but not sure and there is no way to reuse artifacts so every attempt takes 15min/~7%battery, anybody knows if mount/remount of /tmp is safe on sfos? Used to work nicely on N900/maemo, but couldn’t find any thread on this for sfos and it’s my personal production device so don’t want to risk it.

1 Like

I’m not, if I understand that correctly, but if you added a swapfile in /tmp, that’s utterly pointless, since /tmp is a tmpfs, i.e. stored in RAM.

That’s my XA2:

[root@xperia ~]# mount | grep /tmp
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
1 Like

Nah, swapfile is in /home, but it barely touched the extra space once reaching 1.03Gb and then failed with ‘missing -lsqlite3’ or similar message, next try with sqlite-devel installed just oomed again though (after every cargo install crash you have to clear /tmp manually or it ooms quicker and even triggers the OS info banner ‘running out of space’ even though rootfs is untouched, which is why I think more /tmp space could help, maybe?)

Mounting /tmp to some other device (sdcard, nfs, …) should work. Stock umount didn’t

[root@xperia ~]# umount /tmp/
umount: /tmp/: target is busy.

Only user in my case is is messageserver5:

[root@xperia ~]# fuser -m /tmp
4959 
[root@xperia ~]# ps -ef | grep 4959
nemo      4959  4911  0 23:36 ?        00:00:01 /usr/bin/messageserver5

As user nemo:
[nemo@xperia ~]$ systemctl --user stop messageserver5

Now umount worked on my device. After that procedure /tmp is in the root filesystem (plenty of space on my device but pretty limited by default) and you can now mount it to every device you have attached, e.g. an sdcard or nfs share to increase space.

1 Like

Might need to try that, went with ‘mount -o remount,size=5G /tmp/’ after all and instead of killing the window it just said ‘Killed’ and died, maybe it’s hitting some watchdog?

Ok, no need to remount anything, just:

mkdir tmp
CARGO_TARGET_DIR=tmp cargo install xyz

(that or the extra 4Gb of swap helped, 9Gb total oO, the memes are real, EDIT: yeah the tmp dir is ‘only’ 2.3Gb, it must’ve been the extra swap)

Compiling termcolor v1.2.0
Finished release [optimized + debuginfo] target(s) in 14m 13s
Installing /home/defaultuser/.cargo/bin/sq
Installed package `sequoia-sq v0.31.0` (executable `sq`)
1 Like

To ease memory pressure, you could use -j 1 to only use one thread – compilation time goes up, naturally.

What SFOS version you run and what’s the newest Rust you could run? I’m very interested on this…

1 Like

4.5.0.21

rustc --version
rustc 1.71.1 (eb26296b5 2023-08-03)

That would make the compilation time about 90 minutes instead, need to figure out how to force static compilation to not redo all the artifacts all the time and it would be pretty usable

1 Like