[LLVMdev] Getting Started with LLVM

Chris Lattner sabre at nondot.org
Tue Mar 14 11:22:40 PST 2006


Hi, sorry for the delay, I've been swamped lately :-/

On Fri, 10 Mar 2006, Eric Kidd wrote:
> Thanks for your advice!  I did get everything working (eventually) by pasting 
> the following code into the Makefile for HowToUseJIT:
>
>  .PHONY: dump-config
>  dump-config:
>           @echo Compile: $(Compile.CXX)
>           @echo Link: $(Link)
>           @echo Libs: $(LLVMUsedLibs)
>
> ...and using the result. But this is still pretty fragile, and needs be done 
> once for every supported platform.

Ok.  This is a reasonable way to do it.  FWIW, I have a similar problem in 
the new llvm-gcc, which links to LLVM optimizations and native targets. 
The makefile goop I have looks like this:

ifneq ($(LLVMBASEPATH),)
ifdef CHECKING_ENABLED
BUILDMODE=Debug
else
BUILDMODE=Release
endif
LLVMLIBPATH = $(LLVMBASEPATH)/$(BUILDMODE)/lib

# Pick the right LLVM backend based on the target triple.
LLVMTARGETOBJCMD := case $(target) in \
                      alpha-*-*) echo LLVMAlpha.o;; \
                      ia64-*-*) echo LLVMIA64.o;; \
                      i[34567]86-*-*) echo LLVMX86.o;; \
                      powerpc*-*-*) echo LLVMPowerPC.o;; \
                      sparc-*-*) echo LLVMSparc.o;; \
                      sparcv9-*-*) echo LLVMSparc.o;; \
                     esac
LLVMTARGETOBJ := $(shell $(LLVMTARGETOBJCMD))

ifeq ($(LLVMTARGETOBJ),)
$(error Unsuported LLVM Target $(target))
endif

LLVMLIBS = -L$(LLVMLIBPATH) $(LLVMLIBPATH)/$(LLVMTARGETOBJ) 
-lLLVMScalarOpts \
            -lLLVMTransformUtils -lLLVMAnalysis  \
            $(LLVMLIBPATH)/LLVMSelectionDAG.o $(LLVMLIBPATH)/LLVMCodeGen.o \
             -lLLVMTarget $(LLVMLIBPATH)/LLVMBCWriter.o \
            $(LLVMLIBPATH)/LLVMbzip2.o \
            $(LLVMLIBPATH)/LLVMCore.o -lLLVMSupport -lLLVMSystem


uhm... *yuck*.

> Gnome (and many other Unix projects with massively ugly dependencies) can be 
> linked trivially using a "foo-config" script. If LLVM had something similar, 
> it might save new LLVM developers several hours of digging through manuals 
> and Makefiles.

This would be very very cool to have.

> A llvm-config script would be absolutely trivial to generate from the current 
> Makefiles, and--if people think it would be a Good Thing--I'm volunteering to 
> do all the legwork. :-)

Please!  That would be a very welcome addition!

>> I asked a similar question here about a month ago and Chris answered:
>> "make install is lightly tested, but should work.  Please report any
>> problems you find."
>
> Yup, the installed headers and libraries seem sufficient so far. Linking is 
> slow, but that's to be expected for such a big C++ project.

For what it's worth, linking is significantly faster for a release build 
than a debug build.  Also, if you're on linux, updating to a new binutils 
can help things significantly.

>> Personally, I've found LLVM to be a pleasure to work with. Its design 
>> is very powerful, which simplifies many things a lot.
>
> Oh, you don't have to convince me of that!  LLVM's design is so elegant 
> (compared to some compiler backends I've seen) that it really ought to have 
> theme music or something. :-)

:)

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/




More information about the llvm-dev mailing list