Building static libs with -o-

Kagamin via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Sun Apr 5 10:46:05 PDT 2015


On Thursday, 2 April 2015 at 21:57:16 UTC, John Colvin wrote:
> There are inlining opportunities across modules that only exist 
> when they are compiled together. Even if you feed all the 
> modules to LDC at once, the backend only sees one at once. Or 
> at least that's what I understand, perhaps one of the LDC devs 
> can correct me if I'm wrong.

Though llvm has lots of tools to work with bitcode. I did 
something like this:
1. pass -emit-llvm option to clang, it will generate bitcode 
(.bc) instead of object files:
SRCFLAGS = ... -emit-llvm
2. compile sources into bitcode:
compiler.bc: compiler.c $(SRCPREREQ)
trace.bc: trace.c $(SRCPREREQ)
.c.bc:
	$(CC) $(CFLAGS) -c $< -o $@
3. link bitcode files into one bitcode file and generate object 
file from that:
app.o: $(BCS)
	llvm-link $(BCS) -o app.bc
	llc app.bc -o $@ -filetype=obj $(OPT)

Also llc has all sorts of optimization options. Not LTO, but at 
least something.


More information about the digitalmars-d-ldc mailing list