3 ms·
Did you compile with the --release flag? Without it will build a debug build and put all the debug info in there (which mainly due to println is a lot).
by dathinab 8y ago
Did you compile with the --release flag? Without it will build a debug build and put all the debug info in there (which mainly due to println is a lot).
- edflsafoiewq 8y agoIt doesn't make any difference for something as small as hello world (you can try it). A release build might not have debug info in the sense that -C debuginfo=0, but it still has plenty of stuff that can be stripped. You also get the same size if you bypass the println machinery with io::stdout().write_all(b"Hello, world!").
- Grollicus 8y ago$ cargo --version && cargo init hello && cd hello && cat ./src/main.rs && cargo build --release && du -h ./target/release/hello cargo 1.34.0 (6789d8a0a 2019-04-01) Created binary (application) package fn main() { println!("Hello, world!"); } Compiling hello v0.1.0 (/tmp/foo/hello) Finished release [optimized] target(s) in 0.31s 1,6M ./target/release/hello Edit: $ strip target/release/hello && du -h ./target/release/hello 192K ./target/release/hello
- the8472 8y ago164K after fat lto, Os, panic=abort and stripping on nightly 2019-05-12
- aasasd 8y agoNote that, while it doesn't matter much in this case, with `du` you'll get ~±4Kb out of nowhere because it measures by fs blocks. You need `--apparent-size` for the file size―which doesn't exist in the BSD version (= MacOS version).