From b16b53b181939fa6112498a00005d1df40d6de86 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Apr 2010 20:54:25 +0000 Subject: 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 --- Makefile.rules | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'Makefile.rules') diff --git a/Makefile.rules b/Makefile.rules index 9a6280b..f4a1bc9 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" -- cgit v1.1