1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[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.

llvm-svn: 195834
This commit is contained in:
Peter Zotov 2013-11-27 11:03:18 +00:00
parent 533a55aa15
commit 4ae3b7518c

View File

@ -78,6 +78,15 @@ Compile.CMI := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
Compile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o) Compile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
Compile.CMX := $(strip $(OCAMLOPT) -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 ifdef OCAMLSTUBS
Archive.CMA := $(strip $(OCAMLC) -a -dllib -l$(LIBRARYNAME) $(OCAMLDEBUGFLAG) \ Archive.CMA := $(strip $(OCAMLC) -a -dllib -l$(LIBRARYNAME) $(OCAMLDEBUGFLAG) \
-o) -o)
@ -88,8 +97,8 @@ endif
ifdef OCAMLSTUBS ifdef OCAMLSTUBS
Archive.CMXA := $(strip $(OCAMLOPT) -a $(patsubst %,-cclib %, \ Archive.CMXA := $(strip $(OCAMLOPT) -a $(patsubst %,-cclib %, \
$(LLVMLibsOptions) -l$(LIBRARYNAME)) \ $(LLVMLibsOptions) -l$(LIBRARYNAME) \
-cclib -L$(SharedLibDir) \ -L$(SharedLibDir) $(OCAMLRPATH))
$(OCAMLDEBUGFLAG) -o) $(OCAMLDEBUGFLAG) -o)
else else
Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) -o) Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) -o)
@ -234,7 +243,7 @@ uninstall-local:: uninstall-shared
$(SharedLib): $(ObjectsO) $(OcamlDir)/.dir $(SharedLib): $(ObjectsO) $(OcamlDir)/.dir
$(Echo) "Building $(BuildMode) $(notdir $@)" $(Echo) "Building $(BuildMode) $(notdir $@)"
$(Verb) $(Link) $(SharedLinkOptions) $(LLVMLibsOptions) \ $(Verb) $(Link) $(SharedLinkOptions) $(OCAMLRPATH) $(LLVMLibsOptions) \
-o $@ $(ObjectsO) -o $@ $(ObjectsO)
clean-shared:: clean-shared::