[LLVMdev] Compiling zlib to static bytecode archive

Maarten ter Huurne maarten at treewalker.org
Fri Sep 21 09:42:36 PDT 2007


Hi,

I'm trying to compile zlib to produce a "libz.a" static library which is an 
LLVM bytecode archive. I'm using this command line for "configure":

  AR="llvm-ar r" RANLIB=llvm-ranlib CC=llvm-gcc CFLAGS=--emit-llvm \
    ./configure

The creation of "libz.a" works, but after that, zlib's Makefile wants to 
compile and link some example programs. The linking step fails:

  llvm-gcc --emit-llvm -DNO_vsnprintf -DUSE_MMAP -o example example.o \
    -L. libz.a
  example.o: file not recognized: File format not recognized
  collect2: ld returned 1 exit status

I can link it by hand using llvm-ld instead of llvm-gcc, like this:

  llvm-ld -o example example.o libz.a

However, it is not possible to let the zlib Makefile issue that command 
without patching the Makefile, because the fragment that does the linking is 
hardcoded to use the compiler command for linking:

  example$(EXE): example.o $(LIBS)
          $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)

Would it be possible to make llvm-gcc call llvm-ld instead of the systemwide 
ld? I tried setting the environment variables COMPILER_PATH=/usr/local/bin 
and GCC_EXEC_PREFIX=llvm- but that had no effect.

I'm using LLVM 2.1-pre1 and the corresponding llvm-gcc 4.0.

Bye,
		Maarten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070921/cc5af5ec/attachment.sig>


More information about the llvm-dev mailing list