[PATCH] D33789: Export the required symbol from DynamicLibraryTests

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 10:35:08 PDT 2017


chill created this revision.
Herald added a subscriber: mgorny.

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 its own static library.

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


https://reviews.llvm.org/D33789

Files:
  unittests/Support/DynamicLibrary/CMakeLists.txt
  unittests/Support/DynamicLibrary/DynamicLibraryLib.cxx
  unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp


Index: unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
===================================================================
--- unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+++ unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
@@ -20,7 +20,7 @@
 using namespace llvm;
 using namespace llvm::sys;
 
-extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "ProcessCall"; }
+extern "C" PIPSQUEAK_EXPORT const char *TestA();
 
 std::string LibPath() {
   const std::vector<testing::internal::string>& Argvs = testing::internal::GetArgvs();
Index: unittests/Support/DynamicLibrary/DynamicLibraryLib.cxx
===================================================================
--- /dev/null
+++ unittests/Support/DynamicLibrary/DynamicLibraryLib.cxx
@@ -0,0 +1,12 @@
+//===- 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"
+
+extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "ProcessCall"; }
Index: unittests/Support/DynamicLibrary/CMakeLists.txt
===================================================================
--- unittests/Support/DynamicLibrary/CMakeLists.txt
+++ unittests/Support/DynamicLibrary/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_llvm_unittest(DynamicLibraryTests DynamicLibraryTest.cpp)
+add_library(DynamicLibraryLib STATIC DynamicLibraryLib.cxx)
 
+add_llvm_unittest(DynamicLibraryTests DynamicLibraryTest.cpp)
+target_link_libraries(DynamicLibraryTests DynamicLibraryLib)
 export_executable_symbols(DynamicLibraryTests)
 
 add_library(PipSqueak SHARED PipSqueak.cxx)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33789.101048.patch
Type: text/x-patch
Size: 1860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170601/70131a98/attachment.bin>


More information about the llvm-commits mailing list