]> granicus.if.org Git - gc/commitdiff
Add CMake option to compile all library .c files into single object file
authorIvan Maidanski <ivmai@mail.ru>
Fri, 7 Jun 2019 18:33:32 +0000 (21:33 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 7 Jun 2019 18:33:32 +0000 (21:33 +0300)
Issue #281 (bdwgc).

* CMakeLists.txt (enable_single_obj_compilation): New option (off by
default).
* CMakeLists.txt [enable_single_obj_compilation] (SRC): Override value
to extra/gc.c.
* CMakeLists.txt [enable_single_obj_compilation
&& CMAKE_USE_PTHREADS_INIT]: Define GC_PTHREAD_START_STANDALONE macro.
* CMakeLists.txt [enable_single_obj_compilation
&& CMAKE_USE_PTHREADS_INIT] (SRC): Append pthread_start.c (in addition
to extra/gc.c).

CMakeLists.txt

index 206ef9748108aafdf4d45795c71a50852463e58b..9b0e4306013b6b99a57ff2f18da471ab661ddc77 100644 (file)
@@ -49,6 +49,7 @@ option(enable_munmap "Return page to the OS if empty for N collections" ON)
 option(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON)
 option(enable_register_main_static_data "Perform the initial guess of data root sets" ON)
 option(enable_checksums "Report erroneously cleared dirty bits" OFF)
+option(enable_single_obj_compilation "Compile all libgc source files into single .o" OFF)
 option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON)
 option(install_headers "Install header files" ON)
 
@@ -246,6 +247,14 @@ if (enable_checksums)
   set(SRC ${SRC} checksums.c)
 endif(enable_checksums)
 
+if (enable_single_obj_compilation)
+  set(SRC extra/gc.c) # override SRC
+  if (CMAKE_USE_PTHREADS_INIT)
+    add_definitions("-DGC_PTHREAD_START_STANDALONE")
+    set(SRC ${SRC} pthread_start.c)
+  endif(CMAKE_USE_PTHREADS_INIT)
+endif()
+
 add_library(gc-lib STATIC ${SRC})
 set_target_properties(gc-lib PROPERTIES
                       COMPILE_DEFINITIONS GC_NOT_DLL)