Export shared and static libraries

This commit is contained in:
2024-01-24 15:10:06 -08:00
parent 2d152b9a62
commit a6a2ad61d9
3 changed files with 33 additions and 16 deletions

View File

@@ -46,15 +46,25 @@ if(HAS_ARM_NEON)
endif() endif()
add_library(${PROJECT_NAME} SHARED ConflictSet.cpp) add_library(${PROJECT_NAME} SHARED ConflictSet.cpp)
target_compile_options(conflict_set PRIVATE -fPIC -fno-exceptions target_compile_options(${PROJECT_NAME} PRIVATE -fPIC -fno-exceptions
-fvisibility=hidden) -fvisibility=hidden)
target_link_options(conflict_set PRIVATE $<$<NOT:$<CONFIG:Debug>>: target_link_options(${PROJECT_NAME} PRIVATE $<$<NOT:$<CONFIG:Debug>>:
-nodefaultlibs -lc>) -nodefaultlibs -lc>)
add_library(${PROJECT_NAME}_static STATIC ConflictSet.cpp)
target_compile_options(conflict_set_static PRIVATE -fno-exceptions
-fvisibility=hidden)
add_custom_command(
TARGET conflict_set_static
POST_BUILD
COMMAND
${CMAKE_OBJCOPY} --keep-global-symbols=${CMAKE_SOURCE_DIR}/symbols.txt
$<TARGET_FILE:${PROJECT_NAME}_static>)
if(NOT APPLE) if(NOT APPLE)
target_link_options( target_link_options(
conflict_set PRIVATE ${PROJECT_NAME} PRIVATE
"LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/linker.map") "LINKER:-export-symbols=${CMAKE_CURRENT_SOURCE_DIR}/linker.map")
endif() endif()
set(TEST_FLAGS -Wall -Wextra -Wpedantic -Wunreachable-code -UNDEBUG) set(TEST_FLAGS -Wall -Wextra -Wpedantic -Wunreachable-code -UNDEBUG)
@@ -105,7 +115,7 @@ endforeach()
# c90 # c90
add_executable(conflict_set_c_api_test conflict_set_c_api_test.c) add_executable(conflict_set_c_api_test conflict_set_c_api_test.c)
target_compile_options(conflict_set_c_api_test PRIVATE ${TEST_FLAGS}) target_compile_options(conflict_set_c_api_test PRIVATE ${TEST_FLAGS})
target_link_libraries(conflict_set_c_api_test PRIVATE conflict_set) target_link_libraries(conflict_set_c_api_test PRIVATE ${PROJECT_NAME})
set_property(TARGET conflict_set_c_api_test PROPERTY C_STANDARD 90) set_property(TARGET conflict_set_c_api_test PROPERTY C_STANDARD 90)
set_property(TARGET conflict_set_c_api_test PROPERTY C_STANDARD_REQUIRED ON) set_property(TARGET conflict_set_c_api_test PROPERTY C_STANDARD_REQUIRED ON)
add_test(NAME conflict_set_c_api_test COMMAND conflict_set_c_api_test) add_test(NAME conflict_set_c_api_test COMMAND conflict_set_c_api_test)
@@ -113,7 +123,7 @@ add_test(NAME conflict_set_c_api_test COMMAND conflict_set_c_api_test)
# c++98 # c++98
add_executable(conflict_set_cxx_api_test conflict_set_cxx_api_test.cpp) add_executable(conflict_set_cxx_api_test conflict_set_cxx_api_test.cpp)
target_compile_options(conflict_set_cxx_api_test PRIVATE ${TEST_FLAGS}) target_compile_options(conflict_set_cxx_api_test PRIVATE ${TEST_FLAGS})
target_link_libraries(conflict_set_cxx_api_test PRIVATE conflict_set) target_link_libraries(conflict_set_cxx_api_test PRIVATE ${PROJECT_NAME})
set_property(TARGET conflict_set_c_api_test PROPERTY CXX_STANDARD 98) set_property(TARGET conflict_set_c_api_test PROPERTY CXX_STANDARD 98)
set_property(TARGET conflict_set_c_api_test PROPERTY CXX_STANDARD_REQUIRED ON) set_property(TARGET conflict_set_c_api_test PROPERTY CXX_STANDARD_REQUIRED ON)
add_test(NAME conflict_set_cxx_api_test COMMAND conflict_set_cxx_api_test) add_test(NAME conflict_set_cxx_api_test COMMAND conflict_set_cxx_api_test)
@@ -127,12 +137,17 @@ target_include_directories(
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>) $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>)
target_include_directories(
${PROJECT_NAME}_static
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>)
set_target_properties( set_target_properties(
${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} ${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}) SOVERSION ${PROJECT_VERSION_MAJOR})
install( install(
TARGETS ${PROJECT_NAME} TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_static
EXPORT ConflictSetConfig EXPORT ConflictSetConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -140,4 +155,5 @@ install(
install(DIRECTORY include/ install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
install(EXPORT ConflictSetConfig DESTINATION share/ConflictSet/cmake) install(EXPORT ConflictSetConfig
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ConflictSet/cmake)

View File

@@ -1042,7 +1042,9 @@ struct Iterator {
int cmp; int cmp;
}; };
namespace {
std::string_view getSearchPath(Arena &arena, Node *n); std::string_view getSearchPath(Arena &arena, Node *n);
}
Iterator lastLeq(Node *n, const std::span<const uint8_t> key) { Iterator lastLeq(Node *n, const std::span<const uint8_t> key) {
auto remaining = key; auto remaining = key;
@@ -1111,8 +1113,10 @@ void insert(Node **self_, std::span<const uint8_t> key, int64_t writeVersion) {
} }
} }
namespace {
std::string printable(std::string_view key); std::string printable(std::string_view key);
std::string printable(const Key &key); std::string printable(const Key &key);
} // namespace
struct __attribute__((visibility("hidden"))) ConflictSet::Impl { struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
void check(const ReadRange *reads, Result *result, int count) const { void check(const ReadRange *reads, Result *result, int count) const {
@@ -1248,6 +1252,8 @@ __attribute__((__visibility__("default"))) void ConflictSet_destroy(void *cs) {
} }
} }
namespace {
std::string printable(std::string_view key) { std::string printable(std::string_view key) {
std::string result; std::string result;
for (uint8_t c : key) { for (uint8_t c : key) {
@@ -1385,6 +1391,8 @@ bool checkCorrectness(Node *node, ReferenceImpl &refImpl) {
return success; return success;
} }
} // namespace
namespace std { namespace std {
void __throw_length_error(const char *) { __builtin_unreachable(); } void __throw_length_error(const char *) { __builtin_unreachable(); }
} // namespace std } // namespace std

View File

@@ -1,7 +0,0 @@
{
global:
*ConflictSet*;
local:
*;
};