[llvm] r195834 - [OCaml] Embed rpath into stub libraries and native executables
Peter Zotov
whitequark at whitequark.org
Wed Nov 27 03:03:18 PST 2013
Author: whitequark
Date: Wed Nov 27 05:03:18 2013
New Revision: 195834
URL: http://llvm.org/viewvc/llvm-project?rev=195834&view=rev
Log:
[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.
Modified:
llvm/trunk/bindings/ocaml/Makefile.ocaml
Modified: llvm/trunk/bindings/ocaml/Makefile.ocaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/Makefile.ocaml?rev=195834&r1=195833&r2=195834&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/Makefile.ocaml (original)
+++ llvm/trunk/bindings/ocaml/Makefile.ocaml Wed Nov 27 05:03:18 2013
@@ -79,6 +79,15 @@ Compile.CMO := $(strip $(OCAMLC) -c $(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::
More information about the llvm-commits
mailing list