From 0782f8648d24abe8494efca0bb63b927622ec30d Mon Sep 17 00:00:00 2001 From: Keenan Gugeler Date: Fri, 10 Nov 2023 17:40:32 -0500 Subject: [PATCH] mac: fix explicit symbol exports Exception information necessary for properly catching exceptions, seems to not be exported on Mac unless we export the exception, which seems to be different from Linux & Windows. In additional, Mac issues a warning when building the Python module (which itself builds as a shared library). The issue is that the python module links with our static library, and the static library does not export symbols (since it doesn't do anything for static libraries). However, this mismatch in visibility causes a warning. Technically, we shouldn't build a shared library with a static library since the static library isn't position-independent code, but we don't really have other options unless we embed all of the object files? We should probably link the python library against `libkuzu.so` and ship it alongside the python bindings. However, this will be delayed until after the release. Ref #2136. --- .github/workflows/ci-workflow.yml | 1 + CMakeLists.txt | 18 ++++-------------- src/include/common/exception/binder.h | 3 ++- src/include/common/exception/buffer_manager.h | 3 ++- src/include/common/exception/catalog.h | 3 ++- src/include/common/exception/connection.h | 3 ++- src/include/common/exception/conversion.h | 3 ++- src/include/common/exception/copy.h | 3 ++- src/include/common/exception/exception.h | 4 +++- src/include/common/exception/internal.h | 3 ++- src/include/common/exception/interrupt.h | 3 ++- src/include/common/exception/message.h | 1 + src/include/common/exception/not_implemented.h | 3 ++- src/include/common/exception/overflow.h | 3 ++- src/include/common/exception/parser.h | 3 ++- src/include/common/exception/runtime.h | 3 ++- src/include/common/exception/storage.h | 3 ++- .../common/exception/transaction_manager.h | 3 ++- 18 files changed, 37 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index be62958e2f..f9b2e86514 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -338,6 +338,7 @@ jobs: run: | ulimit -n 10240 source /Users/runner/.cargo/env + cargo update -p cc --precise '1.0.83' make rusttest - name: Rust example diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ec4c89451..0d09e98bfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,8 @@ set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -if(NOT APPLE) - set(CMAKE_CXX_VISIBILITY_PRESET hidden) - set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) -endif() +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) option(ENABLE_WERROR "Treat all warnings as errors" FALSE) if(ENABLE_WERROR) @@ -166,18 +164,10 @@ endfunction() function(add_kuzu_api_test TEST_NAME) set(SRCS ${ARGN}) add_executable(${TEST_NAME} ${SRCS}) - if(APPLE) - target_link_libraries(${TEST_NAME} PRIVATE test_helper test_runner graph_test) - else() - target_link_libraries(${TEST_NAME} PRIVATE api_graph_test api_test_helper) - endif() + target_link_libraries(${TEST_NAME} PRIVATE api_graph_test api_test_helper) target_include_directories(${TEST_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/test/include) include(GoogleTest) - if(APPLE) - gtest_discover_tests(${TEST_NAME} DISCOVERY_TIMEOUT 600 DISCOVERY_MODE PRE_TEST) - else() - gtest_discover_tests(${TEST_NAME}) - endif() + gtest_discover_tests(${TEST_NAME}) endfunction() add_definitions(-DKUZU_ROOT_DIRECTORY="${PROJECT_SOURCE_DIR}") diff --git a/src/include/common/exception/binder.h b/src/include/common/exception/binder.h index 4633c62e02..de6a8d31cd 100644 --- a/src/include/common/exception/binder.h +++ b/src/include/common/exception/binder.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class BinderException : public Exception { +class KUZU_API BinderException : public Exception { public: explicit BinderException(const std::string& msg) : Exception("Binder exception: " + msg){}; }; diff --git a/src/include/common/exception/buffer_manager.h b/src/include/common/exception/buffer_manager.h index 76a864ab01..45e9c76320 100644 --- a/src/include/common/exception/buffer_manager.h +++ b/src/include/common/exception/buffer_manager.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class BufferManagerException : public Exception { +class KUZU_API BufferManagerException : public Exception { public: explicit BufferManagerException(const std::string& msg) : Exception("Buffer manager exception: " + msg){}; diff --git a/src/include/common/exception/catalog.h b/src/include/common/exception/catalog.h index 5cb2a805a0..2d21f855fa 100644 --- a/src/include/common/exception/catalog.h +++ b/src/include/common/exception/catalog.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class CatalogException : public Exception { +class KUZU_API CatalogException : public Exception { public: explicit CatalogException(const std::string& msg) : Exception("Catalog exception: " + msg){}; }; diff --git a/src/include/common/exception/connection.h b/src/include/common/exception/connection.h index 93ba0d7978..d1420e49ab 100644 --- a/src/include/common/exception/connection.h +++ b/src/include/common/exception/connection.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class ConnectionException : public Exception { +class KUZU_API ConnectionException : public Exception { public: explicit ConnectionException(const std::string& msg) : Exception(msg){}; }; diff --git a/src/include/common/exception/conversion.h b/src/include/common/exception/conversion.h index 19a3d3028e..4938ad1334 100644 --- a/src/include/common/exception/conversion.h +++ b/src/include/common/exception/conversion.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class ConversionException : public Exception { +class KUZU_API ConversionException : public Exception { public: explicit ConversionException(const std::string& msg) : Exception("Conversion exception: " + msg) {} diff --git a/src/include/common/exception/copy.h b/src/include/common/exception/copy.h index 08af912196..48b6906521 100644 --- a/src/include/common/exception/copy.h +++ b/src/include/common/exception/copy.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class CopyException : public Exception { +class KUZU_API CopyException : public Exception { public: explicit CopyException(const std::string& msg) : Exception("Copy exception: " + msg){}; }; diff --git a/src/include/common/exception/exception.h b/src/include/common/exception/exception.h index 6833ef605d..cfaf4e1962 100644 --- a/src/include/common/exception/exception.h +++ b/src/include/common/exception/exception.h @@ -3,10 +3,12 @@ #include #include +#include "common/api.h" + namespace kuzu { namespace common { -class Exception : public std::exception { +class KUZU_API Exception : public std::exception { public: explicit Exception(std::string msg) : exception(), exception_message_(std::move(msg)){}; diff --git a/src/include/common/exception/internal.h b/src/include/common/exception/internal.h index a254b14236..6e8a176a81 100644 --- a/src/include/common/exception/internal.h +++ b/src/include/common/exception/internal.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class InternalException : public Exception { +class KUZU_API InternalException : public Exception { public: explicit InternalException(const std::string& msg) : Exception(msg){}; }; diff --git a/src/include/common/exception/interrupt.h b/src/include/common/exception/interrupt.h index ab69641a32..7bc5091b42 100644 --- a/src/include/common/exception/interrupt.h +++ b/src/include/common/exception/interrupt.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class InterruptException : public Exception { +class KUZU_API InterruptException : public Exception { public: explicit InterruptException() : Exception("Interrupted."){}; }; diff --git a/src/include/common/exception/message.h b/src/include/common/exception/message.h index b87e59ebfd..948b3731e6 100644 --- a/src/include/common/exception/message.h +++ b/src/include/common/exception/message.h @@ -5,6 +5,7 @@ namespace kuzu { namespace common { + struct ExceptionMessage { static std::string existedPKException(const std::string& pkString); static std::string nonExistPKException(const std::string& pkString); diff --git a/src/include/common/exception/not_implemented.h b/src/include/common/exception/not_implemented.h index a9ff55b30a..d0aa63ec43 100644 --- a/src/include/common/exception/not_implemented.h +++ b/src/include/common/exception/not_implemented.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class NotImplementedException : public Exception { +class KUZU_API NotImplementedException : public Exception { public: explicit NotImplementedException(const std::string& msg) : Exception(msg){}; }; diff --git a/src/include/common/exception/overflow.h b/src/include/common/exception/overflow.h index 1d8b53a00b..c7b14168f7 100644 --- a/src/include/common/exception/overflow.h +++ b/src/include/common/exception/overflow.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class OverflowException : public Exception { +class KUZU_API OverflowException : public Exception { public: explicit OverflowException(const std::string& msg) : Exception("Overflow exception: " + msg) {} }; diff --git a/src/include/common/exception/parser.h b/src/include/common/exception/parser.h index a592055ebc..635c8d9923 100644 --- a/src/include/common/exception/parser.h +++ b/src/include/common/exception/parser.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class ParserException : public Exception { +class KUZU_API ParserException : public Exception { public: explicit ParserException(const std::string& msg) : Exception("Parser exception: " + msg){}; }; diff --git a/src/include/common/exception/runtime.h b/src/include/common/exception/runtime.h index 02cff932d1..b864a189be 100644 --- a/src/include/common/exception/runtime.h +++ b/src/include/common/exception/runtime.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class RuntimeException : public Exception { +class KUZU_API RuntimeException : public Exception { public: explicit RuntimeException(const std::string& msg) : Exception("Runtime exception: " + msg){}; }; diff --git a/src/include/common/exception/storage.h b/src/include/common/exception/storage.h index 9aefc62cdb..474fffa07a 100644 --- a/src/include/common/exception/storage.h +++ b/src/include/common/exception/storage.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class StorageException : public Exception { +class KUZU_API StorageException : public Exception { public: explicit StorageException(const std::string& msg) : Exception("Storage exception: " + msg){}; }; diff --git a/src/include/common/exception/transaction_manager.h b/src/include/common/exception/transaction_manager.h index e0837e70fa..09d64a96d1 100644 --- a/src/include/common/exception/transaction_manager.h +++ b/src/include/common/exception/transaction_manager.h @@ -1,11 +1,12 @@ #pragma once +#include "common/api.h" #include "exception.h" namespace kuzu { namespace common { -class TransactionManagerException : public Exception { +class KUZU_API TransactionManagerException : public Exception { public: explicit TransactionManagerException(const std::string& msg) : Exception(msg){}; };