collect2 hack

Hi all,

After a long time, I've updated to new LLVM. Everything compiles fine
(which is great), but I see that compiling/linking into bitcode files still
hasn't been solved in a satisfying way.

Until that gets resolved, I'm sending an updated script, that will do
the trick.

Usage:

cd $LLVM_PATH/libexec/gcc/x86_64-unknown-linux-gnu/4.0.1/
mv collect2 llvm-collect2
copy the attached file to that directory

The new collect will call llvm-collect2, unless you pass -enable-ld
to it, in which case it will call llvm-ld, and link the bc files.

To build an average app into bc files:

1) configure with standard llvm-gcc (don't pass -enable-ld to llvm-gcc)
2) build with something like:
make CC=llvm-gcc CFLAGS+='-emit-llvm -g -O0 -fkeep-inline-functions
-fno-inline -finline-limit=0 -Wl,-enable-ld -Wl,-O0
-Wl,-disable-inlining -Wl,-disable-opt'

To get the make line right, you will need to know the details of your
build process, if it relies on LD and LDFLAGS, use something like:

make CC=llvm-gcc LD=llvm-ld CFLAGS+='-g -I. -O0
-fkeep-inline-functions -fno-inline -finline-limit=0 -D__i386__'
LDFLAGS+='-O0 -disable-inlining -disable-opt -enable-ld'

This is an ugly hack, but it works for me. Script is not perfect,
and fixes/patches would be welcome.

You are free to use the script as you wish (public domain sw), and
there are no guarantees whatsoever.

I'm really hopeful that this will be solved in a more satisfying manner
soon. Beautiful intermediate form is a big plus of LLVM, but you need
to support it all the way...

Cheers,

collect2 (1.8 KB)