Conversation
Notices
-
Embed this notice
翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Sunday, 16-Mar-2025 21:01:38 JST 翠星石
@theorytoe @PurpCat @EdBoatConnoisseur Hello world is so short that any compiler optimizations for speed or size should have no difference (which is true for gcc)
printf() with a static string does not need to be debugged and can be understanded easily even from objdump, thus there should be no debug information in the binary unless it was specifically requested.-
Embed this notice
翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Sunday, 16-Mar-2025 21:51:18 JST 翠星石
@reimu @theorytoe @EdBoatConnoisseur @PurpCat What on earth is that satanic programming language?
Imagine writing C software, except with >9000 extra steps and such complexity that you are bound to make many mistakes and cause many vulnerabilities, that would be either trivial to avoid (just use printf(), or difficult but possible to avoid with careful programming.
The line noise syntax is ridiculous and seemingly intentionally next to impossible to parse.
It's still larger than a size-unoptimized C binary after all that... -
Embed this notice
reimu@mk.fumo.pictures's status on Sunday, 16-Mar-2025 21:51:22 JST reimu
@Suiseiseki@freesoftwareextremist.com @theorytoe@ak.kyaruc.moe @PurpCat@clubcyberia.co @EdBoatConnoisseur@poa.st The problem with the rust compiler is by default it embeds the entire rust standard library into the binary (without optimizing).
You can disable it with #![no_std] and use libc directly.
this is the hello world program with libc:#![no_std] #![no_main] use core::ffi::CStr; #[no_mangle] pub extern fn main(_argc: i32, _argv: *const *const core::ffi::c_char) -> i32 { unsafe{libc::printf(CStr::from_bytes_with_nul_unchecked("hello world\n\0".as_bytes()).as_ptr());} 0 } #[cfg(not(test))] #[panic_handler] fn panic(_:&core::panic::PanicInfo)->! { loop{} }
and add this to cargo.toml[dependencies] libc="*" [profile.dev] panic="abort" opt-level=3
and add this in .cargo/config.toml[build] rustflags = ["-C", "link-args=-lc"]
after stripping the binary it is 16K
After removing the rust standard library you can check the binary if it contains the panic function. If it does that means the program may crash. If it doesn't then it cannot crash. (except in unsafe code). This feature can make rust code safe, but almost no one uses it. -
Embed this notice
翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Monday, 17-Mar-2025 09:34:42 JST 翠星石
@reimu @theorytoe @EdBoatConnoisseur @PurpCat Under half a MiB in size is not something that causes issues really.
There's a problem if the binary is >1MiB in size. -
Embed this notice
reimu@mk.fumo.pictures's status on Monday, 17-Mar-2025 09:34:43 JST reimu
@EdBoatConnoisseur@poa.st @theorytoe@ak.kyaruc.moe @Suiseiseki@freesoftwareextremist.com @PurpCat@clubcyberia.co GNU ada has the same problem.
with Ada.Text_IO; procedure HelloWorld is begin Ada.Text_IO.Put_Line ("Hello, World!"); end HelloWorld;
The binary size is 428K for me.
I checked the assembly and it contains a lot of unnecessary stuff.
But I haven't found any workaround for ada. -
Embed this notice
EdBoatConnoisseur (edboatconnoisseur@poa.st)'s status on Monday, 17-Mar-2025 09:34:44 JST EdBoatConnoisseur
@reimu @theorytoe @Suiseiseki @PurpCat in other words rust is deeply stupid by default statically adding unneeded stuf.
-
Embed this notice