Skip to content

Commit b606b65

Browse files
committed
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.
1 parent 4a3edb3 commit b606b65

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/Makefile

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,30 @@ ifneq ($(CFG_LLVM_CONFIG),)
167167
endif
168168
ifneq ($(CFG_LLVM_CONFIG),)
169169
CFG_LLVM_VERSION := $(shell $(CFG_LLVM_CONFIG) --version)
170-
ifeq ($(CFG_LLVM_VERSION),2.8svn)
171-
$(info cfg: using LLVM version 2.8svn)
172-
WHERE := $(shell $(CFG_LLVM_CONFIG) --libdir)/ocaml
173-
ifneq ($(shell test -e $(WHERE)/llvm.cma && echo ok),ok)
174-
CFG_LLVM_CONFIG := $(info cfg: LLVM ocaml bindings not found)
175-
endif
170+
$(info cfg: found llvm-config at $(CFG_LLVM_CONFIG))
171+
ifneq ($(findstring 2.8,$(CFG_LLVM_VERSION)),)
172+
$(info cfg: using LLVM version $(CFG_LLVM_VERSION))
173+
else ifneq ($(findstring 2.9,$(CFG_LLVM_VERSION)),)
174+
$(info cfg: using LLVM version $(CFG_LLVM_VERSION))
176175
else
177176
CFG_LLVM_CONFIG :=
178177
$(info cfg: incompatible LLVM version $(CFG_LLVM_VERSION), \
179-
expected 2.8svn)
178+
expected 2.8)
179+
endif
180+
endif
181+
ifneq ($(CFG_LLVM_CONFIG),)
182+
CFG_OCAML_LIBPATH := $(lastword \
183+
$(shell ocamlc$(OPT) -config | grep standard_library:))
184+
CFG_OCAML_LLVM := $(shell \
185+
for path in $(shell $(CFG_LLVM_CONFIG) --libdir)/ocaml \
186+
$(CFG_OCAML_LIBPATH)/llvm \
187+
$(CFG_OCAML_LIBPATH)/llvm-$(CFG_LLVM_VERSION) ; do \
188+
if test -e $${path}/llvm.cma; then echo $${path}; break; fi \
189+
done)
190+
ifneq ($(CFG_OCAML_LLVM),)
191+
$(info cfg: found LLVM ocaml bindings in $(CFG_OCAML_LLVM))
192+
else
193+
CFG_LLVM_CONFIG := $(info cfg: LLVM ocaml bindings not found)
180194
endif
181195
endif
182196
ifdef CFG_LLVM_CONFIG
@@ -185,13 +199,12 @@ ifdef CFG_LLVM_CONFIG
185199
LLVM_NATIVE_LIBS := llvm.cmxa llvm_bitwriter.cmxa
186200
LLVM_CLIBS := $(shell for c in `$(CFG_LLVM_CONFIG) --ldflags --libs` \
187201
-lllvm -lllvm_bitwriter; do echo -cclib && echo $$c; done | xargs echo)
188-
LLVM_INCS := -I boot/llvm -I $(WHERE)
202+
LLVM_INCS := -I boot/llvm -I $(CFG_OCAML_LLVM)
189203
LLVM_MLS := $(addprefix boot/llvm/, llabi.ml llasm.ml llfinal.ml \
190204
lltrans.ml llemit.ml)
191205
LLC := "$(shell $(CFG_LLVM_CONFIG) --bindir)/llc"
192206
CFG_LLC_CFLAGS := -march=x86
193207
LLVM-DIS := "$(shell $(CFG_LLVM_CONFIG) --bindir)/llvm-dis"
194-
$(info cfg: found llvm-config at $(CFG_LLVM_CONFIG))
195208
else
196209
VARIANT=x86
197210
LLVM_CLIBS :=

0 commit comments

Comments
 (0)