]> granicus.if.org Git - llvm/commitdiff
Export the required symbol from DynamicLibraryTests
authorRoger Ferrer Ibanez <roger.ferreribanez@arm.com>
Mon, 12 Jun 2017 07:22:15 +0000 (07:22 +0000)
committerRoger Ferrer Ibanez <roger.ferreribanez@arm.com>
Mon, 12 Jun 2017 07:22:15 +0000 (07:22 +0000)
Running unittests/Support/DynamicLibrary/DynamicLibraryTests fails
when LLVM is configured with -DLLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON, because
the test's version script only contains symbols extracted from the static libraries,
that the test links with, but not those from the main object/executable itself.

The patch moves the one symbol, needed by the test, to a static library.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32893

Patch by Momchil Velikov.

Differential Revision: https://reviews.llvm.org/D33789

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305181 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Support/DynamicLibrary/CMakeLists.txt
unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
unittests/Support/DynamicLibrary/ExportedFuncs.cxx [new file with mode: 0644]
unittests/Support/DynamicLibrary/PipSqueak.cxx
unittests/Support/DynamicLibrary/PipSqueak.h

index 2fa4bf237d409a848cf7d759226a280847866b37..b5844381362e3f29cbfb5b22d98c18271123a9da 100644 (file)
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_llvm_unittest(DynamicLibraryTests DynamicLibraryTest.cpp)
+add_library(DynamicLibraryLib STATIC ExportedFuncs.cxx)
 
+add_llvm_unittest(DynamicLibraryTests DynamicLibraryTest.cpp)
+target_link_libraries(DynamicLibraryTests DynamicLibraryLib)
 export_executable_symbols(DynamicLibraryTests)
 
 function(dynlib_add_module NAME)
index 80a20990de188314a6ce6f3e460fe36b21310cbf..c54e1b7eed24d0f6659b4bf54f17bf97fe9e2651 100644 (file)
@@ -19,8 +19,6 @@
 using namespace llvm;
 using namespace llvm::sys;
 
-extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "ProcessCall"; }
-
 std::string LibPath(const std::string Name = "PipSqueak") {
   const std::vector<testing::internal::string>& Argvs = testing::internal::GetArgvs();
   const char *Argv0 = Argvs.size() > 0 ? Argvs[0].c_str() : "DynamicLibraryTests";
diff --git a/unittests/Support/DynamicLibrary/ExportedFuncs.cxx b/unittests/Support/DynamicLibrary/ExportedFuncs.cxx
new file mode 100644 (file)
index 0000000..97f190b
--- /dev/null
@@ -0,0 +1,16 @@
+//===- llvm/unittest/Support/DynamicLibrary/DynamicLibraryLib.cpp ---------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PipSqueak.h"
+
+#ifndef PIPSQUEAK_TESTA_RETURN
+#define PIPSQUEAK_TESTA_RETURN "ProcessCall"
+#endif
+
+extern "C" PIPSQUEAK_EXPORT const char *TestA() { return PIPSQUEAK_TESTA_RETURN; }
index 79cf59255a4f0f447d8f473ef5c58e5c64e879a8..375d72c0b535f4fc785e736e5969c4c4cd1dc1da 100644 (file)
@@ -45,4 +45,5 @@ extern "C" PIPSQUEAK_EXPORT void TestOrder(std::vector<std::string> &V) {
   Glb.Vec = &V;
 }
 
-extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "LibCall"; }
+#define PIPSQUEAK_TESTA_RETURN "LibCall"
+#include "ExportedFuncs.cxx"
index 3e4f79a9a6f49bf433abc6e3ea89e3e6d039c9c0..b44c61d64dfe47faf26200109da923e880a69541 100644 (file)
@@ -29,4 +29,6 @@
 #define PIPSQUEAK_EXPORT
 #endif
 
+extern "C" PIPSQUEAK_EXPORT const char *TestA();
+
 #endif