I’d like to be able to cross-compile Rust applications for Sailfish OS (which is a Linux-based mobile operating system). Since nobody from the Sailfish community was able to help me, I thought I could ask here, so here’s the problem:
The Sailfish OS Platform SDK is a chroot environment (a 32-bit one, to be precise), so my Rust installation is 32-bit as well; I’ve installed it via rustup. However, to compile code for target devices the SDK uses scratchbox2 and a rootfs which contains arch-specific libraries. Running rustc/cargo from the chroot works fine, but if I try to do it from an sb2 prompt, it simply freezes.
I’ve tried doing an strace, which seems to be waiting forever at this call: futex(0xf77c4c84, FUTEX_WAIT_PRIVATE, 2, NULL
I know that sb2 is a complex piece of software that does a lot of things, and have just recently found this document, which I haven’t yet fully read:
The Sailfish OS Platform SDK installation doc is here, if anyone wants to reproduce the issue. I’ve tried compiling for an i486 target, so that qemu doesn’t come into play.
Can anyone tell me why that error is happening?
Run it from host os (i486), not sb2 (arm). I have been able to run helloworld on the phone and build some easy crates from host but it does not work properly for some crates, openssl for example. I gave up on doing this. However, I am trying to make rust working in sb2 now.
Yeah, I know it works from the chroot itself and a hello world copied to the phone worked as well.
The thing is, for any ‘real’ app you need to use external libraries, preferably those shipped with the OS. I was thinking about chrooting into SB2 targets myself, but that’d be a lot of work from a maintenance perspective in the long run.
If you make any progress, keep me posted. Having Rust on SFOS would certainly open up some possibilities.
Edit: BTW, there’s a new SDK version coming out within the next days I suppose (new OS update was released to early access today). I might try to see if anything’s changed.
Edit 2: Still the same after installing via rustup from within Platform SDK. Works there, but hangs inside any kind of target, including i486.
Sorry for gravedigging this post but it is the only post that relates to the issue I’m facing.
I’m currently trying to build Rust on the Mer Build service (https://build.merproject.org/package/show/home:sfietkonstantin:sailfish:rust/rust), and I’m facing the same kind of hanging. It seems that either cargo or rust is freezing when trying to compile some libraries.
I have also tried to debug the issue under scratchbox, and found out that I’m often facing OOM or allocators trying to allocate memory.
This lead me to the conclusion that jemalloc or how the Rust memory allocator might be behaving incorrectly under qemu / scratchbox.
I would love to have some help debugging this issue. @ArmsOfSorrow and @vityafx: have you tried further by any luck ?
No worries, I’m happy not to be the only one who cares.
I haven’t tried anything further since I don’t know very much about what sb2 does internally that might cause such an error. If you could give me any pointers, I’d be glad to help, though.
I have also tried to compile
rust but without any success unfortunately. So I decided to try to cross-compile
armv7hl binaries from
i486 chroot because it works and will be much faster than using
armv7hl's rust anyway. I have a working recipe for that but I am stuck at compiling
openssl crate - it does not take my environment variables into account and I am unable to compile. For example, everything that uses
hyper (and so
openssl) does not compile. But everything else - does. Okay, not everything, I did not try everything, but most of crates compile.
I’m actually wondering if it really freezes. Some libs just take tons of time to build. I will just be patient and wait to see if anything got built.
On https://build.merproject.org/package/live_build_log/home:sfietkonstantin:sailfish:rust/rust/sailfishos_armv7hl/armv8el it looks like it is being built.
I got it built. See https://build.merproject.org/project/show/home:sfietkonstantin:sailfish:rust for packages. It is also a repository so you can use it in your sb2 env with
ssu ar sfosrust http://repo.merproject.org/obs/home:/sfietkonstantin:/sailfish:/rust/sailfishos_armv7hl/
zypper in rustc rust-std-static cargo
It took about 13h yesterday to build rustc. Now I’m rebuilding it before building cargo, so be patient
Awesome, how did you do it?
EDIT: cargo is still not available. I’m working on it
EDIT2: and cargo is available too
It has been about one year that this topic had no news, but during FOSDEM 2018, I made some discoveries about scratchbox. This means that, probably, we will get accelerated builds in scratchbox / Mer OBS.
I will keep you posted
News for rust and SailfishOS more than welcome!