Live data from Hacker News

Ubus (OpenWrt micro bus architecture)

openwrt.org

31–40 of 56 posts

Re: Ubus (OpenWrt micro bus architecture)

#31
post #26
post #2

Did they consider using a memory-safe language for this?

A decent question, I've wondered about Rust programs on openwrt but at the moment they're just too big! Linking the stdlib into every binary doesn't help, and the code is generally larger than the C equivalent. It doesn't seem unsolvable though, I'm hopeful. no_std rust binaries can be near competitive with C. Binary size is sometimes a big deal. Two decades ago I investigated using C++ for an "embedded" linux ssh se…

This is on point. I work on small-ish embedded Linux systems and I would really like to use Rust there, but a single Rust binary takes up enough space for 10 C programs, so it's prohibitive. You can dynamically link your libraries (especially since these systems are usually built as full images, so ABI compatibility does not really matter) and it helps a little, but nowhere close to the order of magnitude you need.

Alas, there is little interest in/awareness of the middle ground between the no_std world and the "size doesn't matter" world in the Rust community right now. I've asked a bunch of people for pointers as to where to start working towards supporting those cases but I mainly got shrugs. There were attempts at more lightweight stdlibs and so on, but they all seem to have fizzled out.

I wonder how much of this is inherent in the language design. Rust heavily leans on monomorphization, so as a first approximation, you will always generate more code (before maybe optimizing that away again). Famously, the Swift people went to great lengths to avoid these problems: https://faultlore.com/blah/swift-abi/. But while running Swift on Linux is possible, this is even more niche.

Re: Ubus (OpenWrt micro bus architecture)

#32
post #30
post #29

Earlier quoted context omitted.

>I'm hopeful. no_std rust binaries can be near competitive with C. I feel like Rust without std might as well be a different language. Almost all of the available mindshare, docs, libraries are dependant on it. Sure, you can use it. But to me it just looks like technological poverty. Even compared to the C ecosystem.

I'd disagree. Using something like Embassy is pretty pleasant for embedded development, less worries than C. The only issue is maturity. There were sufficient crates to write a ssh server for a rp2040 (mostly out of curiosity) using what's available in no_std.

First time I'm hearing about Embassy. Looks like things have progressed since last time I tried deploying rust on an stm32.

Re: Ubus (OpenWrt micro bus architecture)

#33
post #31
post #26

Earlier quoted context omitted.

A decent question, I've wondered about Rust programs on openwrt but at the moment they're just too big! Linking the stdlib into every binary doesn't help, and the code is generally larger than the C equivalent. It doesn't seem unsolvable though, I'm hopeful. no_std rust binaries can be near competitive with C. Binary size is sometimes a big deal. Two decades ago I investigated using C++ for an "embedded" linux ssh se…

This is on point. I work on small-ish embedded Linux systems and I would really like to use Rust there, but a single Rust binary takes up enough space for 10 C programs, so it's prohibitive. You can dynamically link your libraries (especially since these systems are usually built as full images, so ABI compatibility does not really matter) and it helps a little, but nowhere close to the order of magnitude you need. A…

There's some interest in a binary size working group. https://rust-lang.zulipchat.com/#narrow/stream/131828-t-comp...

Re: Ubus (OpenWrt micro bus architecture)

#34
post #28
post #23

Earlier quoted context omitted.

Current OpenWRT uses musl libc[1] which can be optimized to have a tiny footprint and supports full static linking, before that it used ucLibc which was similarly optimized. You can still build software for OpenWRT that requires the much bigger Glibc, but of course it will not work that well on devices with limited memory. [1]: https://musl.libc.org/

Musl libc seems to be 2 MB ish, it's smaller than glibc but still something when comparing to other languages and their runtimes.

    464.7K Oct 15  2022 /lib/libc.so
As seen on openwrt on armv7l system

Re: Ubus (OpenWrt micro bus architecture)

#35
post #29
post #26

Earlier quoted context omitted.

A decent question, I've wondered about Rust programs on openwrt but at the moment they're just too big! Linking the stdlib into every binary doesn't help, and the code is generally larger than the C equivalent. It doesn't seem unsolvable though, I'm hopeful. no_std rust binaries can be near competitive with C. Binary size is sometimes a big deal. Two decades ago I investigated using C++ for an "embedded" linux ssh se…

>I'm hopeful. no_std rust binaries can be near competitive with C. I feel like Rust without std might as well be a different language. Almost all of the available mindshare, docs, libraries are dependant on it. Sure, you can use it. But to me it just looks like technological poverty. Even compared to the C ecosystem.

Actually I'm often surprised just how much out there is actually available with no_std feature options?

There's obviously a lot of need for improvement in Rust in regards to small systems, as people have pointed out. But there's also a lot more middle ground in Rust vs, say, C++: You can be no_std and still have Vector, for example, while in C++ the STL is an all-or-nothing thing.

It's a smaller community, and it will come down to individuals deciding it's important and making contributions.

Re: Ubus (OpenWrt micro bus architecture)

#36
post #6

Earlier quoted context omitted.

Considering the repo dates back to 2010 (predating Rust by 4+ years), there probably wasn’t a better option that could run on the embedded devices that OpenWRT targets.

The project age is good background info. However Rust didn't invent memory-safety, there were reasonable options for system programming at that time too (eg Ocaml, Go, Ada, etc). edit: Also D in safe mode like mentioend above - not sure if it was around in 2010?

Back then, your suggestions were niche languages (and some still are) and are still not popular for embedded systems or network equipment. Large runtimes or huge static binaries are not suitable due to the memory and storage constraints.

You have to consider the surrounding ecosystem. Those interested in such languages are not necessarily those interested in contributing solutions to the problem space. Any project attempting to use such a language in OpenWrt would very likely not have survived until today.

Re: Ubus (OpenWrt micro bus architecture)

#37
post #31
post #26

Earlier quoted context omitted.

A decent question, I've wondered about Rust programs on openwrt but at the moment they're just too big! Linking the stdlib into every binary doesn't help, and the code is generally larger than the C equivalent. It doesn't seem unsolvable though, I'm hopeful. no_std rust binaries can be near competitive with C. Binary size is sometimes a big deal. Two decades ago I investigated using C++ for an "embedded" linux ssh se…

This is on point. I work on small-ish embedded Linux systems and I would really like to use Rust there, but a single Rust binary takes up enough space for 10 C programs, so it's prohibitive. You can dynamically link your libraries (especially since these systems are usually built as full images, so ABI compatibility does not really matter) and it helps a little, but nowhere close to the order of magnitude you need. A…

totally agree,that's the same reason I gave up rust for embedded systems, beyond no_stb bare metal use case,it is way too big in size comparing to c and c++. golang has similar size issue,sadly.

Re: Ubus (OpenWrt micro bus architecture)

#38
post #19

Earlier quoted context omitted.

200k is very large in the OpenWrt world

Ada then? Eg on https://ada.godbolt.org/ you can see the default program compiled to ~25 lines of assembler. edit: actually it contains a call to a bounds check function that presumably is in the runtime library, i don't know how big that is. A major point in this is that C also has a fairly big runtime library that should be factored into the comparison!

musl is a few hundred kb

Re: Ubus (OpenWrt micro bus architecture)

#39
post #28

Earlier quoted context omitted.

Musl libc seems to be 2 MB ish, it's smaller than glibc but still something when comparing to other languages and their runtimes.

464.7K Oct 15 2022 /lib/libc.so As seen on openwrt on armv7l system

Also OpenWRT udev itself is tiny:

  20.0K Oct 13  2022 /usr/lib/libudev.so.1
   8.0K Dec 15  2022 /sbin/udevtrigger

Re: Ubus (OpenWrt micro bus architecture)

#40
As someone having to debug issues on OpenWRT derivatives, I wish I had a time machine to tell the inventors of Unix to never add other forms of IPC than pipes.

It's all a big pile of stateful daemons notifying other daemons with a billion race conditions and zero debugging capabilities, like a parody of how not to create reliable systems. When you have shell scripts parsing JSON messages, you know it's over.

Post reply on HN