From fb8139e8d86b3f0e9357e7b95d1212d5dabf3960 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 20 Nov 2023 18:48:48 +0200 Subject: [PATCH 01/19] Remove `TILEDB_STATIC` and unify `tiledb_static` and `tiledb_shared`. --- .github/workflows/mingw-w64-tiledb/PKGBUILD | 1 - cmake/Options/BuildOptions.cmake | 2 +- cmake/TileDB-Superbuild.cmake | 2 +- cmake/inputs/Config.cmake.in | 7 +- examples/c_api/CMakeLists.txt | 25 +--- examples/cmake_project/CMakeLists.txt | 8 +- examples/cpp_api/CMakeLists.txt | 4 +- examples/png_ingestion/CMakeLists.txt | 2 +- .../cpp_api/CMakeLists.txt | 4 +- test/benchmarking/src/CMakeLists.txt | 2 +- test/regression/CMakeLists.txt | 2 +- tiledb/CMakeLists.txt | 125 +++--------------- tools/CMakeLists.txt | 8 +- 13 files changed, 41 insertions(+), 151 deletions(-) diff --git a/.github/workflows/mingw-w64-tiledb/PKGBUILD b/.github/workflows/mingw-w64-tiledb/PKGBUILD index 1ec3de5f780..7c54c04e909 100644 --- a/.github/workflows/mingw-w64-tiledb/PKGBUILD +++ b/.github/workflows/mingw-w64-tiledb/PKGBUILD @@ -31,7 +31,6 @@ build() { -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=Release \ - -DTILEDB_STATIC=ON \ -DTILEDB_TESTS=OFF \ -DTILEDB_S3=ON \ -DCOMPILER_SUPPORTS_AVX2=OFF \ diff --git a/cmake/Options/BuildOptions.cmake b/cmake/Options/BuildOptions.cmake index 6714907c34a..bb5e3e732ed 100644 --- a/cmake/Options/BuildOptions.cmake +++ b/cmake/Options/BuildOptions.cmake @@ -21,7 +21,7 @@ option(TILEDB_ASSERTIONS "Build with assertions enabled (default off for release option(TILEDB_CPP_API "Enables building of the TileDB C++ API." ON) option(TILEDB_CMAKE_IDE "(Used for CLion builds). Disables superbuild and sets the EP install dir." OFF) option(TILEDB_STATS "Enables internal TileDB statistics gathering." ON) -option(TILEDB_STATIC "Enables building TileDB as a static library." OFF) +option(BUILD_SHARED_LIBS "Enables building TileDB as a shared library." OFF) option(TILEDB_TESTS "If true, enables building the TileDB unit test suite" ON) option(TILEDB_TOOLS "If true, enables building the TileDB tools" OFF) option(TILEDB_SERIALIZATION "If true, enables building with support for query serialization" OFF) diff --git a/cmake/TileDB-Superbuild.cmake b/cmake/TileDB-Superbuild.cmake index 14378b7f1c5..bc2c4eeb0cb 100644 --- a/cmake/TileDB-Superbuild.cmake +++ b/cmake/TileDB-Superbuild.cmake @@ -24,6 +24,7 @@ list(JOIN CMAKE_PREFIX_PATH "|" CMAKE_PREFIX_PATH_STR) # Forward any additional CMake args to the non-superbuild. set(INHERITED_CMAKE_ARGS + -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_STR} -DCMAKE_BUILD_TYPE=$ @@ -47,7 +48,6 @@ set(INHERITED_CMAKE_ARGS -DSANITIZER=${SANITIZER} -DTILEDB_EP_BASE=${TILEDB_EP_BASE} -DTILEDB_STATS=${TILEDB_STATS} - -DTILEDB_STATIC=${TILEDB_STATIC} -DTILEDB_TESTS=${TILEDB_TESTS} -DTILEDB_TOOLS=${TILEDB_TOOLS} -DTILEDB_SERIALIZATION=${TILEDB_SERIALIZATION} diff --git a/cmake/inputs/Config.cmake.in b/cmake/inputs/Config.cmake.in index 49c85082268..13ebd726187 100644 --- a/cmake/inputs/Config.cmake.in +++ b/cmake/inputs/Config.cmake.in @@ -1,8 +1,7 @@ # # This file attempts to locate the TileDB library. If found, the following # imported targets are created: -# - TileDB::tiledb_shared -# - TileDB::tiledb_static +# - TileDB::tiledb # And the following variables are defined: # - TILEDB_FOUND # - TileDB_FOUND @@ -10,7 +9,7 @@ @PACKAGE_INIT@ -if(@TILEDB_STATIC@) # TILEDB_STATIC +if(NOT @BUILD_SHARED_LIBS@) # NOT BUILD_SHARED_LIBS include(CMakeFindDependencyMacro) find_dependency(Threads) find_dependency(BZip2) @@ -45,7 +44,7 @@ check_required_components("@PROJECT_NAME@") # Define a convenience all-caps variable if (NOT DEFINED TILEDB_FOUND) - if (TARGET TileDB::tiledb_shared) + if (TARGET TileDB::tiledb) set(TILEDB_FOUND TRUE) else() set(TILEDB_FOUND FALSE) diff --git a/examples/c_api/CMakeLists.txt b/examples/c_api/CMakeLists.txt index e145d35d4ac..e52506ebb09 100644 --- a/examples/c_api/CMakeLists.txt +++ b/examples/c_api/CMakeLists.txt @@ -31,16 +31,12 @@ set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) # Don't use GNU extensions # Add custom target 'examples_c' -add_custom_target(examples_c DEPENDS tiledb_shared) - -if (TILEDB_STATIC) - add_custom_target(static_examples_c DEPENDS tiledb_static) -endif() +add_custom_target(examples_c) # Function that builds an executable per example function(build_TileDB_example_capi TARGET) add_executable(${TARGET}_c EXCLUDE_FROM_ALL ${TARGET}.c) - target_link_libraries(${TARGET}_c PUBLIC local_install tiledb_shared) + target_link_libraries(${TARGET}_c PUBLIC local_install tiledb) if (NOT WIN32) # On Linux, must explicitly link -lpthread -ldl in order for static linking # to libzstd or libcurl to work. @@ -49,20 +45,6 @@ function(build_TileDB_example_capi TARGET) add_dependencies(examples_c ${TARGET}_c) endfunction() -function(build_TileDB_static_example_capi TARGET) - add_executable(static_${TARGET}_c EXCLUDE_FROM_ALL ${TARGET}.c) - target_include_directories(static_${TARGET}_c PUBLIC - "${CMAKE_CURRENT_BINARY_DIR}/../" - ) - target_link_libraries(static_${TARGET}_c tiledb_static) - if (NOT WIN32) - # On Linux, must explicitly link -lpthread -ldl in order for static linking - # to libzstd or libcurl to work. - target_link_libraries(static_${TARGET}_c pthread dl) - endif() - add_dependencies(static_examples_c static_${TARGET}_c) -endfunction() - # Get the example sources file(GLOB TILEDB_EXAMPLE_SOURCES_CAPI "*.c") @@ -80,7 +62,4 @@ foreach(EXAMPLE_SOURCE ${TILEDB_EXAMPLE_SOURCES_CAPI}) # Build example executable build_TileDB_example_capi(${EXAMPLE_BIN}) - if (TILEDB_STATIC) - build_TileDB_static_example_capi(${EXAMPLE_BIN}) - endif() endforeach() diff --git a/examples/cmake_project/CMakeLists.txt b/examples/cmake_project/CMakeLists.txt index f002264d3de..31dcd48d53c 100644 --- a/examples/cmake_project/CMakeLists.txt +++ b/examples/cmake_project/CMakeLists.txt @@ -50,10 +50,4 @@ add_executable(ExampleExe "src/main.cc") # Link the example program with the TileDB shared library. # This also configures include paths to find the TileDB headers. -target_link_libraries(ExampleExe TileDB::tiledb_shared) - -# Link a second executable with the TileDB static library, if it is available. -if (TARGET TileDB::tiledb_static) - add_executable(ExampleExe_static "src/main.cc") - target_link_libraries(ExampleExe_static TileDB::tiledb_static) -endif() +target_link_libraries(ExampleExe TileDB::tiledb) diff --git a/examples/cpp_api/CMakeLists.txt b/examples/cpp_api/CMakeLists.txt index 134904eb5ad..0226f9f2b6e 100644 --- a/examples/cpp_api/CMakeLists.txt +++ b/examples/cpp_api/CMakeLists.txt @@ -26,12 +26,12 @@ # # Add custom target 'examples_cpp' -add_custom_target(examples_cpp DEPENDS tiledb_shared) +add_custom_target(examples_cpp) # Function that builds an executable per example function(build_TileDB_example_cppapi TARGET) add_executable(${TARGET}_cpp EXCLUDE_FROM_ALL ${TARGET}.cc) - target_link_libraries(${TARGET}_cpp PUBLIC local_install tiledb_shared) + target_link_libraries(${TARGET}_cpp PUBLIC local_install tiledb) if (NOT WIN32) # On Linux, must explicitly link -lpthread -ldl in order for static linking # to libzstd or libcurl to work. diff --git a/examples/png_ingestion/CMakeLists.txt b/examples/png_ingestion/CMakeLists.txt index 2e791c8c18f..6bdf16546c2 100644 --- a/examples/png_ingestion/CMakeLists.txt +++ b/examples/png_ingestion/CMakeLists.txt @@ -50,7 +50,7 @@ add_executable(tiledb_png "src/main.cc") # Link the example program with the TileDB shared library. # This also configures include paths to find the TileDB headers. -target_link_libraries(tiledb_png TileDB::tiledb_shared) +target_link_libraries(tiledb_png TileDB::tiledb) # Find and link with libpng. find_package(Zlib_EP REQUIRED) diff --git a/experimental/experimental_examples/cpp_api/CMakeLists.txt b/experimental/experimental_examples/cpp_api/CMakeLists.txt index 8da6d16d2d2..192c3189282 100644 --- a/experimental/experimental_examples/cpp_api/CMakeLists.txt +++ b/experimental/experimental_examples/cpp_api/CMakeLists.txt @@ -25,14 +25,14 @@ # THE SOFTWARE. # -add_custom_target(experimental_examples_cpp DEPENDS tiledb_shared) +add_custom_target(experimental_examples_cpp) find_package(Bzip2_EP REQUIRED) # Function that builds an executable per example function(build_TileDB_experimental_example_cppapi TARGET) add_executable(${TARGET}_exp_cpp EXCLUDE_FROM_ALL ${TARGET}.cc) - target_link_libraries(${TARGET}_exp_cpp PUBLIC local_install tiledb_shared) + target_link_libraries(${TARGET}_exp_cpp PUBLIC local_install tiledb) target_link_libraries(${TARGET}_exp_cpp PUBLIC BZip2::BZip2) if (NOT WIN32) # On Linux, must explicitly link -lpthread -ldl in order for static linking diff --git a/test/benchmarking/src/CMakeLists.txt b/test/benchmarking/src/CMakeLists.txt index 07d08b5ded2..2fe1ebe0936 100644 --- a/test/benchmarking/src/CMakeLists.txt +++ b/test/benchmarking/src/CMakeLists.txt @@ -72,5 +72,5 @@ foreach(NAME IN LISTS BENCHMARKS) "${NAME}.cc" $ ) - target_link_libraries(${NAME} TileDB::tiledb_shared pthread) + target_link_libraries(${NAME} TileDB::tiledb pthread) endforeach() diff --git a/test/regression/CMakeLists.txt b/test/regression/CMakeLists.txt index 3fa7e3c2886..37574bf6159 100644 --- a/test/regression/CMakeLists.txt +++ b/test/regression/CMakeLists.txt @@ -67,7 +67,7 @@ target_link_libraries(tiledb_regression PUBLIC Catch2::Catch2WithMain local_install - tiledb_shared + tiledb ) target_include_directories(tiledb_regression diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index 123c0a726d6..a35bd154b5a 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -474,31 +474,6 @@ target_include_directories(TILEDB_CORE_OBJECTS "${CMAKE_CURRENT_BINARY_DIR}/.." ) -# Build a separate copy of the object library for use with static TileDB -# on Windows. See https://github.com/TileDB-Inc/TileDB/issues/673 -if (WIN32 AND TILEDB_STATIC) - add_library(TILEDB_CORE_OBJECTS_STATIC OBJECT - ${TILEDB_CORE_SOURCES} - ${TILEDB_EXTERNALS_SOURCES} - ) - add_dependencies(TILEDB_CORE_OBJECTS_STATIC gen_mgc_unarch) - - target_sources(TILEDB_CORE_OBJECTS_STATIC - PUBLIC - ${TILEDB_CORE_OBJECTS_LIBS_SOURCES} - ) - - target_link_libraries(TILEDB_CORE_OBJECTS_STATIC - PUBLIC - ${TILEDB_CORE_OBJECTS_LIBS} - ) - - target_compile_definitions(TILEDB_CORE_OBJECTS_STATIC - PRIVATE - -DTILEDB_STATIC_DEFINE - ) -endif() - if (TILEDB_CPP_API) target_include_directories(TILEDB_CORE_OBJECTS PRIVATE @@ -829,11 +804,6 @@ if(TILEDB_SERIALIZATION) target_sources(TILEDB_CORE_OBJECTS PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/sm/serialization/tiledb-rest.capnp.c++ ) - if (WIN32 AND TILEDB_STATIC) - target_sources(TILEDB_CORE_OBJECTS_STATIC PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/sm/serialization/tiledb-rest.capnp.c++ - ) - endif() ################################### # capnproto file generation target @@ -878,10 +848,10 @@ endif() ############################################################ -# TileDB static and shared library targets +# TileDB library targets ############################################################ -add_library(tiledb_shared SHARED $) +add_library(tiledb $) file(READ "${CMAKE_CURRENT_SOURCE_DIR}/sm/c_api/tiledb_version.h" ver) @@ -907,80 +877,32 @@ if (WIN32) ) # The .rc file will be created elsewhere (currently below) via configure_file() - target_sources(tiledb_shared PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/tiledb_win32_verinfo.rc) - target_include_directories(tiledb_shared + target_sources(tiledb PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/tiledb_win32_verinfo.rc) + target_include_directories(tiledb PRIVATE "${TILEDB_CORE_INCLUDE_DIR}" ) endif() -# Target properties -set_target_properties(tiledb_shared - PROPERTIES - OUTPUT_NAME "tiledb" -) - if (TILEDB_VERSION AND CMAKE_SYSTEM_NAME MATCHES "Linux") - set_target_properties(tiledb_shared + set_target_properties(tiledb PROPERTIES SOVERSION "${TILEDB_VERSION_MAJOR}.${TILEDB_VERSION_MINOR}") endif() # Link the dependencies specified earlier -target_link_libraries(tiledb_shared +target_link_libraries(tiledb PRIVATE $ - TILEDB_CORE_OBJECTS + $ ) -if (TILEDB_STATIC) - if (WIN32) - # Copy over all include directories, compile options, etc, from the regular - # core objects. - target_compile_definitions(TILEDB_CORE_OBJECTS_STATIC - PRIVATE - $ - ) - target_compile_options(TILEDB_CORE_OBJECTS_STATIC - PRIVATE - $ - ) - target_include_directories(TILEDB_CORE_OBJECTS_STATIC - PRIVATE - $ - ) - # Create the target - add_library(tiledb_static STATIC - $) - target_link_libraries(tiledb_static - PRIVATE - $ - ) - target_compile_definitions(tiledb_static - INTERFACE - -DTILEDB_STATIC_DEFINE - ) - # On Windows we must name the static library something else to avoid - # name clash with the DLL's "import library" .lib file. - set_target_properties(tiledb_static - PROPERTIES - OUTPUT_NAME "tiledbstatic" - ) - else() - add_library(tiledb_static STATIC $) - target_link_libraries(tiledb_static - PRIVATE - $ - ) - set_target_properties(tiledb_static - PROPERTIES - OUTPUT_NAME "tiledb" - ) - endif() - - target_link_libraries(tiledb_static - PRIVATE - $ +if (WIN32 AND NOT BUILD_SHARED_LIBS) + # On Windows we must name the static library something else to avoid + # name clash with the DLL's "import library" .lib file. + set_target_properties(tiledb + PROPERTIES + OUTPUT_NAME "tiledbstatic" ) endif() @@ -992,7 +914,7 @@ endif() # Generates the file 'tiledb_export.h' suitable for the current compiler. include(GenerateExportHeader) -generate_export_header(TILEDB_CORE_OBJECTS +generate_export_header(tiledb BASE_NAME tiledb ) # Install locally @@ -1007,23 +929,17 @@ list(APPEND TILEDB_PUBLIC_HEADERS ) # Set the public headers, which are the ones that get installed. -set_target_properties(tiledb_shared +set_target_properties(tiledb PROPERTIES PUBLIC_HEADER "${TILEDB_PUBLIC_HEADERS}" ) -if (TILEDB_STATIC) - set_target_properties(tiledb_static - PROPERTIES - PUBLIC_HEADER "${TILEDB_PUBLIC_HEADERS}" - ) -endif() # Don't re-export symbols from static (archive) libraries # Prevents conflicts with other versions of (e.g.) OpenSSL # loaded in the same process namespace, which can cause # crashes if the versions are not compatible. if (CMAKE_SYSTEM_NAME MATCHES "Linux") - set_target_properties(tiledb_shared + set_target_properties(tiledb PROPERTIES LINK_FLAGS "-Wl,--exclude-libs=ALL") endif() @@ -1038,8 +954,8 @@ include(GNUInstallDirs) include(CMakePackageConfigHelpers) # Set rpath so the TileDB dynamic dependencies can be located. -if (NOT WIN32) - set_target_properties(tiledb_shared +if (BUILD_SHARED_LIBS AND NOT WIN32) + set_target_properties(tiledb PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" ) @@ -1052,11 +968,10 @@ endif() # List of targets to install. set(TILEDB_INSTALL_TARGETS - tiledb_shared + tiledb ) -if (TILEDB_STATIC) +if (NOT BUILD_SHARED_LIBS) list(APPEND TILEDB_INSTALL_TARGETS - tiledb_static TILEDB_CORE_OBJECTS_ILIB object_store_definitions ) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 218e238029e..a2bf0edd0c9 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -31,14 +31,18 @@ else() find_package(Clipp_EP REQUIRED) endif() -add_executable(tiledb EXCLUDE_FROM_ALL +add_executable(tiledb-cli EXCLUDE_FROM_ALL src/commands/help_command.cc src/commands/info_command.cc src/main/tiledb.cc ) +set_target_properties(tiledb-cli PROPERTIES + OUTPUT_NAME tiledb +) + # List of all tool targets -set(TILEDB_TOOLS tiledb) +set(TILEDB_TOOLS tiledb-cli) # Set up link and include directories for all tools foreach(TOOL ${TILEDB_TOOLS}) From 35732e80034535127fc7b8763c2e8ba45b7dcc97 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 20 Nov 2023 18:39:12 +0200 Subject: [PATCH 02/19] Add bootstrap script options to set `BUILD_SHARED_LIBS`. --- bootstrap | 15 ++++++++++----- bootstrap.ps1 | 14 +++++++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/bootstrap b/bootstrap index 8ade2249dab..868e0dd5c84 100755 --- a/bootstrap +++ b/bootstrap @@ -47,7 +47,8 @@ Configuration: --disable-avx2 disables use of AVX2 instructions --disable-webp disables building of webp library and linkage test --disable-vcpkg disables use of vcpkg for downloading and building dependencies - --enable-static-tiledb enables building TileDB as a static library + --enable-static-tiledb enables building TileDB as a static library (this is the default) + --enable-shared-tiledb enables building TileDB as a shared library --enable-sanitizer=SAN enable sanitizer (clang only) (address|memory|leak|thread|undefined) --enable-debug enable debug build @@ -103,7 +104,7 @@ tiledb_cpp_api="ON" tiledb_force_all_deps="OFF" tiledb_remove_deprecations="OFF" tiledb_stats="ON" -tiledb_static="OFF" +build_shared_libs="OFF" tiledb_disable_avx2="" tiledb_assertions="OFF" tiledb_serialization="OFF" @@ -144,7 +145,9 @@ while test $# != 0; do --enable-azure) tiledb_azure="ON";; --enable-gcs) tiledb_gcs="ON";; --enable-serialization) tiledb_serialization="ON";; - --enable-static-tiledb) tiledb_static="ON";; + --enable-static-tiledb) echo "Argument '--enable-static-tiledb' is obsolete and will be removed in a future version. TileDB is now built as a static library by default." + build_shared_libs="OFF";; + --enable-shared-tiledb) build_shared_libs="ON";; --enable-sanitizer=*) san=`arg "$1"` sanitizer="$san";; --enable-tools) tiledb_tools="ON";; @@ -184,7 +187,9 @@ for en in "${enables[@]}"; do _crc32) tiledb_build_crc32="ON";; abseil) tiledb_build_abseil="ON";; hdfs) tiledb_hdfs="ON";; - static-tiledb) tiledb_static="ON";; + static-tiledb) echo "Argument '--enable-static-tiledb' is obsolete and will be removed in a future version. TileDB is now built as a static library by default." + build_shared_libs="OFF";; + shared-tiledb) build_shared_libs="ON";; experimental-features) tiledb_experimental_features="ON";; rest-tests) tiledb_tests_enable_rest="ON";; aws-s3-config) tiledb_tests_aws_s3_config="ON";; @@ -231,6 +236,7 @@ ${cmake} -DCMAKE_BUILD_TYPE=${build_type} \ -DCMAKE_C_COMPILER="${c_compiler}" \ -DCMAKE_CXX_COMPILER="${cxx_compiler}" \ -DCMAKE_PREFIX_PATH="${dependency_dir}" \ + -DBUILD_SHARED_LIBS=${build_shared_libs} \ -DTILEDB_VCPKG=${tiledb_vcpkg} \ -DTILEDB_ASSERTIONS=${tiledb_assertions} \ -DTILEDB_VERBOSE=${tiledb_verbose} \ @@ -243,7 +249,6 @@ ${cmake} -DCMAKE_BUILD_TYPE=${build_type} \ -DTILEDB_WERROR=${tiledb_werror} \ -DTILEDB_CPP_API=${tiledb_cpp_api} \ -DTILEDB_STATS=${tiledb_stats} \ - -DTILEDB_STATIC=${tiledb_static} \ -DTILEDB_TESTS=${tiledb_tests} \ -DTILEDB_CCACHE=${tiledb_ccache} \ -DTILEDB_ARROW_TESTS=${tiledb_arrow_tests} \ diff --git a/bootstrap.ps1 b/bootstrap.ps1 index 6c3c0358406..1a1d49986e4 100644 --- a/bootstrap.ps1 +++ b/bootstrap.ps1 @@ -58,6 +58,10 @@ Enables building with serialization support. .PARAMETER EnableStaticTileDB Enables building TileDB as a static library. +Deprecated, this is now the default behavior. + +.PARAMETER EnableSharedTileDB +Enables building TileDB as a shared library. .PARAMETER EnableBuildDeps Enables building TileDB dependencies from source (superbuild) @@ -132,6 +136,7 @@ Param( [switch]$EnableGcs, [switch]$EnableSerialization, [switch]$EnableStaticTileDB, + [switch]$EnableSharedTileDB, [switch]$EnableTools, [switch]$EnableExperimentalFeatures, [switch]$EnableAbseil, @@ -248,9 +253,12 @@ if ($DisableWebP.IsPresent) { $BuildWebP="OFF" } -$TileDBStatic = "OFF"; +$BuildSharedLibs = "OFF"; if ($EnableStaticTileDB.IsPresent) { - $TileDBStatic = "ON" + Write-Warning "-EnableStaticTileDB is deprecated and will be removed in a future version. TileDB is now built as a static library by default. Use -EnableSharedTileDB to build a shared library." +} +elseif ($EnableSharedTileDB.IsPresent) { + $BuildSharedLibs = "ON" } $TileDBTools = "OFF"; @@ -326,7 +334,7 @@ if ($CMakeGenerator -eq $null) { # Run CMake. # We use Invoke-Expression so we can echo the command to the user. -$CommandString = "cmake -A X64 -DTILEDB_VCPKG=$UseVcpkg -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" -DCMAKE_PREFIX_PATH=""$DependencyDir"" -DMSVC_MP_FLAG=""/MP$BuildProcesses"" -DTILEDB_ASSERTIONS=$AssertionMode -DTILEDB_VERBOSE=$Verbosity -DTILEDB_AZURE=$UseAzure -DTILEDB_S3=$UseS3 -DTILEDB_GCS=$UseGcs -DTILEDB_SERIALIZATION=$UseSerialization -DTILEDB_WERROR=$Werror -DTILEDB_CPP_API=$CppApi -DTILEDB_TESTS=$Tests -DTILEDB_STATS=$Stats -DTILEDB_STATIC=$TileDBStatic -DTILEDB_FORCE_ALL_DEPS=$TileDBBuildDeps -DTILEDB_REMOVE_DEPRECATIONS=$RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_ENABLE_REST=$RestTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory""" +$CommandString = "cmake -A X64 -DTILEDB_VCPKG=$UseVcpkg -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" -DCMAKE_PREFIX_PATH=""$DependencyDir"" -DMSVC_MP_FLAG=""/MP$BuildProcesses"" -DTILEDB_ASSERTIONS=$AssertionMode -DTILEDB_VERBOSE=$Verbosity -DTILEDB_AZURE=$UseAzure -DTILEDB_S3=$UseS3 -DTILEDB_GCS=$UseGcs -DTILEDB_SERIALIZATION=$UseSerialization -DTILEDB_WERROR=$Werror -DTILEDB_CPP_API=$CppApi -DTILEDB_TESTS=$Tests -DTILEDB_STATS=$Stats -DBUILD_SHARED_LIBS=$BuildSharedLibs -DTILEDB_FORCE_ALL_DEPS=$TileDBBuildDeps -DTILEDB_REMOVE_DEPRECATIONS=$RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_ENABLE_REST=$RestTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory""" Write-Host $CommandString Write-Host Invoke-Expression "$CommandString" From e04fd2d344e8b4886bdb49c8dea4c159990334c4 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 20 Nov 2023 18:43:44 +0200 Subject: [PATCH 03/19] Update the release script to build shared libraries. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2eb12cad3ba..77f894ce7f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,6 +82,7 @@ jobs: run: | cmake -S . -B build \ -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ -DCMAKE_INSTALL_PREFIX=./dist \ -DTILEDB_S3=ON \ -DTILEDB_AZURE=ON \ @@ -89,7 +90,6 @@ jobs: -DTILEDB_HDFS=${{ startsWith(matrix.platform, 'windows') && 'OFF' || 'ON' }} \ -DTILEDB_SERIALIZATION=ON \ -DTILEDB_WEBP=ON \ - -DTILEDB_STATIC=OFF \ -DTILEDB_TESTS=OFF \ -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \ ${{ matrix.cmake_args }} From 7b90b532c26a1d3b4f618020578f5c80bf1c9113 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 20 Nov 2023 18:47:11 +0200 Subject: [PATCH 04/19] Add `TileDB::tiledb_static` and `TileDB::tiledb_shared` exported alias targets. --- cmake/inputs/Config.cmake.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/inputs/Config.cmake.in b/cmake/inputs/Config.cmake.in index 13ebd726187..a7a91aa6425 100644 --- a/cmake/inputs/Config.cmake.in +++ b/cmake/inputs/Config.cmake.in @@ -2,6 +2,8 @@ # This file attempts to locate the TileDB library. If found, the following # imported targets are created: # - TileDB::tiledb +# - TileDB::tiledb_shared (if TileDB is built as a shared library) +# - TileDB::tiledb_static (if TileDB is built as a static library) # And the following variables are defined: # - TILEDB_FOUND # - TileDB_FOUND @@ -42,6 +44,12 @@ endif() include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") check_required_components("@PROJECT_NAME@") +if(@BUILD_SHARED_LIBS@) + add_library(TileDB::tiledb_shared ALIAS TileDB::tiledb) +else() + add_library(TileDB::tiledb_static ALIAS TileDB::tiledb) +endif() + # Define a convenience all-caps variable if (NOT DEFINED TILEDB_FOUND) if (TARGET TileDB::tiledb) From 841ae32d0acfcb6b032fe086776db1e7e345c85c Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Tue, 21 Nov 2023 13:28:01 +0200 Subject: [PATCH 05/19] Compile the Win32 resources only when we build a shared library. --- tiledb/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index a35bd154b5a..4dc277729cb 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -866,7 +866,7 @@ set(ver_patch ${CMAKE_MATCH_1}) set(VERSION "${ver_major}.${ver_minor}.${ver_patch}") -if (WIN32) +if (WIN32 AND BUILD_SHARED_LIBS) # WIN32 RC file creation (for VERSIONINFO) set(TDB_WIN32_FILEVERSION "${ver_major},${ver_minor},${ver_patch},0") set(TDB_WIN32_FILEVERSION_STR "\"${ver_major}.${ver_minor}.${ver_patch}\"") From 05fe01c416050115589c9db133808347328de945 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Tue, 21 Nov 2023 17:34:44 +0200 Subject: [PATCH 06/19] Update CI workflows. --- .github/workflows/build-windows.yml | 12 +----------- .github/workflows/unit-test-runs.yml | 4 +--- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index e1d6762ea08..e9ceae7c458 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -9,9 +9,8 @@ env: TILEDB_AZURE: OFF TILEDB_GCS: OFF TILEDB_SERIALIZATION: OFF - TILEDB_STATIC: OFF TILEDB_TOOLS: ON - TILEDB_BASE_BOOTSTRAP_OPTIONS: '-EnableVerbose -EnableStaticTileDB' + TILEDB_BASE_BOOTSTRAP_OPTIONS: '-EnableVerbose' jobs: build: @@ -155,10 +154,6 @@ jobs: if ($env:TILEDB_SERIALIZATION -eq "ON") { $bootstrapOptions = "-EnableSerialization " + $bootstrapOptions } - # static already added above as initial default - # if ($env:TILEDB_STATIC -eq "ON") { - # $bootstrapOptions = $bootstrapOptions + " -EnableStaticTileDB" - # } # if ($env:TILEDB_HDFS -eq "ON") { # $bootstrapOptions = $bootstrapOptions + " -EnableHDFS" #} @@ -404,11 +399,6 @@ jobs: Write-Host "cmd: '$cmd'" Invoke-Expression $cmd - #.\$CMakeBuildType\ExampleExe_static.exe - $cmd = ".\$CMakeBuildType\ExampleExe_static.exe" - Write-Host "cmd: '$cmd'" - Invoke-Expression $cmd - - name: Packaging test shell: pwsh run: | diff --git a/.github/workflows/unit-test-runs.yml b/.github/workflows/unit-test-runs.yml index 660c4539be3..0b16aede88c 100644 --- a/.github/workflows/unit-test-runs.yml +++ b/.github/workflows/unit-test-runs.yml @@ -9,7 +9,6 @@ env: TILEDB_AZURE: OFF TILEDB_GCS: OFF TILEDB_SERIALIZATION: ON - TILEDB_STATIC: ON TILEDB_TOOLS: ON VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite' @@ -59,8 +58,7 @@ jobs: -DTILEDB_GCS=${TILEDB_GCS} \ -DTILEDB_S3=${TILEDB_S3} \ -DTILEDB_SERIALIZATION=${TILEDB_SERIALIZATION} \ - -DTILEDB_ASSERTIONS=${TILEDB_ASSERTIONS} \ - -DTILEDB_STATIC=${TILEDB_STATIC} + -DTILEDB_ASSERTIONS=${TILEDB_ASSERTIONS} make -j4 # Build all unit tests make -C tiledb tests -j4 From ea075ab4fe2a8d52a9c881b2887250764c57550e Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Tue, 21 Nov 2023 14:27:06 +0200 Subject: [PATCH 07/19] Update comments. --- tiledb/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index 4dc277729cb..71b0f38f64d 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -415,7 +415,7 @@ add_library(TILEDB_CORE_OBJECTS OBJECT ${TILEDB_EXTERNALS_SOURCES} ) -# List of libraries to be linked to TILEDB_CORE_OBJECTS and TILEDB_CORE_OBJECTS_STATIC. +# List of libraries to be linked to TILEDB_CORE_OBJECTS. set(TILEDB_CORE_OBJECTS_LIBS baseline ) @@ -851,6 +851,8 @@ endif() # TileDB library targets ############################################################ +# CMake will determine the library's linkage from +# the value of the BUILD_SHARED_LIBS variable. add_library(tiledb $) file(READ "${CMAKE_CURRENT_SOURCE_DIR}/sm/c_api/tiledb_version.h" ver) From b332b87b2ed57b13a94dc927778bf01629373a77 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Wed, 22 Nov 2023 21:57:59 +0200 Subject: [PATCH 08/19] Rename mentions of `TILEDB_CORE_OBJECTS_EXPORTS` to `tiledb_EXPORTS`. --- test/CMakeLists.txt | 2 +- test/performance/CMakeLists.txt | 2 +- test/support/CMakeLists.txt | 2 +- tiledb/CMakeLists.txt | 2 +- tiledb/api/c_api/CMakeLists.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6b844e322e1..7deb4c1af22 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -360,7 +360,7 @@ endif() # This is necessary only because we are linking directly to the core objects. # Other users (e.g. the examples) do not need this flag. -target_compile_definitions(tiledb_unit PRIVATE -DTILEDB_CORE_OBJECTS_EXPORTS) +target_compile_definitions(tiledb_unit PRIVATE -Dtiledb_EXPORTS) target_compile_definitions(tiledb_unit PRIVATE -DTILEDB_TEST_INPUTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/inputs" diff --git a/test/performance/CMakeLists.txt b/test/performance/CMakeLists.txt index f8db58905d2..6352041104c 100644 --- a/test/performance/CMakeLists.txt +++ b/test/performance/CMakeLists.txt @@ -86,7 +86,7 @@ target_link_libraries(tiledb_explore_msys_handle_leakage # This is necessary only because we are linking directly to the core objects. # Other users (e.g. the examples) do not need this flag. -target_compile_definitions(tiledb_explore_msys_handle_leakage PRIVATE -DTILEDB_CORE_OBJECTS_EXPORTS) +target_compile_definitions(tiledb_explore_msys_handle_leakage PRIVATE -Dtiledb_EXPORTS) target_compile_definitions(tiledb_explore_msys_handle_leakage PRIVATE -DTILEDB_TEST_INPUTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/inputs" diff --git a/test/support/CMakeLists.txt b/test/support/CMakeLists.txt index 0b97ae84405..e727cfb91e1 100644 --- a/test/support/CMakeLists.txt +++ b/test/support/CMakeLists.txt @@ -87,7 +87,7 @@ if (TILEDB_SERIALIZATION) target_compile_definitions(tiledb_test_support_lib PRIVATE -DTILEDB_SERIALIZATION) endif() -target_compile_definitions(tiledb_test_support_lib PRIVATE -DTILEDB_CORE_OBJECTS_EXPORTS) +target_compile_definitions(tiledb_test_support_lib PRIVATE -Dtiledb_EXPORTS) target_compile_definitions(tiledb_test_support_lib PRIVATE -DTILEDB_TEST_INPUTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../inputs" diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index 71b0f38f64d..0641dc98a05 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -922,7 +922,7 @@ generate_export_header(tiledb # Install locally configure_file(${TILEDB_EXPORT_HEADER} ${TILEDB_LOCALINSTALL_INCLUDE}/${TILEDB_EXPORT_HEADER_LOCALINSTALL_PATH} COPYONLY) -target_compile_definitions(TILEDB_CORE_OBJECTS PRIVATE -DTILEDB_CORE_OBJECTS_EXPORTS) +target_compile_definitions(TILEDB_CORE_OBJECTS PRIVATE -Dtiledb_EXPORTS) target_include_directories(TILEDB_CORE_OBJECTS PRIVATE ${TILEDB_EXPORT_HEADER_DIR}) # Add the generated header to the public headers list diff --git a/tiledb/api/c_api/CMakeLists.txt b/tiledb/api/c_api/CMakeLists.txt index 8c4cc35e794..11d62110bcd 100644 --- a/tiledb/api/c_api/CMakeLists.txt +++ b/tiledb/api/c_api/CMakeLists.txt @@ -32,7 +32,7 @@ include(common NO_POLICY_SCOPE) # - Include path for `c_api` headers # add_library(export INTERFACE) -target_compile_definitions(export INTERFACE -DTILEDB_CORE_OBJECTS_EXPORTS) +target_compile_definitions(export INTERFACE -Dtiledb_EXPORTS) target_include_directories(export INTERFACE ${TILEDB_EXPORT_HEADER_DIR}) target_include_directories(export INTERFACE ${TILEDB_SOURCE_ROOT}/tiledb/sm/c_api) From 371f41cd2383e0cf26c1c206600c8d823b86baf2 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Fri, 24 Nov 2023 14:13:42 +0200 Subject: [PATCH 09/19] Don't create a context in global scope in `quickstart_dense.cc`. Fixes segfaults when running it with statically linking to TileDB. --- examples/cpp_api/quickstart_dense.cc | 39 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/examples/cpp_api/quickstart_dense.cc b/examples/cpp_api/quickstart_dense.cc index fe6bc8384d7..2c0a3efe6a1 100644 --- a/examples/cpp_api/quickstart_dense.cc +++ b/examples/cpp_api/quickstart_dense.cc @@ -41,34 +41,31 @@ using namespace tiledb; // Name of array. std::string array_name_("mem://quickstart_dense_array"); -// Example-global Context object. -Context ctx_; - -void create_array() { +void create_array(const Context& ctx) { // The array will be 4x4 with dimensions "rows" and "cols", with domain [1,4]. - Domain domain(ctx_); - domain.add_dimension(Dimension::create(ctx_, "rows", {{1, 4}}, 4)) - .add_dimension(Dimension::create(ctx_, "cols", {{1, 4}}, 4)); + Domain domain(ctx); + domain.add_dimension(Dimension::create(ctx, "rows", {{1, 4}}, 4)) + .add_dimension(Dimension::create(ctx, "cols", {{1, 4}}, 4)); // The array will be dense. - ArraySchema schema(ctx_, TILEDB_DENSE); + ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); // Add a single attribute "a" so each (i,j) cell can store an integer. - schema.add_attribute(Attribute::create(ctx_, "a")); + schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. Array::create(array_name_, schema); } -void write_array() { +void write_array(const Context& ctx) { // Prepare some data for the array std::vector data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; // Open the array for writing and create the query. - Array array(ctx_, array_name_, TILEDB_WRITE); - Query query(ctx_, array, TILEDB_WRITE); + Array array(ctx, array_name_, TILEDB_WRITE); + Query query(ctx, array, TILEDB_WRITE); query.set_layout(TILEDB_ROW_MAJOR).set_data_buffer("a", data); // Perform the write and close the array. @@ -76,19 +73,19 @@ void write_array() { array.close(); } -void read_array() { +void read_array(const Context& ctx) { // Prepare the array for reading - Array array(ctx_, array_name_, TILEDB_READ); + Array array(ctx, array_name_, TILEDB_READ); // Slice only rows 1, 2 and cols 2, 3, 4 - Subarray subarray(ctx_, array); + Subarray subarray(ctx, array); subarray.add_range(0, 1, 2).add_range(1, 2, 4); // Prepare the vector that will hold the result (of size 6 elements) std::vector data(6); // Prepare the query - Query query(ctx_, array, TILEDB_READ); + Query query(ctx, array, TILEDB_READ); query.set_subarray(subarray) .set_layout(TILEDB_ROW_MAJOR) .set_data_buffer("a", data); @@ -104,11 +101,13 @@ void read_array() { } int main() { - if (Object::object(ctx_, array_name_).type() != Object::Type::Array) { - create_array(); - write_array(); + // Create TileDB context + Context ctx; + if (Object::object(ctx, array_name_).type() != Object::Type::Array) { + create_array(ctx); + write_array(ctx); } - read_array(); + read_array(ctx); return 0; } From 908f4b2843894678cd5c8579811bc47ae9f45f6e Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Fri, 24 Nov 2023 16:58:57 +0200 Subject: [PATCH 10/19] Don't define the alias targets if they are already defined. --- cmake/inputs/Config.cmake.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/inputs/Config.cmake.in b/cmake/inputs/Config.cmake.in index a7a91aa6425..93ef9310e79 100644 --- a/cmake/inputs/Config.cmake.in +++ b/cmake/inputs/Config.cmake.in @@ -44,9 +44,9 @@ endif() include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") check_required_components("@PROJECT_NAME@") -if(@BUILD_SHARED_LIBS@) +if(@BUILD_SHARED_LIBS@ AND NOT TARGET TileDB::tiledb_shared) # BUILD_SHARED_LIBS AND NOT TARGET TileDB::tiledb_shared add_library(TileDB::tiledb_shared ALIAS TileDB::tiledb) -else() +elseif(NOT TARGET TileDB::tiledb_static) add_library(TileDB::tiledb_static ALIAS TileDB::tiledb) endif() From 4c91a249b552d54f981be74aedee34dc5322ac5a Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Fri, 24 Nov 2023 18:25:07 +0200 Subject: [PATCH 11/19] List the files in build directory on failure. --- .github/workflows/ci-linux_mac.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci-linux_mac.yml b/.github/workflows/ci-linux_mac.yml index f16fabbf453..f11b4542334 100644 --- a/.github/workflows/ci-linux_mac.yml +++ b/.github/workflows/ci-linux_mac.yml @@ -216,6 +216,10 @@ jobs: if: ${{ failure() && startsWith(matrix.os, 'ubuntu-') == true }} # only run this job if the build step failed run: ./scripts/ci/posix/dump-core-stacks.sh + - name: List files in build directory on failure + run: du --exclude _deps -h $GITHUB_WORKSPACE/build + if: ${{ failure() }} + - name: 'Upload failure artifacts (Linux)' # https://github.com/actions/upload-artifact#where-does-the-upload-go if: ${{ startsWith(matrix.os, 'ubuntu-') == true }} # only run this job if the build step failed uses: actions/upload-artifact@v3 From 4a0ea349163c0181e1ae659bd4f95b9f898f5f17 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 27 Nov 2023 13:05:36 +0200 Subject: [PATCH 12/19] Build, run and delete each example individually. Prevents out of disk errors on CI. --- .github/workflows/ci-linux_mac.yml | 1 - scripts/run-nix-examples.sh | 30 +++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) mode change 100644 => 100755 scripts/run-nix-examples.sh diff --git a/.github/workflows/ci-linux_mac.yml b/.github/workflows/ci-linux_mac.yml index f11b4542334..d83bc7c0ad5 100644 --- a/.github/workflows/ci-linux_mac.yml +++ b/.github/workflows/ci-linux_mac.yml @@ -204,7 +204,6 @@ jobs: ################################################### # Build and run Examples - make -C $GITHUB_WORKSPACE/build -j3 examples source $GITHUB_WORKSPACE/scripts/run-nix-examples.sh ################################################### diff --git a/scripts/run-nix-examples.sh b/scripts/run-nix-examples.sh old mode 100644 new mode 100755 index 5743cf882b3..6584d82b546 --- a/scripts/run-nix-examples.sh +++ b/scripts/run-nix-examples.sh @@ -1,20 +1,28 @@ #!/bin/bash +SourceDir="$(dirname $0)/.." BaseDir="$(pwd)" + TestAppDir="$(pwd)/tiledb/examples/c_api" TestAppDataDir="$(pwd)/tiledb/examples/c_api/test_app_data" -for exampleexe in $(ls ${TestAppDir}/*_c) ; +for example in $(ls ${SourceDir}/examples/c_api/*.c) ; do cd ${TestAppDir} rm -rf ${TestAppDataDir} mkdir ${TestAppDataDir} cd ${TestAppDataDir} - echo $exampleexe - $exampleexe; + exampleexe=${example%.c}_c + exampleexe=${exampleexe##*/} + cmake --build ${BaseDir} --target ${exampleexe} + echo $TestAppDir/$exampleexe + $TestAppDir/$exampleexe; + # Remove the executable after running it to prevent disk + # space exhaustion when statically linking to tiledb. + rm $TestAppDir/$exampleexe status=$? if (($status != 0)); then echo "FAILED: $exampleexe exited with $status" - echo "::set-output name=TILEDB_CI_SUCCESS::0" + echo "TILEDB_CI_SUCCESS=0" >> $GITHUB_OUTPUT fi done cd ${TestAppDir} @@ -23,10 +31,10 @@ rm -rf ${TestAppDataDir} cd ${BaseDir} TestAppDir="$(pwd)/tiledb/examples/cpp_api" TestAppDataDir="$(pwd)/tiledb/examples/cpp_api/test_app_data" -for exampleexe in $(ls ${TestAppDir}/*_cpp) ; +for example in $(ls ${SourceDir}/examples/cpp_api/*.cc) ; do # Skip running WebP example with no input - if [ "${exampleexe##*/}" == png_ingestion_webp_cpp ]; then + if [ "${example##*/}" == png_ingestion_webp.cc ]; then continue fi; @@ -34,12 +42,16 @@ do rm -rf ${TestAppDataDir} mkdir ${TestAppDataDir} cd ${TestAppDataDir} - echo $exampleexe - $exampleexe; + exampleexe=${example%.cc}_cpp + exampleexe=${exampleexe##*/} + cmake --build ${BaseDir} --target ${exampleexe} + echo $TestAppDir/$exampleexe + $TestAppDir/$exampleexe; + rm $TestAppDir/$exampleexe status=$? if (($status != 0)); then echo "FAILED: $exampleexe exited with $status" - echo "::set-output name=TILEDB_CI_SUCCESS::0" + echo "TILEDB_CI_SUCCESS=0" >> $GITHUB_OUTPUT fi done cd ${TestAppDir} From 15197117025162fb8712699f7f0936917b15afc1 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 27 Nov 2023 14:10:33 +0200 Subject: [PATCH 13/19] Do not source `run-nix-examples.sh`. --- .github/workflows/ci-linux_mac.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-linux_mac.yml b/.github/workflows/ci-linux_mac.yml index d83bc7c0ad5..32b0dfd5993 100644 --- a/.github/workflows/ci-linux_mac.yml +++ b/.github/workflows/ci-linux_mac.yml @@ -204,7 +204,9 @@ jobs: ################################################### # Build and run Examples - source $GITHUB_WORKSPACE/scripts/run-nix-examples.sh + # The following script must not be sourced. + # It relies on finding its source directory. + $GITHUB_WORKSPACE/scripts/run-nix-examples.sh ################################################### # Build benchmark code From 63ca09666c8fa853d66ee064a1c5df83eecf72ed Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Tue, 28 Nov 2023 14:48:57 +0200 Subject: [PATCH 14/19] Fix linker errors when building the benchmarks. --- scripts/ci/build_benchmarks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/build_benchmarks.sh b/scripts/ci/build_benchmarks.sh index 18b26bcf361..2d961cc3f8e 100644 --- a/scripts/ci/build_benchmarks.sh +++ b/scripts/ci/build_benchmarks.sh @@ -52,7 +52,7 @@ int main(int argc, char **argv) { EOF export TESTFILE_LDFLAGS="-ltiledb" export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/build/dist/lib:/usr/local/lib:${LD_LIBRARY_PATH:-} -$CXX -std=c++11 -g -O0 -Wall -Werror -I$GITHUB_WORKSPACE/build/dist/include -L$GITHUB_WORKSPACE/build/dist/lib $testfile -o $testfile.exe $TESTFILE_LDFLAGS && \ +$CXX -std=c++17 -g -O0 -Wall -Werror -I$GITHUB_WORKSPACE/build/dist/include -L$GITHUB_WORKSPACE/build/dist/lib -L$GITHUB_WORKSPACE/build/vcpkg_installed/$VCPKG_TARGET_TRIPLET $testfile -o $testfile.exe $TESTFILE_LDFLAGS && \ $testfile.exe && \ rm -f $testfile $testfile.exe From 1bbd6cc58f5624e6cb966211a2e07cc496bb38be Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Tue, 28 Nov 2023 15:38:56 +0200 Subject: [PATCH 15/19] Fix building the examples. --- scripts/run-nix-examples.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/run-nix-examples.sh b/scripts/run-nix-examples.sh index 6584d82b546..0ab1f7cbd7e 100755 --- a/scripts/run-nix-examples.sh +++ b/scripts/run-nix-examples.sh @@ -13,7 +13,7 @@ do cd ${TestAppDataDir} exampleexe=${example%.c}_c exampleexe=${exampleexe##*/} - cmake --build ${BaseDir} --target ${exampleexe} + cmake --build ${BaseDir}/tiledb --target ${exampleexe} echo $TestAppDir/$exampleexe $TestAppDir/$exampleexe; # Remove the executable after running it to prevent disk @@ -44,7 +44,7 @@ do cd ${TestAppDataDir} exampleexe=${example%.cc}_cpp exampleexe=${exampleexe##*/} - cmake --build ${BaseDir} --target ${exampleexe} + cmake --build ${BaseDir}/tiledb --target ${exampleexe} echo $TestAppDir/$exampleexe $TestAppDir/$exampleexe; rm $TestAppDir/$exampleexe From 6b4fcdd027e97b0e1e6db699a2011e0d4870f851 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Tue, 28 Nov 2023 16:18:33 +0200 Subject: [PATCH 16/19] Delete seemingly useless code. --- scripts/ci/build_benchmarks.sh | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/scripts/ci/build_benchmarks.sh b/scripts/ci/build_benchmarks.sh index 2d961cc3f8e..a3de85b57ab 100644 --- a/scripts/ci/build_benchmarks.sh +++ b/scripts/ci/build_benchmarks.sh @@ -32,29 +32,3 @@ cd build cmake -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/build/dist;$GITHUB_WORKSPACE/build/vcpkg_installed/$VCPKG_TARGET_TRIPLET" ../src make popd - -testfile=$(mktemp) -mv $testfile $testfile.cc -testfile=$testfile.cc -cat < $testfile -#include -#include -#include -int main(int argc, char **argv) { - int major = 0; - int minor = 0; - int patch = 0; - tiledb_version(&major,&minor,&patch); - auto version = tiledb::version(); - assert(major == std::get<0>(version)); - return 0; -} -EOF -export TESTFILE_LDFLAGS="-ltiledb" -export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/build/dist/lib:/usr/local/lib:${LD_LIBRARY_PATH:-} -$CXX -std=c++17 -g -O0 -Wall -Werror -I$GITHUB_WORKSPACE/build/dist/include -L$GITHUB_WORKSPACE/build/dist/lib -L$GITHUB_WORKSPACE/build/vcpkg_installed/$VCPKG_TARGET_TRIPLET $testfile -o $testfile.exe $TESTFILE_LDFLAGS && \ -$testfile.exe && \ -rm -f $testfile $testfile.exe - -ps -U $(whoami) -o comm= | sort | uniq -# displayName: 'Build examples, PNG test, and benchmarks (build-only)' From 6663f3c9ba40279389a6d725e96682fa5b284d0a Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Tue, 5 Dec 2023 20:02:08 +0200 Subject: [PATCH 17/19] Fix name clashes with syscalls. When we initialize the AWS SDK on Linux, it also initializes s2n, which reads from `/dev/urandom` as part of it. However, the call to `read`, gets resolved to the `read()` function of our example. The example tries to recursively initialize the AWS SDK, but since `std::call_once` is not always reentrant, it deadlocks. --- examples/c_api/vfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/c_api/vfs.c b/examples/c_api/vfs.c index 921f6555214..d550d0adc96 100644 --- a/examples/c_api/vfs.c +++ b/examples/c_api/vfs.c @@ -36,7 +36,7 @@ #include #include -void dirs_files() { +static void dirs_files() { // Create TileDB context tiledb_ctx_t* ctx; tiledb_ctx_alloc(NULL, &ctx); @@ -92,7 +92,8 @@ void dirs_files() { tiledb_ctx_free(&ctx); } -void write() { +// Should be static to avoid collision with the write syscall. +static void write() { // Create TileDB context tiledb_ctx_t* ctx; tiledb_ctx_alloc(NULL, &ctx); @@ -132,7 +133,8 @@ void write() { tiledb_ctx_free(&ctx); } -void read() { +// Should be static to avoid collision with the read syscall. +static void read() { // Create TileDB context tiledb_ctx_t* ctx; tiledb_ctx_alloc(NULL, &ctx); From 782a955d635a22e6c05a2c7c63ebb3dc9ede02f0 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Wed, 6 Dec 2023 20:28:43 +0200 Subject: [PATCH 18/19] Address most PR feedback. --- bootstrap | 29 +++++++++++++++++++++-------- bootstrap.ps1 | 28 +++++++++++++++++++--------- cmake/inputs/Config.cmake.in | 2 +- examples/c_api/vfs.c | 14 ++++++-------- scripts/run-nix-examples.sh | 4 ++-- 5 files changed, 49 insertions(+), 28 deletions(-) diff --git a/bootstrap b/bootstrap index 9dd9bce4557..2abc4554835 100755 --- a/bootstrap +++ b/bootstrap @@ -37,6 +37,8 @@ Configuration: --enable-vcpkg use vcpkg for downloading and building dependencies --dependency=DIRs specify the dependencies at DIRs, separated by colon ['"${default_dependency}"'] + --linkage specify the linkage of tiledb. Defaults to static. + [static|shared] --force-build-all-deps force building of all dependencies, even those already installed at system-level --remove-deprecations build TileDB without any deprecated APIs @@ -47,8 +49,7 @@ Configuration: --disable-avx2 disables use of AVX2 instructions --disable-webp disables building of webp library and linkage test --disable-vcpkg disables use of vcpkg for downloading and building dependencies - --enable-static-tiledb enables building TileDB as a static library (this is the default) - --enable-shared-tiledb enables building TileDB as a shared library + --enable-static-tiledb enables building TileDB as a static library (deprecated, use --linkage=static) --enable-sanitizer=SAN enable sanitizer (clang only) (address|memory|leak|thread|undefined) --enable-debug enable debug build @@ -122,6 +123,7 @@ while test $# != 0; do tiledb_vcpkg="ON";; --dependency=*) dir=`arg "$1"` dependency_dir="$dir";; + --linkage=*) linkage=`arg "$1"`;; --force-build-all-deps) tiledb_force_all_deps="ON";; --remove-deprecations) tiledb_remove_deprecations="ON";; --disable-werror) tiledb_werror="OFF";; @@ -141,9 +143,8 @@ while test $# != 0; do --enable-azure) tiledb_azure="ON";; --enable-gcs) tiledb_gcs="ON";; --enable-serialization) tiledb_serialization="ON";; - --enable-static-tiledb) echo "Argument '--enable-static-tiledb' is obsolete and will be removed in a future version. TileDB is now built as a static library by default." - build_shared_libs="OFF";; - --enable-shared-tiledb) build_shared_libs="ON";; + --enable-static-tiledb) echo "Argument '--enable-static-tiledb' is obsolete and will be removed in a future version. TileDB is now built as a static library by default and linkage is controlled with the --linkage option." + enable_static_tiledb="ON";; --enable-sanitizer=*) san=`arg "$1"` sanitizer="$san";; --enable-tools) tiledb_tools="ON";; @@ -179,9 +180,8 @@ for en in "${enables[@]}"; do ccache) tiledb_ccache="ON";; arrow-tests) tiledb_arrow_tests="ON";; hdfs) tiledb_hdfs="ON";; - static-tiledb) echo "Argument '--enable-static-tiledb' is obsolete and will be removed in a future version. TileDB is now built as a static library by default." - build_shared_libs="OFF";; - shared-tiledb) build_shared_libs="ON";; + static-tiledb) echo "Argument '--enable-static-tiledb' is obsolete and will be removed in a future version. TileDB is now built as a static library by default and linkage is controlled with the --linkage option." + enable_static_tiledb="ON";; experimental-features) tiledb_experimental_features="ON";; rest-tests) tiledb_tests_enable_rest="ON";; aws-s3-config) tiledb_tests_aws_s3_config="ON";; @@ -193,6 +193,19 @@ if [ "${source_dir}" = "${binary_dir}" ]; then die "cannot build the project in the source directory! Out-of-source build is enforced!" fi +if [ "${linkage}" = "static" ] || [ "${linkage}" = "" ]; then + build_shared_libs="OFF" +elif [ "${linkage}" = "shared" ]; then + build_shared_libs="ON" +else + die "unknown linkage: ${linkage}" +fi + +# Fail if both --linkage=shared and --enable-static-tiledb are specified +if [ "${build_shared_libs}" = "ON" ] && [ "${enable_static_tiledb}" = "ON" ]; then + die "cannot specify both --linkage=shared and --enable-static-tiledb" +fi + # Check clang compiler if [[ x"${CC}" = x"" ]]; then CC=gcc diff --git a/bootstrap.ps1 b/bootstrap.ps1 index da22e62d25c..bda0743e469 100644 --- a/bootstrap.ps1 +++ b/bootstrap.ps1 @@ -16,6 +16,10 @@ Installs files in tree rooted at PREFIX (defaults to TileDB\dist). .PARAMETER Dependency Semicolon separated list to binary dependencies. +.PARAMETER Linkage +Specify the linkage type to build TileDB with. Valid values are +"static" and "shared". Default is "static". + .PARAMETER CMakeGenerator Optionally specify the CMake generator string, e.g. "Visual Studio 15 2017". Check 'cmake --help' for a list of supported generators. @@ -58,10 +62,7 @@ Enables building with serialization support. .PARAMETER EnableStaticTileDB Enables building TileDB as a static library. -Deprecated, this is now the default behavior. - -.PARAMETER EnableSharedTileDB -Enables building TileDB as a shared library. +Deprecated, use -Linkage static instead. .PARAMETER EnableBuildDeps Enables building TileDB dependencies from source (superbuild) @@ -117,6 +118,7 @@ https://github.com/TileDB-Inc/TileDB Param( [string]$Prefix, [string]$Dependency, + [string]$Linkage = "static", [string]$CMakeGenerator, [switch]$EnableAssert, [switch]$EnableDebug, @@ -130,7 +132,6 @@ Param( [switch]$EnableGcs, [switch]$EnableSerialization, [switch]$EnableStaticTileDB, - [switch]$EnableSharedTileDB, [switch]$EnableTools, [switch]$EnableExperimentalFeatures, [switch]$EnableBuildDeps, @@ -246,12 +247,21 @@ if ($DisableWebP.IsPresent) { } $BuildSharedLibs = "OFF"; -if ($EnableStaticTileDB.IsPresent) { - Write-Warning "-EnableStaticTileDB is deprecated and will be removed in a future version. TileDB is now built as a static library by default. Use -EnableSharedTileDB to build a shared library." -} -elseif ($EnableSharedTileDB.IsPresent) { +if ($Linkage -eq "shared") { $BuildSharedLibs = "ON" } +elseif ($Linkage -ne "static") { + Write-Error "Invalid linkage type: $Linkage. Valid values are 'static' and 'shared'." + exit 1 +} + +if ($EnableStaticTileDB.IsPresent) { + Write-Warning "-EnableStaticTileDB is deprecated and will be removed in a future version. TileDB is now built as a static library by default. Use -Linkage shared to build a shared library." + if ($Linkage -eq "shared") { + Write-Error "Cannot specify -EnableStaticTileDB alongside -Linkage shared." + exit 1 + } +} $TileDBTools = "OFF"; if ($EnableTools.IsPresent) { diff --git a/cmake/inputs/Config.cmake.in b/cmake/inputs/Config.cmake.in index 93ef9310e79..ccea6a22cb3 100644 --- a/cmake/inputs/Config.cmake.in +++ b/cmake/inputs/Config.cmake.in @@ -1,7 +1,7 @@ # # This file attempts to locate the TileDB library. If found, the following # imported targets are created: -# - TileDB::tiledb +# - TileDB::tiledb (points to either a static or shared library) # - TileDB::tiledb_shared (if TileDB is built as a shared library) # - TileDB::tiledb_static (if TileDB is built as a static library) # And the following variables are defined: diff --git a/examples/c_api/vfs.c b/examples/c_api/vfs.c index d550d0adc96..ffbcb0f0f72 100644 --- a/examples/c_api/vfs.c +++ b/examples/c_api/vfs.c @@ -36,7 +36,7 @@ #include #include -static void dirs_files() { +static void do_dirs_files() { // Create TileDB context tiledb_ctx_t* ctx; tiledb_ctx_alloc(NULL, &ctx); @@ -92,8 +92,7 @@ static void dirs_files() { tiledb_ctx_free(&ctx); } -// Should be static to avoid collision with the write syscall. -static void write() { +static void do_write() { // Create TileDB context tiledb_ctx_t* ctx; tiledb_ctx_alloc(NULL, &ctx); @@ -133,8 +132,7 @@ static void write() { tiledb_ctx_free(&ctx); } -// Should be static to avoid collision with the read syscall. -static void read() { +static void do_read() { // Create TileDB context tiledb_ctx_t* ctx; tiledb_ctx_alloc(NULL, &ctx); @@ -160,7 +158,7 @@ static void read() { } int main() { - dirs_files(); - write(); - read(); + do_dirs_files(); + do_write(); + do_read(); } diff --git a/scripts/run-nix-examples.sh b/scripts/run-nix-examples.sh index 0ab1f7cbd7e..b99cabd1b83 100755 --- a/scripts/run-nix-examples.sh +++ b/scripts/run-nix-examples.sh @@ -16,10 +16,10 @@ do cmake --build ${BaseDir}/tiledb --target ${exampleexe} echo $TestAppDir/$exampleexe $TestAppDir/$exampleexe; + status=$? # Remove the executable after running it to prevent disk # space exhaustion when statically linking to tiledb. rm $TestAppDir/$exampleexe - status=$? if (($status != 0)); then echo "FAILED: $exampleexe exited with $status" echo "TILEDB_CI_SUCCESS=0" >> $GITHUB_OUTPUT @@ -47,8 +47,8 @@ do cmake --build ${BaseDir}/tiledb --target ${exampleexe} echo $TestAppDir/$exampleexe $TestAppDir/$exampleexe; - rm $TestAppDir/$exampleexe status=$? + rm $TestAppDir/$exampleexe if (($status != 0)); then echo "FAILED: $exampleexe exited with $status" echo "TILEDB_CI_SUCCESS=0" >> $GITHUB_OUTPUT From 94112e5d6b1b9f551eb19f8209481fc61b1562c9 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Wed, 6 Dec 2023 20:46:45 +0200 Subject: [PATCH 19/19] Fix outdated bootstrap script documentation. --- bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap b/bootstrap index 2abc4554835..1878c54df6d 100755 --- a/bootstrap +++ b/bootstrap @@ -47,7 +47,7 @@ Configuration: --disable-tests disables building the TileDB tests --disable-stats disables internal TileDB statistics --disable-avx2 disables use of AVX2 instructions - --disable-webp disables building of webp library and linkage test + --disable-webp disables building of webp library --disable-vcpkg disables use of vcpkg for downloading and building dependencies --enable-static-tiledb enables building TileDB as a static library (deprecated, use --linkage=static) --enable-sanitizer=SAN enable sanitizer (clang only)