4 ms·
A statically linked curl for ARM64 is 205kb. A statically linked hello world in Rust for ARM64 is 680kb. Curl is used for a ton of embedded hardware, and is p
by shakna 10y ago
A statically linked curl for ARM64 is 205kb.
A statically linked hello world in Rust for ARM64 is 680kb.
Curl is used for a ton of embedded hardware, and is probably in your router. Until Rust can solve its massive binaries, that is somewhere on their roadmap, it just isn't appropriate for use in the embedded world, where kilobytes still count.
- ekiru 10y agoBut there's also no reason why the most widely used HTTP fetcher in embedded software should be the same piece of software as the most widely used command line HTTP fetcher on workstations and servers, most of which do not care much about shaving kilobytes.
- shakna 10y agoAnd no reason that the most widely deployed kernel in embedded and server worlds should be the same. But it is, and written in C. Its called GNU/Linux.
- saghm 10y agoNot taking a side on the whole Linux vs. GNU/Linux thing, but the kernel is decidedly not called GNU/Linux; it's just Linux.
- pcwalton 10y agoThis is in fact a strong argument against your hard-line "every kilobyte matters" stance above. Linux is not a particularly small kernel. If code size in the embedded world were really as paramount as you claim, we'd see a lot less Linux and a lot more random RTOSes.
- pcwalton 10y ago> Until Rust can solve its massive binaries, that is somewhere on their roadmap, it just isn't appropriate for use in the embedded world, where kilobytes still count. A demo written in Rust [1] won a 64kB demo competition against C and C++ competitors. It is already solved if the binary size is a problem for you. You can easily get down to 160kB without a whole lot of effort (i.e. avoiding libstd) [2]. [1]: https://www.reddit.com/r/rust/comments/597hhv/logicoma_elysian_1st_place_trsac_2016_pc_64kb/ https://www.reddit.com/r/rust/comments/597hhv/logicoma_elysi... [2]: https://lifthrasiir.github.io/rustlog/why-is-a-rust-executable-large.html https://lifthrasiir.github.io/rustlog/why-is-a-rust-executab...
- shakna 10y ago2 very big things. 1. > How big was it before compression? - CyberDiablo > Just over 200kb iirc - yupferris 2. Avoid the standard library is a whole lot of effort. With C, and code elimination with GCC or clang, using fairly standard optimisations that require next to no knowledge of the native code being produced, I can have the following libraries, without bloating the executable: <assert.h> <complex.h> <ctype.h> <errno.h> <fenv.h> <float.h> <inttypes.h> <iso646.h> <limits.h> <locale.h> <math.h> <setjmp.h> <signal.h> <stdalign.h> <stdarg.h> <stdatomic.h> <stdbool.h> <stddef.h> <stdint.h> <stdio.h> <stdlib.h> <stdnoreturn.h> <string.h> <tgmath.h> <threads.h> <time.h> <uchar.h> <wchar.h> <wctype.h> Though you are incredibly unlikely to use all of the above at once, and occassionally some are unavailable on more limited embedded hardware (e.g. threads), C and its current compilers are light years ahead of rustc in terms of optimisation, even more so when you look at the massive list of supported architectures: GCC [0], Clang [1] I love Rust, and I do look forward to seeing more of it, but avoiding libstd, or using a different malloc, and being forced to use a nightly, or any of the other little things you can do to mitigate large binaries are just not something that is easy compared to C, or easy to pipeline when making embedded software. Relying on executable compression not directly supported by the compiler, is asking for trouble. You can do the same insane things like no stdlib in C too [2], but it doesn't mean its a good idea. (See the IOCCC [3] for some truly crazy manipulations of the C language!) [0] https://gcc.gnu.org/backends.html https://gcc.gnu.org/backends.html [1] http://llvm.org/docs/doxygen/html/classllvm_1_1Triple.html http://llvm.org/docs/doxygen/html/classllvm_1_1Triple.html [2] http://ptspts.blogspot.com.au/2013/12/how-to-make-smaller-c-and-c-binaries.html http://ptspts.blogspot.com.au/2013/12/how-to-make-smaller-c-... [3] http://www.ioccc.org/years.html http://www.ioccc.org/years.html
- steveklabnik 10y agoDon't forget, "losing the standard library" doesn't mean losing everything; it means losing libstd, but not libcore. A lot of those headers you're showing off would be in libcore, not in libstd, in Rust terms. > C and its current compilers are light years ahead of rustc in terms of optimisation, Given that we use LLVM, which is the part of clang that does most of the optimizing, we should be equivalent here, roughly. (That said, I agree that there's more we can do to make this easy.)