[LLVMdev] llvmc doesn't recognise .a files

Bueno, Denis denbuen at sandia.gov
Tue Sep 28 12:48:52 PDT 2010


Hello,

I'm trying to compile some existing C99 code with llvm in order to take advantage of its whole-program optimisations.  The existing code has a configure/make compilation process.

So far the most success I've had follows this recipe:

CC=llvmc ./configure
make CFLAGS='--emit-llvm ...' #including a bunch of gcc optimisation flags like -O2

The compile process first builds libLibrary.a, using llvmc, llvm-ar, and llvm-ranlib.  Then it compiles main.c to main.o and at this point the compile process fails when trying to link the final executable:

  llvmc --emit-llvm -o program main.o libLibrary.a
  llvmc: File 'libLibrary.a' has unknown suffix 'a'

So close!  I'm reasonably sure llvmc _should_ understand .a files, given that llvm tools exist to create them (llvm-ar and llvm-ranlib) and other tools understand them (e.g. llvm-ld).  Is this a known issue and will it be fixed?

So what I do right now is after the link failure:

  llvm-ld -b=program-unopt.bc -internalize-public-api-list=main main.o libLibrary.a
  # llvm-ld deals with .a files just fine
  opt -O3 -o program-opt.bc program-unopt.bc
  llvm-ld -o=program-opt -internalize-public-api-list=main -native -Xlinker=-lm program-opt.bc
  
Is there a cleaner way to do what I'm doing?  In particular it would be nicer if all I had to do was mess with the flags passed to configure or make and not have to run any of the llvm tools (e.g. opt or llvm-ld) myself.

Thanks.
                             Denis






More information about the llvm-dev mailing list