Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/threads-ffi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2015-11-23 23:50:53 +0300
committerSam Gross <colesbury@gmail.com>2015-12-23 01:50:48 +0300
commit369dde36c38c1eac6ce535ffe8c7522fb02f7280 (patch)
tree92bda58e5be091cafe80d8b76a860b8e928f6ad7 /CMakeLists.txt
parent388cf941802d6940875ece7d3b17be228b49a657 (diff)
Load thread's start routine from separate shared library
Prior to this change, if Lua unloads the threads library before the child threads terminate, the program wil segfault. This could happen if an error is triggered during an endcallback, preventing the child thread from exiting. This places the thread's start routine in a separate shared library: libthreadsmain, which is loaded once and never unloaded.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt8
1 files changed, 7 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6b2fcf..a583a6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,9 +20,15 @@ set(luasrc
)
add_torch_package(threads "${src}" "${luasrc}" "Threads")
-
target_link_libraries(threads luaT TH)
+ADD_LIBRARY(threadsmain MODULE lib/thread-main.c)
+IF(APPLE)
+ SET_TARGET_PROPERTIES(threadsmain PROPERTIES
+ LINK_FLAGS "-undefined dynamic_lookup")
+ENDIF()
+INSTALL(TARGETS threadsmain LIBRARY DESTINATION "${Torch_INSTALL_LIB_SUBDIR}")
+
if(WIN32)
add_definitions(-DUSE_WIN_THREADS=1)
else()