[llvm] r332487 - Give shared modules in unittests the platform-native extension, make PipSqueak a MODULE

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed May 16 09:29:06 PDT 2018


Author: nico
Date: Wed May 16 09:29:05 2018
New Revision: 332487

URL: http://llvm.org/viewvc/llvm-project?rev=332487&view=rev
Log:
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

Modified:
    llvm/trunk/unittests/Passes/CMakeLists.txt
    llvm/trunk/unittests/Passes/PluginsTest.cpp
    llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt
    llvm/trunk/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp

Modified: llvm/trunk/unittests/Passes/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Passes/CMakeLists.txt?rev=332487&r1=332486&r2=332487&view=diff
==============================================================================
--- llvm/trunk/unittests/Passes/CMakeLists.txt (original)
+++ llvm/trunk/unittests/Passes/CMakeLists.txt Wed May 16 09:29:05 2018
@@ -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")
 

Modified: llvm/trunk/unittests/Passes/PluginsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Passes/PluginsTest.cpp?rev=332487&r1=332486&r2=332487&view=diff
==============================================================================
--- llvm/trunk/unittests/Passes/PluginsTest.cpp (original)
+++ llvm/trunk/unittests/Passes/PluginsTest.cpp Wed May 16 09:29:05 2018
@@ -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::st
   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();
 }
 

Modified: llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt?rev=332487&r1=332486&r2=332487&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt (original)
+++ llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt Wed May 16 09:29:05 2018
@@ -11,7 +11,7 @@ target_link_libraries(DynamicLibraryTest
 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)

Modified: llvm/trunk/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp?rev=332487&r1=332486&r2=332487&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp (original)
+++ llvm/trunk/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp Wed May 16 09:29:05 2018
@@ -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();
 }
 




More information about the llvm-commits mailing list