Re:151-byte static Linux binary in Rust
by userbinator on Sunday January 11, 2015 @01:10AM
(#8869231)
That main() can still be improved... try this:
It should be 10 bytes shorter.
[ Parent
| on HN ]
Yes, but the point was that it could be done in rust, using rust's language features (type safety and so forth). Making your main inline assembly isn't really using the language very much.
Re:151-byte static Linux binary in Rust
by userbinator on Sunday January 11, 2015 @11:02AM
(#8870266)
From the Github page: https://github.com/kmcallister/tiny-rust-demo
All of the machine code comes out of rustc. (Although all of the instructions that survive optimization went in as inline assembly.)
So while his main() is written in (unsafe) Rust, he's basically using it as a macroassembler.
Re:151-byte static Linux binary in Rust
by omega_rythm on Sunday January 11, 2015 @04:10AM
(#8869510)
You really should have a look at the rust code this guy wrote. I would not call that last optimization type safe.
Re:151-byte static Linux binary in Rust
by the_mitsuhiko on Sunday January 11, 2015 @04:18AM
(#8869518)
How so? The only unsafe part is the transmute which only saves 7 bytes anyways :P
Even that is still type safe, just not portable. After all, every part of the memory is a collection of bytes (that is, a slice of u8) – whether you can access them is another story.