Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ project(adbc
VERSION "${ADBC_BASE_VERSION}"
LANGUAGES C CXX)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(AdbcDefines)
include(BuildUtils)
Expand Down
2 changes: 1 addition & 1 deletion c/cmake_modules/AdbcDefines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ if(ADBC_BUILD_TESTS)
if(NOT GTest_FOUND)
message(STATUS "Building googletest from source")
# Required for GoogleTest
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
include(FetchContent)
fetchcontent_declare(googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
Expand Down
10 changes: 5 additions & 5 deletions c/cmake_modules/BuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function(ADD_ARROW_LIB LIB_NAME)
${ARG_STATIC_LINK_LIBS})
adbc_configure_target(${LIB_NAME}_objlib)
# https://github.com/apache/arrow-adbc/issues/81
target_compile_features(${LIB_NAME}_objlib PRIVATE cxx_std_11)
target_compile_features(${LIB_NAME}_objlib PRIVATE cxx_std_20)
else()
# Prepare arguments for separate compilation of static and shared libs below
# TODO: add PCH directives
Expand All @@ -199,7 +199,7 @@ function(ADD_ARROW_LIB LIB_NAME)

if(BUILD_SHARED)
add_library(${LIB_NAME}_shared SHARED ${LIB_DEPS})
target_compile_features(${LIB_NAME}_shared PRIVATE cxx_std_17)
target_compile_features(${LIB_NAME}_shared PRIVATE cxx_std_20)
set_property(TARGET ${LIB_NAME}_shared PROPERTY CXX_STANDARD_REQUIRED ON)
adbc_configure_target(${LIB_NAME}_shared)
if(EXTRA_DEPS)
Expand Down Expand Up @@ -253,7 +253,7 @@ function(ADD_ARROW_LIB LIB_NAME)
endif()

# https://github.com/apache/arrow-adbc/issues/81
target_compile_features(${LIB_NAME}_shared PRIVATE cxx_std_11)
target_compile_features(${LIB_NAME}_shared PRIVATE cxx_std_20)

target_link_libraries(${LIB_NAME}_shared
LINK_PUBLIC
Expand Down Expand Up @@ -317,7 +317,7 @@ function(ADD_ARROW_LIB LIB_NAME)

if(BUILD_STATIC)
add_library(${LIB_NAME}_static STATIC ${LIB_DEPS})
target_compile_features(${LIB_NAME}_static PRIVATE cxx_std_11)
target_compile_features(${LIB_NAME}_static PRIVATE cxx_std_20)
set_property(TARGET ${LIB_NAME}_static PROPERTY CXX_STANDARD_REQUIRED ON)
adbc_configure_target(${LIB_NAME}_static)
if(EXTRA_DEPS)
Expand Down Expand Up @@ -352,7 +352,7 @@ function(ADD_ARROW_LIB LIB_NAME)
OUTPUT_NAME ${LIB_NAME_STATIC})

# https://github.com/apache/arrow-adbc/issues/81
target_compile_features(${LIB_NAME}_static PRIVATE cxx_std_11)
target_compile_features(${LIB_NAME}_static PRIVATE cxx_std_20)

if(ARG_STATIC_INSTALL_INTERFACE_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion c/driver/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if(ADBC_BUILD_TESTS)
utils_test.cc
EXTRA_LINK_LIBS
adbc_driver_common)
target_compile_features(adbc-driver-common-test PRIVATE cxx_std_17)
target_compile_features(adbc-driver-common-test PRIVATE cxx_std_20)
target_include_directories(adbc-driver-common-test
PRIVATE "${REPOSITORY_ROOT}/c/include")
adbc_configure_target(adbc-driver-common-test)
Expand Down
2 changes: 1 addition & 1 deletion c/driver/flightsql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if(ADBC_BUILD_TESTS)
endif()
endif()

target_compile_features(adbc-driver-flightsql-test PRIVATE cxx_std_17)
target_compile_features(adbc-driver-flightsql-test PRIVATE cxx_std_20)
target_include_directories(adbc-driver-flightsql-test SYSTEM
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
${REPOSITORY_ROOT}/c/driver)
Expand Down
2 changes: 1 addition & 1 deletion c/driver/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if(ADBC_BUILD_TESTS)
base_driver_test.cc
EXTRA_LINK_LIBS
adbc_driver_framework)
target_compile_features(adbc-driver-framework-test PRIVATE cxx_std_17)
target_compile_features(adbc-driver-framework-test PRIVATE cxx_std_20)
target_include_directories(adbc-driver-framework-test
PRIVATE "${REPOSITORY_ROOT}/c/"
"${REPOSITORY_ROOT}/c/include"
Expand Down
4 changes: 2 additions & 2 deletions c/driver/postgresql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if(ADBC_BUILD_TESTS)
adbc_driver_common
adbc_validation
${TEST_LINK_LIBS})
target_compile_features(adbc-driver-postgresql-test PRIVATE cxx_std_17)
target_compile_features(adbc-driver-postgresql-test PRIVATE cxx_std_20)
target_compile_definitions(adbc-driver-postgresql-test
PRIVATE ADBC_POSTGRESQL_TESTDATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/testdata"
)
Expand All @@ -110,7 +110,7 @@ if(ADBC_BUILD_TESTS)
adbc_driver_common
adbc_validation
${TEST_LINK_LIBS})
target_compile_features(adbc-driver-postgresql-copy-test PRIVATE cxx_std_17)
target_compile_features(adbc-driver-postgresql-copy-test PRIVATE cxx_std_20)
target_include_directories(adbc-driver-postgresql-copy-test SYSTEM
PRIVATE ${REPOSITORY_ROOT}/c/
${REPOSITORY_ROOT}/c/include/
Expand Down
2 changes: 1 addition & 1 deletion c/driver/sqlite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if(ADBC_BUILD_TESTS)
${TEST_LINK_LIBS})
target_compile_definitions(adbc-driver-sqlite-test
PRIVATE ${ADBC_SQLITE_COMPILE_DEFINES})
target_compile_features(adbc-driver-sqlite-test PRIVATE cxx_std_17)
target_compile_features(adbc-driver-sqlite-test PRIVATE cxx_std_20)
target_include_directories(adbc-driver-sqlite-test SYSTEM
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
Expand Down
4 changes: 2 additions & 2 deletions c/driver_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ if(ADBC_BUILD_TESTS)
adbc_driver_common
adbc_validation
${TEST_LINK_LIBS})
target_compile_features(adbc-driver-manager-test PRIVATE cxx_std_17)
target_compile_features(adbc-driver-manager-test PRIVATE cxx_std_20)
add_dependencies(adbc-driver-manager-test adbc_driver_entrypoint
adbc_driver_no_entrypoint)

Expand Down Expand Up @@ -153,7 +153,7 @@ if(ADBC_BUILD_TESTS)
EXTRA_LINK_LIBS
adbc_validation_util
${TEST_LINK_LIBS})
target_compile_features(adbc-version-100-compatibility-test PRIVATE cxx_std_17)
target_compile_features(adbc-version-100-compatibility-test PRIVATE cxx_std_20)
target_include_directories(adbc-version-100-compatibility-test SYSTEM
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
Expand Down
94 changes: 94 additions & 0 deletions c/driver_manager/adbc_driver_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,100 @@ std::string CheckNonPrintableLibraryName(const std::string& name) {
return error_message;
}

const std::string& InternalAdbcCurrentArch() {
#if defined(_WIN32)
static const std::string platform = "windows";
#elif defined(__APPLE__)
static const std::string platform = "macos";
#elif defined(__FreeBSD__)
static const std::string platform = "freebsd";
#elif defined(__OpenBSD__)
static const std::string platform = "openbsd";
#elif defined(__linux__)
static const std::string platform = "linux";
#else
static const std::string platform = "unknown";
#endif

#if defined(__x86_64__) || defined(__amd64__) || defined(_M_X64) || defined(_M_AMD64)
static const std::string arch = "amd64";
#elif defined(__aarch64__) || defined(_M_ARM64) || defined(__ARM_ARCH_ISA_A64)
#ifdef ADBC_LITTLE_ENDIAN
static const std::string arch = "arm64";
#else
static const std::string arch = "arm64be";
#endif
#elif defined(__i386__) || defined(_M_IX86) || defined(_M_X86)
static const std::string arch = "x86";
#elif defined(__arm__) || defined(_M_ARM)
#ifdef ADBC_LITTLE_ENDIAN
static const std::string arch = "arm";
#else
static const std::string arch = "armbe";
#endif
#elif defined(__riscv) || defined(_M_RISCV)
#if defined(__riscv_xlen) && __riscv_xlen == 64
static const std::string arch = "riscv64";
#else
static const std::string arch = "riscv";
#endif
#elif defined(__ppc64__) || defined(__powerpc64__)
#ifdef ADBC_LITTLE_ENDIAN
static const std::string arch = "powerpc64le";
#else
static const std::string arch = "powerpc64";
#endif
#elif defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC)
static const std::string arch = "powerpc";
#elif defined(__s390x__) || defined(_M_S390)
static const std::string arch = "s390x";
#elif defined(__sparc__) || defined(__sparc)
#if defined(_LP64) || defined(__LP64__)
static const std::string arch = "sparc64";
#else
static const std::string arch = "sparc";
#endif
#elif defined(__wasm32__)
static const std::string arch = "wasm32";
#elif defined(__wasm64__)
static const std::string arch = "wasm64";
#else
static const std::string arch = "unknown";
#endif

// musl doesn't actually define any preprocessor macro for itself
// but apparently it doesn't define __USE_GNU inside of features.h
// while gcc DOES define that.
// see https://stackoverflow.com/questions/58177815/how-to-actually-detect-musl-libc
#if defined(_WIN32) || defined(__APPLE__) || defined(__FreeBSD__)
#else
#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE
#include <features.h> // NOLINT [build/include]
#ifndef __USE_GNU
#define __MUSL__
#endif
#undef _GNU_SOURCE /* don't contaminate other includes unnecessarily */
#else
#include <features.h> // NOLINT [build/include]
#ifndef __USE_GNU
#define __MUSL__
#endif
#endif
#endif

#if defined(__MINGW32__) || defined(__MINGW64__)
static const std::string target = "_mingw";
#elif defined(__MUSL__)
static const std::string target = "_musl";
#else
static const std::string target = "";
#endif

static const std::string result = platform + "_" + arch + target;
return result;
}

// Platform-specific helpers

#if defined(_WIN32)
Expand Down
8 changes: 4 additions & 4 deletions c/driver_manager/adbc_driver_manager_driver_loading.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ AdbcStatusCode LoadDriverManifest(const std::filesystem::path& driver_manifest,

auto driver = config.at_path("Driver.shared");
if (toml::table* platforms = driver.as_table()) {
auto view = platforms->at_path(adbc::CurrentArch());
auto view = platforms->at_path(InternalAdbcCurrentArch());
if (!view) {
std::string message = "Driver path not found in manifest '";
message += driver_manifest.string();
message += "' for current architecture '";
message += adbc::CurrentArch();
message += InternalAdbcCurrentArch();
message += "'. Architectures found:";
for (const auto& [key, val] : *platforms) {
message += " ";
Expand All @@ -213,7 +213,7 @@ AdbcStatusCode LoadDriverManifest(const std::filesystem::path& driver_manifest,
std::string message = "Driver path is an empty string in manifest '";
message += driver_manifest.string();
message += "' for current architecture '";
message += adbc::CurrentArch();
message += InternalAdbcCurrentArch();
message += "'";
SetError(error, std::move(message));
return ADBC_STATUS_INVALID_ARGUMENT;
Expand All @@ -225,7 +225,7 @@ AdbcStatusCode LoadDriverManifest(const std::filesystem::path& driver_manifest,
std::string message = "Driver path not found in manifest '";
message += driver_manifest.string();
message += "' for current architecture '";
message += adbc::CurrentArch();
message += InternalAdbcCurrentArch();
message += "'. Value was not a string";
SetError(error, std::move(message));
return ADBC_STATUS_INVALID_ARGUMENT;
Expand Down
6 changes: 3 additions & 3 deletions c/driver_manager/adbc_driver_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ class DriverManifest : public ::testing::Test {
toml::table{
{"shared",
toml::table{
{adbc::CurrentArch(), driver_path.string()},
{InternalAdbcCurrentArch(), driver_path.string()},
}},
}},
};
Expand Down Expand Up @@ -829,7 +829,7 @@ TEST_F(DriverManifest, ConfigEntrypoint) {
{"entrypoint", "BadEntrypointSymbolName"},
{"shared",
toml::table{
{adbc::CurrentArch(), driver_path.string()},
{InternalAdbcCurrentArch(), driver_path.string()},
}},
});

Expand Down Expand Up @@ -2166,7 +2166,7 @@ class DriverUriProfileTest : public ConnectionProfiles,
toml::table{
{"shared",
toml::table{
{adbc::CurrentArch(), driver_path.string()},
{InternalAdbcCurrentArch(), driver_path.string()},
}},
}},
};
Expand Down
Loading
Loading