Skip to content

Commit 1238981

Browse files
committed
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
1 parent 84caa96 commit 1238981

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

llvm/unittests/Passes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set_output_directory(TestPlugin
2121

2222
set_target_properties(TestPlugin
2323
PROPERTIES PREFIX ""
24-
SUFFIX ".so"
24+
SUFFIX ${LTDL_SHLIB_EXT}
2525
)
2626
set_target_properties(TestPlugin PROPERTIES FOLDER "Tests")
2727

llvm/unittests/Passes/PluginsTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//===----------------------------------------------------------------------===//
99

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

llvm/unittests/Support/DynamicLibrary/CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
1111
export_executable_symbols(DynamicLibraryTests)
1212

1313
function(dynlib_add_module NAME)
14-
add_library(${NAME} SHARED PipSqueak.cpp)
14+
add_library(${NAME} MODULE PipSqueak.cpp)
1515
set_target_properties(${NAME} PROPERTIES FOLDER "Tests")
1616

1717
set_output_directory(${NAME}
@@ -21,18 +21,11 @@ function(dynlib_add_module NAME)
2121

2222
set_target_properties(${NAME}
2323
PROPERTIES PREFIX ""
24-
SUFFIX ".so"
24+
SUFFIX ${LTDL_SHLIB_EXT}
2525
)
2626

2727
add_dependencies(DynamicLibraryTests ${NAME})
2828
endfunction(dynlib_add_module)
2929

30-
# Revert -Wl,-z,nodelete on this test since it relies on the file
31-
# being unloaded.
32-
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
33-
string(REPLACE "-Wl,-z,nodelete" "" CMAKE_SHARED_LINKER_FLAGS
34-
${CMAKE_SHARED_LINKER_FLAGS})
35-
endif()
36-
3730
dynlib_add_module(PipSqueak)
3831
dynlib_add_module(SecondLib)

llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ using namespace llvm;
2020
using namespace llvm::sys;
2121

2222
std::string LibPath(const std::string Name = "PipSqueak") {
23-
const std::vector<testing::internal::string>& Argvs = testing::internal::GetArgvs();
24-
const char *Argv0 = Argvs.size() > 0 ? Argvs[0].c_str() : "DynamicLibraryTests";
23+
const std::vector<testing::internal::string> &Argvs =
24+
testing::internal::GetArgvs();
25+
const char *Argv0 =
26+
Argvs.size() > 0 ? Argvs[0].c_str() : "DynamicLibraryTests";
2527
void *Ptr = (void*)(intptr_t)TestA;
2628
std::string Path = fs::getMainExecutable(Argv0, Ptr);
2729
llvm::SmallString<256> Buf(path::parent_path(Path));
28-
path::append(Buf, (Name+".so").c_str());
30+
path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str());
2931
return Buf.str();
3032
}
3133

0 commit comments

Comments
 (0)