# Needed by LLVM's CMake checks because this file defines multiple targets.
set(LLVM_OPTIONAL_SOURCES ExportedFuncs.cpp PipSqueak.cpp)

set(LLVM_LINK_COMPONENTS Support)

add_library(DynamicLibraryLib STATIC
  ExportedFuncs.cpp
  )
set_target_properties(DynamicLibraryLib PROPERTIES FOLDER "Tests")

add_llvm_unittest(DynamicLibraryTests
  DynamicLibraryTest.cpp
  )
target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
export_executable_symbols(DynamicLibraryTests)

function(dynlib_add_module NAME)
  add_library(${NAME} MODULE
    PipSqueak.cpp
    )
  set_target_properties(${NAME} PROPERTIES FOLDER "Tests")

  set_output_directory(${NAME}
    BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
    LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
    )

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

  add_dependencies(DynamicLibraryTests ${NAME})
endfunction(dynlib_add_module)

dynlib_add_module(PipSqueak)
dynlib_add_module(SecondLib)

# Needed by LLVM's CMake checks because this file defines multiple targets.
set(LLVM_OPTIONAL_SOURCES ExportedFuncs.cpp PipSqueak.cpp)

set(LLVM_LINK_COMPONENTS Support)

add_library(DynamicLibraryLib STATIC
  ExportedFuncs.cpp
  )
set_target_properties(DynamicLibraryLib PROPERTIES FOLDER "Tests")

add_llvm_unittest(DynamicLibraryTests
  DynamicLibraryTest.cpp
  )
target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
export_executable_symbols(DynamicLibraryTests)

function(dynlib_add_module NAME)
  add_library(${NAME} SHARED
    PipSqueak.cpp
    )
  set_target_properties(${NAME} PROPERTIES FOLDER "Tests")

  set_output_directory(${NAME}
    BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
    LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
    )

  set_target_properties(${NAME}
    PROPERTIES PREFIX ""
    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)

Change linker flags of dynamic library tests
[Unittests] Change linker flags of dynamic library tests

A recent change https://reviews.llvm.org/D46898 which had no intended
behavior change, actually modified the linker flags used when linking
the dynamic libraries used by the DynamicLibraryTests unit test. This
made the test fail in our testing environment which runs the tests
from an NFS share. Prior to D46898 the two libraries used by the test
were different (because the library name used to be embedded into the
binary), and after the change they became bit-to-bit identical. This
causes dlopen to return the same handle when these two libraries are
loaded from an NFS share, and the test expects two different handles.

This patch reverts the part of D46898 that is responsible for
changing the linker flags.

Differential Revision: https://reviews.llvm.org/D47469


git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@334394 91177308-0d34-0410-b5e6-96231b3b80d8
