summaryrefslogtreecommitdiff
path: root/Makefile.rules
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-04-15 20:54:25 +0000
committerDan Gohman <gohman@apple.com>2010-04-15 20:54:25 +0000
commitb16b53b181939fa6112498a00005d1df40d6de86 (patch)
tree9478ccad505c974ebf512e2012461ceeb8b2e0b3 /Makefile.rules
parentf27733f418f9b75c7f1feeab715accc3698ba12b (diff)
downloadllvm-b16b53b181939fa6112498a00005d1df40d6de86.tar.gz
llvm-b16b53b181939fa6112498a00005d1df40d6de86.tar.bz2
llvm-b16b53b181939fa6112498a00005d1df40d6de86.tar.xz
Generalize the EXPORTED_SYMBOL_FILE concept in the Makefiles to work with
native linking export files, including running sed to prepend underscores on darwin, and make use of it in libLTO and libEnhancedDisassembly. Remove the leading underscores from library export files so that they work with the new EXPORTED_SYMBOL_FILE support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101399 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Makefile.rules')
-rw-r--r--Makefile.rules35
1 files changed, 35 insertions, 0 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 9a6280bf7f..f4a1bc95db 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -970,6 +970,37 @@ endif
endif
endif
+# Set up the library exports file.
+ifdef EXPORTED_SYMBOL_FILE
+
+# First, set up the native export file, which may differ from the source
+# export file.
+
+ifeq ($(HOST_OS),Darwin)
+# Darwin convention prefixes symbols with underscores.
+NativeExportsFile := $(ObjDir)/$(EXPORTED_SYMBOL_FILE).sed
+$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE)
+ $(Verb) sed -e 's/[[:<:]]/_/' < $< > $@
+clean-local::
+ -$(Verb) $(RM) -f $(NativeExportsFile)
+else
+NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
+endif
+
+# Now add the linker command-line options to use the native export file.
+
+ifeq ($(HOST_OS),Darwin)
+LLVMLibsOptions += -Wl,-exported_symbols_list -Wl,$(NativeExportsFile)
+endif
+
+# This isn't really Linux-specific; it works at least on gold and bfd ld, but
+# there's no convenient way to detect it.
+ifeq ($(HOST_OS),Linux)
+LLVMLibsOptions += -Wl,-retain-symbols-file -Wl,$(NativeExportsFile)
+endif
+
+endif
+
###############################################################################
# Library Build Rules: Four ways to build a library
###############################################################################
@@ -1060,6 +1091,10 @@ ifdef SHARED_LIBRARY
all-local:: $(LibName.SO)
+ifdef EXPORTED_SYMBOL_FILE
+$(LibName.SO): $(NativeExportsFile)
+endif
+
ifdef LINK_LIBS_IN_SHARED
ifdef LOADABLE_MODULE
SharedLibKindMessage := "Loadable Module"