summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorPeter Zotov <whitequark@whitequark.org>2013-11-27 11:03:18 +0000
committerPeter Zotov <whitequark@whitequark.org>2013-11-27 11:03:18 +0000
commit4e05282ec5b757ecfd43cfb71e6ea3ab01cf7cd7 (patch)
tree3cabaa3f67d6cdfbe75132372cfd74233a0af467 /bindings
parent3b818b481fef58aabbd70a6ce8cce859e0c10aaf (diff)
downloadllvm-4e05282ec5b757ecfd43cfb71e6ea3ab01cf7cd7.tar.gz
llvm-4e05282ec5b757ecfd43cfb71e6ea3ab01cf7cd7.tar.bz2
llvm-4e05282ec5b757ecfd43cfb71e6ea3ab01cf7cd7.tar.xz
[OCaml] Embed rpath into stub libraries and native executables
This commit embeds a set of linker flags with hardcoded paths to the LLVM shared library on --enable-shared builds into .cmxa files and stub dynamic libraries. This solution closely follows existing rules for rpath in the LLVM tools, which had to be modified because of differences in toolchain. Without this patch, OCaml tests as well as opam bindings broke, as neither of those updates LD_LIBRARY_PATH to include the $prefix/lib directory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/ocaml/Makefile.ocaml15
1 files changed, 12 insertions, 3 deletions
diff --git a/bindings/ocaml/Makefile.ocaml b/bindings/ocaml/Makefile.ocaml
index f7ee43b8f2..1e9eb9f560 100644
--- a/bindings/ocaml/Makefile.ocaml
+++ b/bindings/ocaml/Makefile.ocaml
@@ -79,6 +79,15 @@ Compile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
Compile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
ifdef OCAMLSTUBS
+# Avoid the need for LD_LIBRARY_PATH
+ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ifneq ($(HOST_OS),Darwin)
+OCAMLRPATH := $(RPATH) -Wl,'$(SharedLibDir)'
+endif
+endif
+endif
+
+ifdef OCAMLSTUBS
Archive.CMA := $(strip $(OCAMLC) -a -dllib -l$(LIBRARYNAME) $(OCAMLDEBUGFLAG) \
-o)
else
@@ -88,8 +97,8 @@ endif
ifdef OCAMLSTUBS
Archive.CMXA := $(strip $(OCAMLOPT) -a $(patsubst %,-cclib %, \
- $(LLVMLibsOptions) -l$(LIBRARYNAME)) \
- -cclib -L$(SharedLibDir) \
+ $(LLVMLibsOptions) -l$(LIBRARYNAME) \
+ -L$(SharedLibDir) $(OCAMLRPATH))
$(OCAMLDEBUGFLAG) -o)
else
Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) -o)
@@ -234,7 +243,7 @@ uninstall-local:: uninstall-shared
$(SharedLib): $(ObjectsO) $(OcamlDir)/.dir
$(Echo) "Building $(BuildMode) $(notdir $@)"
- $(Verb) $(Link) $(SharedLinkOptions) $(LLVMLibsOptions) \
+ $(Verb) $(Link) $(SharedLinkOptions) $(OCAMLRPATH) $(LLVMLibsOptions) \
-o $@ $(ObjectsO)
clean-shared::