llvm.org GIT mirror llvm / 4e05282
[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 Peter Zotov 7 years ago
1 changed file(s) with 12 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
7878 Compile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
7979
8080 ifdef OCAMLSTUBS
81 # Avoid the need for LD_LIBRARY_PATH
82 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
83 ifneq ($(HOST_OS),Darwin)
84 OCAMLRPATH := $(RPATH) -Wl,'$(SharedLibDir)'
85 endif
86 endif
87 endif
88
89 ifdef OCAMLSTUBS
8190 Archive.CMA := $(strip $(OCAMLC) -a -dllib -l$(LIBRARYNAME) $(OCAMLDEBUGFLAG) \
8291 -o)
8392 else
8796
8897 ifdef OCAMLSTUBS
8998 Archive.CMXA := $(strip $(OCAMLOPT) -a $(patsubst %,-cclib %, \
90 $(LLVMLibsOptions) -l$(LIBRARYNAME)) \
91 -cclib -L$(SharedLibDir) \
99 $(LLVMLibsOptions) -l$(LIBRARYNAME) \
100 -L$(SharedLibDir) $(OCAMLRPATH))
92101 $(OCAMLDEBUGFLAG) -o)
93102 else
94103 Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) -o)
233242
234243 $(SharedLib): $(ObjectsO) $(OcamlDir)/.dir
235244 $(Echo) "Building $(BuildMode) $(notdir $@)"
236 $(Verb) $(Link) $(SharedLinkOptions) $(LLVMLibsOptions) \
245 $(Verb) $(Link) $(SharedLinkOptions) $(OCAMLRPATH) $(LLVMLibsOptions) \
237246 -o $@ $(ObjectsO)
238247
239248 clean-shared::