Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bdwgc] New port #6405

Merged
merged 13 commits into from
Jun 6, 2019
257 changes: 257 additions & 0 deletions ports/bdwgc/001-install-libraries.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8d386ca5..b94d6358 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,10 @@ include(CTest)

cmake_minimum_required(VERSION 3.1)

+# Customize CMake options by passing "-D<OPTION_NAME>=ON|OFF" in your command line
+option(build_cord "Install cord" ON)
+option(build_tests "Install library tests" ON)
+option(install_headers "Install header files" ON)
option(enable_threads "TODO" OFF) #TODO Support it
option(enable_parallel_mark "Parallelize marking and free list construction" ON)
option(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON)
@@ -52,22 +56,13 @@ add_definitions("-DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION")

if (APPLE)
if ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
- set(CMAKE_OSX_ARCHITECTURES "ppc;i386;x86_64"
+ set(CMAKE_OSX_ARCHITECTURES "x86_64;i386"
CACHE STRING "Build architectures for Mac OS X" FORCE)
endif()
-elseif (WIN32)
+elseif (MSVC)
add_definitions("-D_CRT_SECURE_NO_DEPRECATE")
endif()

-#LIBATOMIC #TODO
-#ADD_LIBRARY(atomic_ops STATIC )
-#SET_TARGET_PROPERTIES(atomic_ops PROPERTIES COMPILE_FLAGS -DNO_DEBUGGING)
-
-
-#LIBGC
-
-include_directories(include)
-include_directories(libatomic_ops/src)

set(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c
mark_rts.c headers.c mark.c obj_map.c blacklst.c finalize.c
@@ -82,12 +77,6 @@ if (enable_threads)
set(LIBS ${LIBS} ${Threads_LIBRARIES})
endif()

-#IF(Threads_FOUND)
-# ADD_DEFINITIONS("")
-#ELSE
-# MESSAGE("Parallel mark requires enable_threads ON" )
-#ENDIF(Threads_FOUND)
-
if (enable_cplusplus)
set(SRC ${SRC} gc_cpp.cc)
endif()
@@ -141,7 +130,7 @@ if (CMAKE_USE_PTHREADS_INIT)
if (enable_parallel_mark)
add_definitions("-DHANDLE_FORK")
endif()
- endif(enable_handle_fork)
+ endif()
set(SRC ${SRC} darwin_stop_world.c)
#TODO darwin_threads=true
endif()
@@ -158,10 +147,10 @@ if (CMAKE_USE_WIN32_THREADS_INIT)
add_definitions("-DTHREAD_LOCAL_ALLOC")
set(SRC ${SRC} thread_local_alloc.c)
endif()
- endif(enable_parallel_mark)
+ endif()
add_definitions("-DEMPTY_GETENV_RESULTS")
set(SRC ${SRC} win32_threads.c)
-endif(CMAKE_USE_WIN32_THREADS_INIT)
+endif()

if (enable_gcj_support)
add_definitions("-DGC_GCJ_SUPPORT")
@@ -169,7 +158,7 @@ if (enable_gcj_support)
add_definitions("-DGC_ENABLE_SUSPEND_THREAD")
endif()
set(SRC ${SRC} gcj_mlc.c)
-endif(enable_gcj_support)
+endif()

if (enable_disclaim)
add_definitions("-DENABLE_DISCLAIM")
@@ -195,7 +184,7 @@ if (enable_gc_debug)
add_definitions("-DMAKE_BACK_GRAPH")
set(SRC ${SRC} backgraph.c)
endif()
-endif(enable_gc_debug)
+endif()

if (enable_redirect_malloc)
if (enable_gc_debug)
@@ -206,7 +195,7 @@ if (enable_redirect_malloc)
add_definitions("-DREDIRECT_MALLOC=GC_malloc")
endif()
add_definitions("-DGC_USE_DLOPEN_WRAP")
-endif(enable_redirect_malloc)
+endif()

if (enable_munmap)
add_definitions("-DUSE_MMAP -DUSE_MUNMAP")
@@ -240,19 +229,44 @@ if (enable_checksums)
endif()
add_definitions("-DCHECKSUMS")
set(SRC ${SRC} checksums.c)
-endif(enable_checksums)
-
-add_library(gc-lib STATIC ${SRC})
-set_target_properties(gc-lib PROPERTIES
- COMPILE_DEFINITIONS GC_NOT_DLL)
-#TODO TARGET_LINK_LIBRARIES(... ... ${LIBS})
+endif()

-add_library(gcmt-lib STATIC ${SRC})
-set_target_properties(gcmt-lib PROPERTIES
- COMPILE_DEFINITIONS GC_NOT_DLL)
+# Create target
+add_library(gc ${SRC})
+target_include_directories(gc
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include>
+)
+if (NOT BUILD_SHARED_LIBS)
+ target_compile_definitions(gc PRIVATE GC_NOT_DLL)
+else()
+ target_compile_definitions(gc PRIVATE GC_DLL)
+endif()

-add_library(gcmt-dll SHARED ${SRC})
+# Install library
+install(
+ TARGETS gc
+ EXPORT gcExports
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin
+ INCLUDES DESTINATION include
+)
+
+# Install headers
+if (install_headers)
+ file(GLOB BDWGC_HEADERS "include/*.h")
+ install(FILES ${BDWGC_HEADERS} DESTINATION include/gc)
+
+ file(GLOB BDWGC_EXTRA_HEADERS "include/extra/*.h")
+ install(FILES ${BDWGC_EXTRA_HEADERS} DESTINATION include)
+endif()

-add_subdirectory(cord)
+if (build_cord)
+ add_subdirectory(cord)
+endif()

-add_subdirectory(tests)
+if (build_tests)
+ add_subdirectory(tests)
+endif()
diff --git a/cord/CMakeLists.txt b/cord/CMakeLists.txt
index 17077370..21818d4e 100644
--- a/cord/CMakeLists.txt
+++ b/cord/CMakeLists.txt
@@ -11,11 +11,11 @@
# modified is included with the above copyright notice.
##

+add_executable(cord cordbscs.c cordxtra.c tests/de.c tests/de_win.c)
+set_target_properties(cord PROPERTIES COMPILE_DEFINITIONS GC_NOT_DLL)
+target_link_libraries(cord PRIVATE gc)
+
if (WIN32)
- add_executable(cord cordbscs.c cordxtra.c
- tests/de.c tests/de_win.c)
set_target_properties(cord PROPERTIES WIN32_EXECUTABLE TRUE)
- set_target_properties(cord PROPERTIES COMPILE_DEFINITIONS GC_NOT_DLL)
- target_link_libraries(cord gc-lib)
- target_link_libraries(cord gdi32)
+ target_link_libraries(cord PRIVATE gdi32)
endif()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c6bcc7d7..32a021e7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -14,8 +14,6 @@
# modified is included with the above copyright notice.
##

-add_definitions("-DGC_NOT_DLL")
-
# Compile some tests as C++ to test extern "C" in header files.
if (enable_cplusplus)
set_source_files_properties(leak_test.c test.c
@@ -23,51 +21,51 @@ if (enable_cplusplus)
endif()

add_executable(gctest WIN32 test.c)
-target_link_libraries(gctest gc-lib)
+target_link_libraries(gctest PRIVATE gc)
add_test(NAME gctest COMMAND gctest)

add_executable(hugetest huge_test.c)
-target_link_libraries(hugetest gc-lib)
+target_link_libraries(hugetest PRIVATE gc)
add_test(NAME hugetest COMMAND hugetest)

add_executable(leaktest leak_test.c)
-target_link_libraries(leaktest gc-lib)
+target_link_libraries(leaktest PRIVATE gc)
add_test(NAME leaktest COMMAND leaktest)

add_executable(middletest middle.c)
-target_link_libraries(middletest gc-lib)
+target_link_libraries(middletest PRIVATE gc)
add_test(NAME middletest COMMAND middletest)

add_executable(realloc_test realloc_test.c)
-target_link_libraries(realloc_test gc-lib)
+target_link_libraries(realloc_test PRIVATE gc)
add_test(NAME realloc_test COMMAND realloc_test)

add_executable(smashtest smash_test.c)
-target_link_libraries(smashtest gc-lib)
+target_link_libraries(smashtest PRIVATE gc)
add_test(NAME smashtest COMMAND smashtest)

if (enable_gc_debug)
add_executable(tracetest trace_test.c)
- target_link_libraries(tracetest gc-lib)
+ target_link_libraries(tracetest PRIVATE gc)
add_test(NAME tracetest COMMAND tracetest)
endif()

if (enable_cplusplus)
# TODO add_executable(test_cpp test_cpp.cc)
- # target_link_libraries(test_cpp gc-lib)
+ # target_link_libraries(test_cpp PRIVATE gc)
# add_test(NAME test_cpp COMMAND test_cpp)
endif()

if (enable_disclaim)
add_executable(disclaim_bench disclaim_bench.c)
- target_link_libraries(disclaim_bench gc-lib)
+ target_link_libraries(disclaim_bench PRIVATE gc)
add_test(NAME disclaim_bench COMMAND disclaim_bench)

add_executable(disclaim_test disclaim_test.c)
- target_link_libraries(disclaim_test gc-lib)
+ target_link_libraries(disclaim_test PRIVATE gc)
add_test(NAME disclaim_test COMMAND disclaim_test)

add_executable(disclaim_weakmap_test disclaim_weakmap_test.c)
- target_link_libraries(disclaim_weakmap_test gc-lib)
+ target_link_libraries(disclaim_weakmap_test PRIVATE gc)
add_test(NAME disclaim_weakmap_test COMMAND disclaim_weakmap_test)
endif()

3 changes: 3 additions & 0 deletions ports/bdwgc/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Source: bdwgc
Version: 8.0.4-1
Description: The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (libgc, bdwgc, boehm-gc)
31 changes: 31 additions & 0 deletions ports/bdwgc/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
include(vcpkg_common_functions)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ivmai/bdwgc
# REF v8.0.4
# SHA512 f3c178c9cab9d9df9ecdad5ac5661c916518d29b0eaca24efe569cb757c386c118ad4389851107597d99ff1bbe99b46383cce73dfd01be983196aa57c9626a4a
REF 0c8905e84d16bd5e14ed91e21904fd7ab9d197e2
SHA512 b38fe86d0dfaacd502971e39ea7df83a3dbf5542711f6b0462b7a6d48dbcf43da07a41a60ee96bca6403a2d2adaac0815a64667f3c80549ca57c5ebbe0e9672d
HEAD_REF master
PATCHES
001-install-libraries.patch
)


vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-Dbuild_tests=OFF
-Dbuild_cord=OFF
OPTIONS_DEBUG
-Dinstall_headers=OFF
)

vcpkg_install_cmake()

vcpkg_copy_pdbs()

# Handle copyright
file(INSTALL ${SOURCE_PATH}/README.QUICK DESTINATION ${CURRENT_PACKAGES_DIR}/share/bdwgc RENAME copyright)