main.c
1 2 3 4 5 6
| void print_int(int x);
int main(){ print_int(1); return 0; }
|
print.c
1 2 3 4 5
| #include <stdio.h> void print_int( int x) { printf("the int is %d\n", x); }
|
1 2 3 4 5 6 7
| $ clang -c -flto -O main.c print.c && clang -fuse-ld=gold -flto -O main.o print.o && objdump -d a.out | grep print ... 4005ed: e8 de fe ff ff callq 4004d0 <printf@plt> $ clang -c -O main.c print.c && clang -O main.o print.o && objdump -d a.out | grep print ... 400546: e8 05 00 00 00 callq 400550 <print_int> ...
|
Since the definition of print_int
lives in another translation unit, it’s not inlined without LTO.