ThinLTO on OS X!

Johan Engelen via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Tue Sep 27 11:52:46 PDT 2016


Hi all,
   The new XCode 8 features LLVM's ThinLTO in the linker. With 
some patching in LDC, I got it to work pretty easily. The result:

<file b.d>
```
extern(C) void doesNothing() {}
```

<file a.d>
```
extern(C) void doesNothing(); // declaration only

void main() {
     for (ulong i = 0; i < 100_000_000; ++i) {
         doesNothing();
     }
}
```

Separate compilation:
> ../bin/ldc2 -c b.d -O3 -of=b.o
> ../bin/ldc2 a.d b.o -of=a -O3
> time ./a
./a  1.77s user 0.01s system 98% cpu 1.802 total

Separate compilation with ThinLTO:
> ../bin/ldc2 -c b.d -O3 -of=bthin.o -thinlto
> ../bin/ldc2 a.d bthin.o -of=athin -O3 -thinlto
> time ./athin
./athin  0.00s user 0.00s system 61% cpu 0.006 total

BAM!

PR incoming.

I'd like your input for the commandline flag name.




More information about the digitalmars-d-ldc mailing list