[PATCH] D40459: [cmake] Pass -Wl, -z, nodelete on Linux to prevent unloading
Michał Górny via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 27 14:23:39 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319105: [cmake] Pass -Wl,-z,nodelete on Linux to prevent unloading (authored by mgorny).
Changed prior to commit:
https://reviews.llvm.org/D40459?vs=124462&id=124469#toc
Repository:
rL LLVM
https://reviews.llvm.org/D40459
Files:
llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt
Index: llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt
===================================================================
--- llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt
+++ llvm/trunk/unittests/Support/DynamicLibrary/CMakeLists.txt
@@ -24,5 +24,12 @@
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)
Index: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
@@ -151,6 +151,14 @@
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
endif()
+# Pass -Wl,-z,nodelete. This makes sure our shared libraries are not unloaded
+# by dlclose(). We need that since the CLI API relies on cross-references
+# between global objects which became horribly broken when one of the libraries
+# is unloaded.
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete")
+endif()
+
function(append value)
foreach(variable ${ARGN})
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40459.124469.patch
Type: text/x-patch
Size: 1440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171127/2666db66/attachment.bin>
More information about the llvm-commits
mailing list