💾 Archived View for bbs.geminispace.org › s › Harelang › 11826 captured on 2024-08-18 at 22:11:04. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-08-18)

-=-=-=-=-=-=-

How do I reduce binary size when compiling a Hare program?

I compiled the example Hello World program as depicted on the official website, and the binary size is ~121kB after stripping. I then tried to rewrite the Hello World program using io::write and strings::toutf8, and the stripped binary is ~34kB. Is there any way to reduce binary size even further, using lto or compiler flags?

The source code of the modified Hello World is this:

use io;
use strings;
export fn main() void = {
        io::write(1, strings::toutf8("Hello, World!\n"))!;
};

Posted in: s/Harelang

🔭 DocEdelgas

2023-11-18 · 9 months ago

1 Comment

🔭 DocEdelgas [OP] · 2023-11-20 at 00:28:

Thanks for the reply. After checking the implementation of strings::toutf8 in the standard library, I rewrote the Hello World program like this:

use io;
export fn main() void = {
        let s: str = "Hello, World!\n";
        io::write(1, *(&s: *[]u8))!;
};

The resulting stripped binary is, unfortunately, the same size.