Give shared modules in unittests the platform-native extension, make PipSqueak a MODULE

As far as I can tell from revision history, there's no good reason to call
these files .so instead of .dll in Windows, so use the normal extension.

Also change PipSquak from SHARED to MODULE -- it's never passed to
target_link_libraries() and only loaded via dlopen(), so MODULE is more
appropriate. This makes it possible to delete a workaround for SHARED ldflags
being not quite right as well.

No intended behavior change.
https://reviews.llvm.org/D46898

llvm-svn: 332487
This commit is contained in:
Nico Weber 2018-05-16 16:29:05 +00:00
parent 84caa9659e
commit 1238981938
4 changed files with 10 additions and 14 deletions

View File

@ -21,7 +21,7 @@ set_output_directory(TestPlugin
set_target_properties(TestPlugin
PROPERTIES PREFIX ""
SUFFIX ".so"
SUFFIX ${LTDL_SHLIB_EXT}
)
set_target_properties(TestPlugin PROPERTIES FOLDER "Tests")

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Config/config.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
@ -32,7 +33,7 @@ static std::string LibPath(const std::string Name = "TestPlugin") {
void *Ptr = (void *)(intptr_t)anchor;
std::string Path = sys::fs::getMainExecutable(Argv0, Ptr);
llvm::SmallString<256> Buf{sys::path::parent_path(Path)};
sys::path::append(Buf, (Name + ".so").c_str());
sys::path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str());
return Buf.str();
}

View File

@ -11,7 +11,7 @@ target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
export_executable_symbols(DynamicLibraryTests)
function(dynlib_add_module NAME)
add_library(${NAME} SHARED PipSqueak.cpp)
add_library(${NAME} MODULE PipSqueak.cpp)
set_target_properties(${NAME} PROPERTIES FOLDER "Tests")
set_output_directory(${NAME}
@ -21,18 +21,11 @@ function(dynlib_add_module NAME)
set_target_properties(${NAME}
PROPERTIES PREFIX ""
SUFFIX ".so"
SUFFIX ${LTDL_SHLIB_EXT}
)
add_dependencies(DynamicLibraryTests ${NAME})
endfunction(dynlib_add_module)
# Revert -Wl,-z,nodelete on this test since it relies on the file
# being unloaded.
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
string(REPLACE "-Wl,-z,nodelete" "" CMAKE_SHARED_LINKER_FLAGS
${CMAKE_SHARED_LINKER_FLAGS})
endif()
dynlib_add_module(PipSqueak)
dynlib_add_module(SecondLib)

View File

@ -20,12 +20,14 @@ using namespace llvm;
using namespace llvm::sys;
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";
const std::vector<testing::internal::string> &Argvs =
testing::internal::GetArgvs();
const char *Argv0 =
Argvs.size() > 0 ? Argvs[0].c_str() : "DynamicLibraryTests";
void *Ptr = (void*)(intptr_t)TestA;
std::string Path = fs::getMainExecutable(Argv0, Ptr);
llvm::SmallString<256> Buf(path::parent_path(Path));
path::append(Buf, (Name+".so").c_str());
path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str());
return Buf.str();
}