code generation
John-Mark Gurney
jmg at funkthat.com
Sun May 31 00:45:25 UTC 2020
Jack Raats wrote this message on Sat, May 30, 2020 at 23:52 +0200:
> Hi,
>
> Can anyone explain why a simple hello_world.c compiles on a AMD64 machine
> to +/- 21000 bytes while on a raspberry pi 3 +/- 206000 bytes (10 times
> more)
>
> I use FreeBSD 12.1 stable on RPi3 and cc -o hello hello.c to compile.
What file, and what's your compiler options. This is on 13-current,
but shouldn't be dramatically different. it's on a Pine64 A64-LTS,
but that shouldn't mater either.
freebsd at generic:~ $ cat hello.c
#include <stdio.h>
int
main(void)
{
printf("hello world\n");
return 0;
}
freebsd at generic:~ $ cc -o hello hello.c
freebsd at generic:~ $ ls -l hello
-rwxr-xr-x 1 freebsd freebsd 14232 Jan 1 16:14 hello
freebsd at generic:~ $ ./hello
hello world
This is even smaller when you strip it:
freebsd at generic:~ $ strip hello
freebsd at generic:~ $ file hello
hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.0 (1300094), FreeBSD-style, stripped
freebsd at generic:~ $ ls -l hello
-rwxr-xr-x 1 freebsd freebsd 5456 Jan 1 16:19 hello
Though on the other hand, compile it static and:
freebsd at generic:~ $ cc -o hello hello.c -static -O2
freebsd at generic:~ $ ls -l hello
-rwxr-xr-x 1 freebsd freebsd 4229680 Jan 1 16:14 hello
4MB seems a bit huge for a statically compiled program...
But that's because of debug symbols:
freebsd at generic:~ $ cc -o hello hello.c -static -O2
freebsd at generic:~ $ file hello
hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (FreeBSD), statically linked, for FreeBSD 13.0 (1300094), FreeBSD-style, with debug_info, not stripped
freebsd at generic:~ $ strip hello
freebsd at generic:~ $ ls -l hello
-rwxr-xr-x 1 freebsd freebsd 701808 Jan 1 16:17 hello
But even stripped, it's still VERY large...
--
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
More information about the freebsd-arm
mailing list