summaryrefslogtreecommitdiff
path: root/tools/llvm-shlib
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2010-02-18 02:36:02 +0000
committerJeffrey Yasskin <jyasskin@google.com>2010-02-18 02:36:02 +0000
commitf6afae2f49ed65a6a482257c7e55520857d751b7 (patch)
tree3cdfe6a7431398a707157c86927577fb0908f5cc /tools/llvm-shlib
parent89bb7b56407bf81a5d5fdcdac7106d94bb30dd65 (diff)
downloadllvm-f6afae2f49ed65a6a482257c7e55520857d751b7.tar.gz
llvm-f6afae2f49ed65a6a482257c7e55520857d751b7.tar.bz2
llvm-f6afae2f49ed65a6a482257c7e55520857d751b7.tar.xz
Add a shared library for LLVM, named libLLVM2.7svn.(so|dylib), and add an
--enable-shared configure flag to have the tools linked shared. (2.7svn is just $(LLVMVersion) so it'll change to "2.7" in the release.) Always link the example programs shared to test that the shared library keeps working. On my mac laptop, Debug libLLVM2.7svn.dylib is 39MB, and opt (for example) is 16M static vs 440K shared. Two things are less than ideal here: 1) The library doesn't include any version information. Since we expect to break the ABI with every release, this shouldn't be much of a problem. If we do release a compatible 2.7.1, we may be able to hack its library to work with binaries compiled against 2.7.0, or we can just ask them to recompile. I'm hoping to get a real packaging expert to look at this for the 2.8 release. 2) llvm-config doesn't yet have an option to print link options for the shared library. I'll add this as a subsequent patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96559 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-shlib')
-rw-r--r--tools/llvm-shlib/Makefile61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/llvm-shlib/Makefile b/tools/llvm-shlib/Makefile
new file mode 100644
index 0000000000..b2f725ce3b
--- /dev/null
+++ b/tools/llvm-shlib/Makefile
@@ -0,0 +1,61 @@
+##===- tools/shlib/Makefile --------------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../..
+LIBRARYNAME = LLVM$(LLVMVersion)
+
+NO_BUILD_ARCHIVE = 1
+LINK_LIBS_IN_SHARED = 1
+SHARED_LIBRARY = 1
+
+include $(LEVEL)/Makefile.common
+
+# Include all archives in libLLVM.(so|dylib) except the ones that have
+# their own dynamic libraries.
+Archives := $(wildcard $(LibDir)/libLLVM*.a)
+SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT))
+IncludeInLibLlvm := $(filter-out $(basename $(SharedLibraries)).a, $(Archives))
+LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%)
+LLVMLibsPaths := $(IncludeInLibLlvm)
+
+$(LibName.SO): $(LLVMLibsPaths)
+
+ifeq ($(HOST_OS),Darwin)
+ # set dylib internal version number to llvmCore submission number
+ ifdef LLVM_SUBMIT_VERSION
+ LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \
+ -Wl,$(LLVM_SUBMIT_VERSION).$(LLVM_SUBMIT_SUBVERSION) \
+ -Wl,-compatibility_version -Wl,1
+ endif
+ # Include everything from the .a's into the shared library.
+ LLVMLibsOptions := $(LLVMLibsOptions) \
+ -Wl,-all_load
+ # extra options to override libtool defaults
+ LLVMLibsOptions := $(LLVMLibsOptions) \
+ -avoid-version \
+ -Wl,-dead_strip \
+ -Wl,-seg1addr -Wl,0xE0000000
+
+ # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
+ DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
+ ifneq ($(DARWIN_VERS),8)
+ LLVMLibsOptions := $(LLVMLibsOptions) \
+ -Wl,-install_name \
+ -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)"
+ endif
+endif
+
+ifeq ($(HOST_OS), Linux)
+ # Include everything from the .a's into the shared library.
+ LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \
+ -Wl,--no-whole-archive
+ # Don't allow unresolved symbols, and warn if we'll need to modify
+ # the text segment when loading libLLVM.so.
+ LLVMLibsOptions += -Wl,--no-undefined,--warn-shared-textrel
+endif