Re:Show HN: Lstr – A modern, interactive tree command writte...
by koito17 on Wednesday June 18, 2025 @12:35AM
(#44306698)
By switching to e.g. musl, you can go down to a single megabyte ;)
But in all seriousness, my example is quite cherrypicked, since nobody will actually statically link glibc. And even if they did, one can make use of link-time optimization to remove lots of patches of unused code. Note that this is the same strategy one would employ to debloat their Rust binaries. (Use LTO, don't aggressively inline code, etc.)
Re:Show HN: Lstr – A modern, interactive tree command writte...
by 3836293648 on Wednesday June 18, 2025 @06:02PM
(#44313658)
Just a `puts("Hello world!")` with -Os statically linked to musl is 22k
Re:Show HN: Lstr – A modern, interactive tree command writte...
by 3836293648 on Wednesday June 18, 2025 @12:50AM
(#44306752)
We just have large standard libraries now
Re:Show HN: Lstr – A modern, interactive tree command writte...
by surajrmal on Wednesday June 18, 2025 @09:42AM
(#44309817)
lto will remove most of it.
Re:Show HN: Lstr – A modern, interactive tree command writte...
by AdieuToLogic on Wednesday June 18, 2025 @09:36PM
(#44314688)
Just for fun, I wondered how small a canonical hello world program could be in macOS running an ARM processor. Below is based on what I found here[0] with minor command-line switch alterations to account for a newer OS version.
ARM64 assembly program (hw.s):
//
// Assembler program to print "Hello World!"
// to stdout.
//
// X0-X2 - parameters to linux function services
// X16 - linux function number
//
.global _start // Provide program starting address to linker
.align 2
// Setup the parameters to print hello world
// and then call Linux to do it.
_start: mov X0, #1 // 1 = StdOut
adr X1, helloworld // string to print
mov X2, #13 // length of our string
mov X16, #4 // MacOS write system call
svc 0 // Call linux to output the string
// Setup the parameters to exit the program
// and then call Linux to do it.
mov X0, #0 // Use 0 return code
mov X16, #1 // Service command code 1 terminates this program
svc 0 // Call MacOS to terminate the program
helloworld: .ascii "Hello World!\n"
Assembling and linking commands: as -o hw.o hw.s &&
ld -macos_version_min 14.0.0 -o hw hw.o -lSystem -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -e _start -arch arm64
Resulting file sizes: -rwxr-xr-x 1 <uid> <gid> 16K Jun 18 21:23 hw
-rw-r--r-- 1 <uid> <gid> 440B Jun 18 21:23 hw.o
-rw-r--r-- 1 <uid> <gid> 862B Jun 18 21:21 hw.s
0 - https://smist08.wordpress.com/2021/01/08/apple-m1-assembly-l...
Re:Show HN: Lstr – A modern, interactive tree command writte...
by creatonez on Monday June 23, 2025 @05:31PM
(#44360357)
> The executable takes 33KB in C, 75KB in nim.
Did you statically link Glibc...? Or is this with a non-GNU libc?
Either way, it probably is true that this 2.2MiB number would be smaller on, say, Debian 5. And much smaller on PDP Unix.
The executable takes 33KB in C, 75KB in nim.