From: Roger Ferrer Ibanez Date: Mon, 12 Jun 2017 07:22:15 +0000 (+0000) Subject: Export the required symbol from DynamicLibraryTests X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0158aaf614dd50ef1587b22c448b8b4d93f16e08;p=llvm Export the required symbol from DynamicLibraryTests 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 --- diff --git a/unittests/Support/DynamicLibrary/CMakeLists.txt b/unittests/Support/DynamicLibrary/CMakeLists.txt index 2fa4bf237d4..b5844381362 100644 --- a/unittests/Support/DynamicLibrary/CMakeLists.txt +++ b/unittests/Support/DynamicLibrary/CMakeLists.txt @@ -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) diff --git a/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp b/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp index 80a20990de1..c54e1b7eed2 100644 --- a/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp +++ b/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -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& 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 index 00000000000..97f190b0b9b --- /dev/null +++ b/unittests/Support/DynamicLibrary/ExportedFuncs.cxx @@ -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; } diff --git a/unittests/Support/DynamicLibrary/PipSqueak.cxx b/unittests/Support/DynamicLibrary/PipSqueak.cxx index 79cf59255a4..375d72c0b53 100644 --- a/unittests/Support/DynamicLibrary/PipSqueak.cxx +++ b/unittests/Support/DynamicLibrary/PipSqueak.cxx @@ -45,4 +45,5 @@ extern "C" PIPSQUEAK_EXPORT void TestOrder(std::vector &V) { Glb.Vec = &V; } -extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "LibCall"; } +#define PIPSQUEAK_TESTA_RETURN "LibCall" +#include "ExportedFuncs.cxx" diff --git a/unittests/Support/DynamicLibrary/PipSqueak.h b/unittests/Support/DynamicLibrary/PipSqueak.h index 3e4f79a9a6f..b44c61d64df 100644 --- a/unittests/Support/DynamicLibrary/PipSqueak.h +++ b/unittests/Support/DynamicLibrary/PipSqueak.h @@ -29,4 +29,6 @@ #define PIPSQUEAK_EXPORT #endif +extern "C" PIPSQUEAK_EXPORT const char *TestA(); + #endif