Skip to content

Commit

Permalink
[CMake][AIX] Adjust plugin library extension used on AIX
Browse files Browse the repository at this point in the history
As stated in the CMake manual, we are supposed to use MODULE rules to generate
plugin libraries:

"MODULE libraries are plugins that are not linked into other targets but may be
loaded dynamically at runtime using dlopen-like functionality"

Besides, LLVM's plugin infrastructure fits with the AIX treatment of .so
shared objects more than it fits with the AIX treatment of .a library archives
(which may contain shared objects).

Differential revision: https://reviews.llvm.org/D96282
  • Loading branch information
xling-liao committed Mar 4, 2021
1 parent 293e8fa commit e9f9ec8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
8 changes: 6 additions & 2 deletions llvm/cmake/modules/HandleLLVMOptions.cmake
Expand Up @@ -152,8 +152,12 @@ endif()
set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})

# We use *.dylib rather than *.so on darwin.
set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
# We use *.dylib rather than *.so on darwin, but we stick with *.so on AIX.
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_MODULE_SUFFIX})
else()
set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()

if(APPLE)
if(LLVM_ENABLE_LLD AND LLVM_ENABLE_LTO)
Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/Config/config.h.cmake
Expand Up @@ -317,6 +317,9 @@
/* Define to the extension used for shared libraries, say, ".so". */
#cmakedefine LTDL_SHLIB_EXT "${LTDL_SHLIB_EXT}"

/* Define to the extension used for plugin libraries, say, ".so". */
#cmakedefine LLVM_PLUGIN_EXT "${LLVM_PLUGIN_EXT}"

/* Define to the address where bug reports for this package should be sent. */
#cmakedefine PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}"

Expand Down
8 changes: 4 additions & 4 deletions llvm/unittests/Support/DynamicLibrary/CMakeLists.txt
Expand Up @@ -22,7 +22,7 @@ target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
export_executable_symbols(DynamicLibraryTests)

function(dynlib_add_module NAME)
add_library(${NAME} SHARED
add_library(${NAME} MODULE
PipSqueak.cpp
)
set_target_properties(${NAME} PROPERTIES FOLDER "Tests")
Expand All @@ -34,7 +34,7 @@ function(dynlib_add_module NAME)

set_target_properties(${NAME}
PROPERTIES PREFIX ""
SUFFIX ${LTDL_SHLIB_EXT}
SUFFIX ${LLVM_PLUGIN_EXT}
)

add_dependencies(DynamicLibraryTests ${NAME})
Expand All @@ -54,8 +54,8 @@ 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})
string(REPLACE "-Wl,-z,nodelete" "" CMAKE_MODULE_LINKER_FLAGS
${CMAKE_MODULE_LINKER_FLAGS})
endif()

dynlib_add_module(PipSqueak)
Expand Down
Expand Up @@ -26,7 +26,7 @@ std::string LibPath(const std::string Name = "PipSqueak") {
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 + LTDL_SHLIB_EXT).c_str());
path::append(Buf, (Name + LLVM_PLUGIN_EXT).c_str());
return std::string(Buf.str());
}

Expand Down

0 comments on commit e9f9ec8

Please sign in to comment.