Update llvm version detection for the 2.8 release.

The LLVM project recently released version 2.8, and updated
the SVN tree version to 2.9svn, obsoleting the simple check
for 'llvm-config --version' returning 2.8svn.

With this commit we instead check for the substrings 2.8 and 2.9
in the output of 'llvm-config --version', since we (currently)
support both the svn and released varieties of those versions.

A stable release also complicates our check for the ocaml bindings.
Previously we looked in `llvm-config --libdir`/ocaml which is
appropriate for local compiles, but distribution packagers are
likely to put the bindings in the default search path, e.g.
/usr/lib/ocaml/llvm. We now fall back to trying variations on
the standard library path returned by 'ocamlc -config' if we
don't find it under 'llvm-config --libdir'.

With this change, rust builds against LLVM 2.8 as packaged
in Ubuntu 10.10 as well as LLVM 2.9svn compiled locally.
(cherry picked from commit b606b65756f087c403180abd5418fe7dce469758)
This commit is contained in:
Ralph Giles 2010-10-19 12:05:22 -07:00 committed by Graydon Hoare
parent a7599a7968
commit 45056fc022

View File

@ -167,16 +167,30 @@ ifneq ($(CFG_LLVM_CONFIG),)
endif
ifneq ($(CFG_LLVM_CONFIG),)
CFG_LLVM_VERSION := $(shell $(CFG_LLVM_CONFIG) --version)
ifeq ($(CFG_LLVM_VERSION),2.8svn)
$(info cfg: using LLVM version 2.8svn)
WHERE := $(shell $(CFG_LLVM_CONFIG) --libdir)/ocaml
ifneq ($(shell test -e $(WHERE)/llvm.cma && echo ok),ok)
CFG_LLVM_CONFIG := $(info cfg: LLVM ocaml bindings not found)
endif
$(info cfg: found llvm-config at $(CFG_LLVM_CONFIG))
ifneq ($(findstring 2.8,$(CFG_LLVM_VERSION)),)
$(info cfg: using LLVM version $(CFG_LLVM_VERSION))
else ifneq ($(findstring 2.9,$(CFG_LLVM_VERSION)),)
$(info cfg: using LLVM version $(CFG_LLVM_VERSION))
else
CFG_LLVM_CONFIG :=
$(info cfg: incompatible LLVM version $(CFG_LLVM_VERSION), \
expected 2.8svn)
expected 2.8)
endif
endif
ifneq ($(CFG_LLVM_CONFIG),)
CFG_OCAML_LIBPATH := $(lastword \
$(shell ocamlc$(OPT) -config | grep standard_library:))
CFG_OCAML_LLVM := $(shell \
for path in $(shell $(CFG_LLVM_CONFIG) --libdir)/ocaml \
$(CFG_OCAML_LIBPATH)/llvm \
$(CFG_OCAML_LIBPATH)/llvm-$(CFG_LLVM_VERSION) ; do \
if test -e $${path}/llvm.cma; then echo $${path}; break; fi \
done)
ifneq ($(CFG_OCAML_LLVM),)
$(info cfg: found LLVM ocaml bindings in $(CFG_OCAML_LLVM))
else
CFG_LLVM_CONFIG := $(info cfg: LLVM ocaml bindings not found)
endif
endif
ifdef CFG_LLVM_CONFIG
@ -185,13 +199,12 @@ ifdef CFG_LLVM_CONFIG
LLVM_NATIVE_LIBS := llvm.cmxa llvm_bitwriter.cmxa
LLVM_CLIBS := $(shell for c in `$(CFG_LLVM_CONFIG) --ldflags --libs` \
-lllvm -lllvm_bitwriter; do echo -cclib && echo $$c; done | xargs echo)
LLVM_INCS := -I boot/llvm -I $(WHERE)
LLVM_INCS := -I boot/llvm -I $(CFG_OCAML_LLVM)
LLVM_MLS := $(addprefix boot/llvm/, llabi.ml llasm.ml llfinal.ml \
lltrans.ml llemit.ml)
LLC := "$(shell $(CFG_LLVM_CONFIG) --bindir)/llc"
CFG_LLC_CFLAGS := -march=x86
LLVM-DIS := "$(shell $(CFG_LLVM_CONFIG) --bindir)/llvm-dis"
$(info cfg: found llvm-config at $(CFG_LLVM_CONFIG))
else
VARIANT=x86
LLVM_CLIBS :=