llvm.org GIT mirror llvm / c901719
Try r96559 for the third time. This time the shared library is only built if --enable-shared is passed to configure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97119 91177308-0d34-0410-b5e6-96231b3b80d8 Jeffrey Yasskin 9 years ago
10 changed file(s) with 155 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
2929 DIRS := lib/System lib/Support utils
3030 OPTIONAL_DIRS :=
3131 else
32 DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \
33 tools runtime docs unittests
32 DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-shlib \
33 tools/llvm-config tools runtime docs unittests
3434 OPTIONAL_DIRS := projects bindings
3535 endif
3636
4141 EXTRA_DIST := test unittests llvm.spec include win32 Xcode
4242
4343 include $(LEVEL)/Makefile.config
44
45 ifneq ($(ENABLE_SHARED),1)
46 DIRS := $(filter-out tools/llvm-shlib, $(DIRS))
47 endif
4448
4549 ifeq ($(MAKECMDGOALS),libs-only)
4650 DIRS := $(filter-out tools runtime docs, $(DIRS))
261261 # Do we want to build with position independent code?
262262 ENABLE_PIC := @ENABLE_PIC@
263263
264 # Do we want to build a shared library and link the tools with it?
265 ENABLE_SHARED := @ENABLE_SHARED@
266
264267 # Use -fvisibility-inlines-hidden?
265268 ENABLE_VISIBILITY_INLINES_HIDDEN := @ENABLE_VISIBILITY_INLINES_HIDDEN@
266269
270273
271274 # Enable JIT for this platform
272275 TARGET_HAS_JIT = @TARGET_HAS_JIT@
276
277 # Environment variable to set to change the runtime shared library search path.
278 SHLIBPATH_VAR = @SHLIBPATH_VAR@
273279
274280 # Shared library extension for host platform.
275281 SHLIBEXT = @SHLIBEXT@
622622 ifneq ($(HOST_OS),Darwin)
623623 ifneq ($(DARWIN_MAJVERS),4)
624624 ifdef TOOLNAME
625 ifdef EXAMPLE_TOOL
626 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
627 else
628 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
629 endif
625 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
626 ifdef EXAMPLE_TOOL
627 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
628 else
629 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
630 endif
630631 endif
631632 endif
632633 endif
959960
960961 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
961962
963 ifeq ($(ENABLE_SHARED), 1)
964 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
965 LLVMLibsPaths += $(LibDir)/libLLVM-$(LLVMVersion)$(SHLIBEXT)
966 else
962967 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
963968 LLVMLibsPaths += $(LLVM_CONFIG) \
964969 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
970 endif
965971 endif
966972 endif
967973
11681174 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
11691175 # building an archive.
11701176 #---------------------------------------------------------
1177 ifndef NO_BUILD_ARCHIVE
11711178 ifndef BUILD_ARCHIVE
11721179 ifndef LOADABLE_MODULE
11731180 BUILD_ARCHIVE = 1
1181 endif
11741182 endif
11751183 endif
11761184
471471 AC_DEFINE_UNQUOTED([ENABLE_PIC],$ENABLE_PIC,
472472 [Define if position independent code is enabled])
473473
474 dnl Allow building a shared library and linking tools against it.
475 AC_ARG_ENABLE(shared,
476 AS_HELP_STRING([--enable-shared],
477 [Build a shared library and link tools against it (default is NO)]),,
478 enableval=default)
479 case "$enableval" in
480 yes) AC_SUBST(ENABLE_SHARED,[1]) ;;
481 no) AC_SUBST(ENABLE_SHARED,[0]) ;;
482 default) AC_SUBST(ENABLE_SHARED,[0]) ;;
483 *) AC_MSG_ERROR([Invalid setting for --enable-shared. Use "yes" or "no"]) ;;
484 esac
485
474486 dnl Allow specific targets to be specified for building (or not)
475487 TARGETS_TO_BUILD=""
476488 AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
13351347 dnl the Makefiles so we can use it there too
13361348 AC_SUBST(SHLIBEXT,$libltdl_cv_shlibext)
13371349
1350 dnl Propagate the run-time library path variable that the libltdl
1351 dnl checks found to the Makefiles so we can use it there too
1352 AC_SUBST(SHLIBPATH_VAR,$libltdl_cv_shlibpath_var)
1353
13381354 # Translate the various configuration directories and other basic
13391355 # information into substitutions that will end up in Makefile.config.in
13401356 # that these configured values can be used by the makefiles
688688 ENABLE_DOXYGEN
689689 ENABLE_THREADS
690690 ENABLE_PIC
691 ENABLE_SHARED
691692 TARGETS_TO_BUILD
692693 LLVM_ENUM_TARGETS
693694 LLVM_ENUM_ASM_PRINTERS
769770 LLVMGCCDIR
770771 LLVMGCC_LANGS
771772 SHLIBEXT
773 SHLIBPATH_VAR
772774 LLVM_PREFIX
773775 LLVM_BINDIR
774776 LLVM_LIBDIR
14011403 --enable-threads Use threads if available (default is YES)
14021404 --enable-pic Build LLVM with Position Independent Code (default
14031405 is YES)
1406 --enable-shared Build a shared library and link tools against it
1407 (default is NO)
14041408 --enable-targets Build specific host targets: all or
14051409 target1,target2,... Valid targets are: host, x86,
14061410 x86_64, sparc, powerpc, alpha, arm, mips, spu,
23262330 msp430-*) llvm_cv_target_arch="MSP430" ;;
23272331 s390x-*) llvm_cv_target_arch="SystemZ" ;;
23282332 bfin-*) llvm_cv_target_arch="Blackfin" ;;
2329 microblaze-*) llvm_cv_target_arch="MBlaze" ;;
2333 mblaze-*) llvm_cv_target_arch="MBlaze" ;;
23302334 *) llvm_cv_target_arch="Unknown" ;;
23312335 esac
23322336 fi
48654869 #define ENABLE_PIC $ENABLE_PIC
48664870 _ACEOF
48674871
4872
4873 # Check whether --enable-shared was given.
4874 if test "${enable_shared+set}" = set; then
4875 enableval=$enable_shared;
4876 else
4877 enableval=default
4878 fi
4879
4880 case "$enableval" in
4881 yes) ENABLE_SHARED=1
4882 ;;
4883 no) ENABLE_SHARED=0
4884 ;;
4885 default) ENABLE_SHARED=0
4886 ;;
4887 *) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-shared. Use \"yes\" or \"no\"" >&5
4888 echo "$as_me: error: Invalid setting for --enable-shared. Use \"yes\" or \"no\"" >&2;}
4889 { (exit 1); exit 1; }; } ;;
4890 esac
48684891
48694892 TARGETS_TO_BUILD=""
48704893 # Check whether --enable-targets was given.
1110911132 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1111011133 lt_status=$lt_dlunknown
1111111134 cat > conftest.$ac_ext <
11112 #line 11108 "configure"
11135 #line 11136 "configure"
1111311136 #include "confdefs.h"
1111411137
1111511138 #if HAVE_DLFCN_H
1968819711 fi
1968919712
1969019713 SHLIBEXT=$libltdl_cv_shlibext
19714
19715
19716 SHLIBPATH_VAR=$libltdl_cv_shlibpath_var
1969119717
1969219718
1969319719 # Translate the various configuration directories and other basic
2074720773 ENABLE_DOXYGEN!$ENABLE_DOXYGEN$ac_delim
2074820774 ENABLE_THREADS!$ENABLE_THREADS$ac_delim
2074920775 ENABLE_PIC!$ENABLE_PIC$ac_delim
20776 ENABLE_SHARED!$ENABLE_SHARED$ac_delim
2075020777 TARGETS_TO_BUILD!$TARGETS_TO_BUILD$ac_delim
2075120778 LLVM_ENUM_TARGETS!$LLVM_ENUM_TARGETS$ac_delim
2075220779 LLVM_ENUM_ASM_PRINTERS!$LLVM_ENUM_ASM_PRINTERS$ac_delim
2075620783 CLANGPATH!$CLANGPATH$ac_delim
2075720784 CLANGXXPATH!$CLANGXXPATH$ac_delim
2075820785 ENABLE_BUILT_CLANG!$ENABLE_BUILT_CLANG$ac_delim
20759 OPTIMIZE_OPTION!$OPTIMIZE_OPTION$ac_delim
2076020786 _ACEOF
2076120787
2076220788 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
2079820824 ac_delim='%!_!# '
2079920825 for ac_last_try in false false false false false :; do
2080020826 cat >conf$$subs.sed <<_ACEOF
20827 OPTIMIZE_OPTION!$OPTIMIZE_OPTION$ac_delim
2080120828 EXTRA_OPTIONS!$EXTRA_OPTIONS$ac_delim
2080220829 BINUTILS_INCDIR!$BINUTILS_INCDIR$ac_delim
2080320830 ENABLE_LLVMC_DYNAMIC!$ENABLE_LLVMC_DYNAMIC$ac_delim
2086920896 LLVMGCCDIR!$LLVMGCCDIR$ac_delim
2087020897 LLVMGCC_LANGS!$LLVMGCC_LANGS$ac_delim
2087120898 SHLIBEXT!$SHLIBEXT$ac_delim
20899 SHLIBPATH_VAR!$SHLIBPATH_VAR$ac_delim
2087220900 LLVM_PREFIX!$LLVM_PREFIX$ac_delim
2087320901 LLVM_BINDIR!$LLVM_BINDIR$ac_delim
2087420902 LLVM_LIBDIR!$LLVM_LIBDIR$ac_delim
2088920917 LTLIBOBJS!$LTLIBOBJS$ac_delim
2089020918 _ACEOF
2089120919
20892 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 89; then
20920 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 91; then
2089320921 break
2089420922 elif $ac_last_try; then
2089520923 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
197197 -e "s#@LLVM_TOOLS_DIR@#$(ToolDir)#g" \
198198 -e "s#@LLVMGCCDIR@#$(LLVMGCCDIR)#g" \
199199 -e "s#@LLVM_BUILD_MODE@#$(BuildMode)#g" \
200 -e "s#@ENABLE_SHARED@#$(ENABLE_SHARED)#g" \
201 -e "s#@SHLIBPATH_VAR@#$(SHLIBPATH_VAR)#g" \
200202 $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@
2222
2323 ###
2424
25 import os
25 # If necessary, point the dynamic loader at libLLVM.so.
26 if config.enable_shared:
27 libdir = os.path.join(config.llvm_obj_root, config.llvm_build_mode, 'lib')
28 shlibpath = config.environment.get(config.shlibpath_var,'')
29 if shlibpath:
30 shlibpath = ':' + shlibpath
31 shlibpath = libdir + shlibpath
32 config.environment[config.shlibpath_var] = shlibpath
2633
2734 # Check that the object root is known.
2835 if config.test_exec_root is None:
44 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
55 config.llvmgcc_dir = "@LLVMGCCDIR@"
66 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
7 config.enable_shared = @ENABLE_SHARED@
8 config.shlibpath_var = "@SHLIBPATH_VAR@"
79
810 # Let the main config do the real work.
911 lit.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg")
0 ##===- tools/shlib/Makefile --------------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../..
10
11 LIBRARYNAME = LLVM-$(LLVMVersion)
12
13 NO_BUILD_ARCHIVE = 1
14 LINK_LIBS_IN_SHARED = 1
15 SHARED_LIBRARY = 1
16
17 include $(LEVEL)/Makefile.common
18
19 # Include all archives in libLLVM.(so|dylib) except the ones that have
20 # their own dynamic libraries.
21 Archives := $(wildcard $(LibDir)/libLLVM*.a)
22 SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT))
23 IncludeInLibLlvm := $(filter-out $(basename $(SharedLibraries)).a, $(Archives))
24 LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%)
25 LLVMLibsPaths := $(IncludeInLibLlvm)
26
27 $(LibName.SO): $(LLVMLibsPaths)
28
29 ifeq ($(HOST_OS),Darwin)
30 # set dylib internal version number to llvmCore submission number
31 ifdef LLVM_SUBMIT_VERSION
32 LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \
33 -Wl,$(LLVM_SUBMIT_VERSION).$(LLVM_SUBMIT_SUBVERSION) \
34 -Wl,-compatibility_version -Wl,1
35 endif
36 # Include everything from the .a's into the shared library.
37 LLVMLibsOptions := $(LLVMLibsOptions) -all_load
38 # extra options to override libtool defaults
39 LLVMLibsOptions := $(LLVMLibsOptions) \
40 -avoid-version \
41 -Wl,-dead_strip \
42 -Wl,-seg1addr -Wl,0xE0000000
43
44 # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
45 DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
46 ifneq ($(DARWIN_VERS),8)
47 LLVMLibsOptions := $(LLVMLibsOptions) \
48 -Wl,-install_name \
49 -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)"
50 endif
51 endif
52
53 ifeq ($(HOST_OS), Linux)
54 # Include everything from the .a's into the shared library.
55 LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \
56 -Wl,--no-whole-archive
57 # Don't allow unresolved symbols.
58 LLVMLibsOptions += -Wl,--no-undefined
59 endif
2727 CPP.Flags += $(NO_VARIADIC_MACROS)
2828 TESTLIBS = -lGoogleTest -lUnitTestMain
2929
30 ifeq ($(ENABLE_SHARED), 1)
31 # Add the absolute path to the dynamic library. This is ok because
32 # we'll never install unittests.
33 LD.Flags += $(RPATH) -Wl,$(LibDir)
34 # Also set {DYLD,LD}_LIBRARY_PATH because OSX ignores the rpath most
35 # of the time.
36 Run.Shared := $(SHLIBPATH_VAR)="$(LibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)"
37 endif
38
3039 $(LLVMUnitTestExe): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
3140 $(Echo) Linking $(BuildMode) unit test $(TESTNAME) $(StripWarnMsg)
3241 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
3746 all:: $(LLVMUnitTestExe)
3847
3948 unitcheck:: $(LLVMUnitTestExe)
40 $(LLVMUnitTestExe)
49 $(Run.Shared) $(LLVMUnitTestExe)
4150
4251 endif