OSDN Git Service

Export all dynamic symbols for opt and bugpoint
authorPirama Arumuga Nainar <pirama@google.com>
Thu, 23 Apr 2015 18:06:58 +0000 (11:06 -0700)
committerPirama Arumuga Nainar <pirama@google.com>
Fri, 1 May 2015 00:59:43 +0000 (17:59 -0700)
bug 15433215

Command line options from an LLVM module are registered and stored in a
static global object in libLLVMSupport.  Linking the Hello module with
its own copy of libLLVMSupport meant this module's option was not
registered correctly.  This patch updates Hello's build rules to not
link with libLLVMSupport and libLLVMCore.

Given the above change, the Hello module still needs to find LLVM
symbols that it used to pull directly.  The second half of this patch
adds linker flag --export-dynamic to tools/opt and tools/bugpoint so
loaded modules can find LLVM symbols.

Other  notes:
- The linker flag is not added to the device build of opt.  No one
  should be running opt on the device, AFAIK.
- Other tools that load modules, such as llc, lli and even clang, would
  need this linker flag if they were to load modules correctly.  Now
  that we know how to fix the incorrect module loads, they can be fixed
  if the need arises.
- Remove a duplicate from opt's llvm_opt_STATIC_LIBRARIES.

All supported tests pass!

Cherry pick of https://android-review.googlesource.com/#/c/148017/ from
AOSP

Change-Id: Ib76507ccfeae37a368718c5a1fb69da337f4f964

lib/Transforms/Hello/Android.mk
tools/bugpoint/Android.mk
tools/opt/Android.mk

index 4998478..e2d6163 100644 (file)
@@ -13,11 +13,6 @@ include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(transforms_hello_SRC_FILES)
 LOCAL_MODULE:= LLVMHello
 
-#LOCAL_SHARED_LIBRARIES := libLLVM
-LOCAL_STATIC_LIBRARIES := \
-  libLLVMCore \
-  libLLVMSupport
-
 LOCAL_MODULE_TAGS := optional
 
 include $(LLVM_HOST_BUILD_MK)
index 512a91f..752972a 100644 (file)
@@ -52,6 +52,7 @@ LOCAL_SRC_FILES := $(bugpoint_SRC_FILES)
 LOCAL_STATIC_LIBRARIES := $(bugpoint_STATIC_LIBRARIES)
 
 LOCAL_LDLIBS += -lpthread -lm -ldl
+LOCAL_LDFLAGS += -Wl,--export-dynamic
 
 include $(LLVM_ROOT_PATH)/llvm.mk
 include $(LLVM_HOST_BUILD_MK)
index 814fabc..3c6a494 100644 (file)
@@ -49,7 +49,6 @@ llvm_opt_STATIC_LIBRARIES := \
   libLLVMTransformObjCARC \
   libLLVMVectorize \
   libLLVMScalarOpts \
-  libLLVMTransformUtils \
   libLLVMPasses \
   libLLVMAnalysis \
   libLLVMipo \
@@ -77,6 +76,7 @@ LOCAL_IS_HOST_MODULE := true
 LOCAL_SRC_FILES := $(llvm_opt_SRC_FILES)
 LOCAL_STATIC_LIBRARIES := $(llvm_opt_STATIC_LIBRARIES)
 LOCAL_LDLIBS += -lpthread -lm -ldl
+LOCAL_LDFLAGS += -Wl,--export-dynamic
 
 include $(LLVM_ROOT_PATH)/llvm.mk
 include $(LLVM_HOST_BUILD_MK)