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

Use hidden visibility for symbols for non-windows platforms #341

Merged
merged 6 commits into from
Jul 30, 2024
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ else()
if(CSP_BUILD_NO_CXX_ABI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
if (COVERAGE)
# TODO windows
add_compile_options(--coverage)
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ build-debug: ## build the library ( DEBUG ) - May need a make clean when switch
build-conda: ## build the library in Conda
python setup.py build build_ext --csp-no-vcpkg --inplace

build-conda-debug: ## build the library ( DEBUG ) - in Conda
SKBUILD_CONFIGURE_OPTIONS="" DEBUG=1 python setup.py build build_ext --csp-no-vcpkg --inplace

install: ## install library
python -m pip install .

Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/adapters/kafka/KafkaAdapterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct KafkaStatusMessageTypeTraits
using KafkaStatusMessageType = csp::Enum<KafkaStatusMessageTypeTraits>;

//Top level AdapterManager object for all kafka adapters in the engine
class KafkaAdapterManager final : public csp::AdapterManager
class CSP_PUBLIC KafkaAdapterManager final : public csp::AdapterManager
{
public:
KafkaAdapterManager( csp::Engine * engine, const Dictionary & properties );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DialectGenericListReaderInterface
};

template< typename T >
class TypedDialectGenericListReaderInterface : public DialectGenericListReaderInterface
class CSP_PUBLIC TypedDialectGenericListReaderInterface : public DialectGenericListReaderInterface
{
public:
using Ptr = std::shared_ptr<TypedDialectGenericListReaderInterface<T>>;
Expand All @@ -45,4 +45,4 @@ class TypedDialectGenericListReaderInterface : public DialectGenericListReaderIn

}

#endif
#endif
2 changes: 1 addition & 1 deletion cpp/csp/adapters/parquet/ParquetInputAdapterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace csp::adapters::parquet


//Top level AdapterManager object for all parquet adapters in the engine
class ParquetInputAdapterManager final : public csp::AdapterManager
class CSP_PUBLIC ParquetInputAdapterManager final : public csp::AdapterManager
{
public:
using GeneratorPtr = csp::Generator<std::string, csp::DateTime, csp::DateTime>::Ptr;
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/adapters/parquet/ParquetOutputAdapterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ParquetOutputFilenameAdapter;
class ParquetDictBasketOutputWriter;

//Top level AdapterManager object for all parquet adapters in the engine
class ParquetOutputAdapterManager final : public csp::AdapterManager
class CSP_PUBLIC ParquetOutputAdapterManager final : public csp::AdapterManager
{
public:
using FileVisitorCallback = std::function<void(const std::string &)>;
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/adapters/parquet/ParquetReaderColumnAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ void ListColumnAdapter<ValueArrayType, ValueType>::readCurValue()
if( this -> m_curChunkArray -> IsValid( curRow ) )
{
auto values = this -> m_curChunkArray -> value_slice( curRow );
auto typedValues = std::dynamic_pointer_cast<ValueArrayType>( values );
auto typedValues = std::static_pointer_cast<ValueArrayType>( values );

auto arrayValue = m_listReader -> create( typedValues -> length() );
auto* internalBuffer = m_listReader -> getRawDataBuffer( arrayValue );
Expand Down
6 changes: 2 additions & 4 deletions cpp/csp/adapters/websocket/ClientAdapterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ struct WebsocketClientStatusTypeTraits

using ClientStatusType = Enum<WebsocketClientStatusTypeTraits>;

class ClientAdapterManager final : public AdapterManager
class CSP_PUBLIC ClientAdapterManager final : public AdapterManager
{


public:
ClientAdapterManager(
Engine * engine,
Expand Down Expand Up @@ -78,4 +76,4 @@ class ClientAdapterManager final : public AdapterManager

}

#endif
#endif
4 changes: 2 additions & 2 deletions cpp/csp/core/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace csp
{

class Exception : public std::exception
class CSP_PUBLIC Exception : public std::exception
{
public:
Exception( const char * exType, const std::string & description, const char * file, const char * func, int line ) :
Expand Down Expand Up @@ -59,7 +59,7 @@ class Exception : public std::exception
};

#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define CSP_DECLARE_EXCEPTION( DerivedException, BaseException ) class DerivedException : public BaseException { public: DerivedException( const char * exType, const std::string &r, const char * file, const char * func, int line ) : BaseException( exType, r, file, func, line ) {} };
#define CSP_DECLARE_EXCEPTION( DerivedException, BaseException ) class CSP_PUBLIC DerivedException : public BaseException { public: DerivedException( const char * exType, const std::string &r, const char * file, const char * func, int line ) : BaseException( exType, r, file, func, line ) {} };

CSP_DECLARE_EXCEPTION( AssertionError, Exception )
CSP_DECLARE_EXCEPTION( RuntimeException, Exception )
Expand Down
10 changes: 6 additions & 4 deletions cpp/csp/core/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#undef ERROR
#undef GetMessage

#define DLL_LOCAL
#define CSP_LOCAL
#define CSP_PUBLIC __declspec(dllexport)

#ifdef CSPTYPESIMPL_EXPORTS
#define CSPTYPESIMPL_EXPORT __declspec(dllexport)
Expand Down Expand Up @@ -90,10 +91,11 @@ inline uint8_t ffs(uint64_t n)

#else

#define CSPIMPL_EXPORT
#define CSPTYPESIMPL_EXPORT
#define CSPIMPL_EXPORT __attribute__ ((visibility ("default")))
#define CSPTYPESIMPL_EXPORT __attribute__ ((visibility ("default")))

#define DLL_LOCAL __attribute__ ((visibility ("hidden")))
#define CSP_LOCAL __attribute__ ((visibility ("hidden")))
#define CSP_PUBLIC __attribute__ ((visibility ("default")))

#define START_PACKED
#define END_PACKED __attribute__((packed))
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/engine/AdapterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ bool ManagedSimInputAdapter::pushNullTick()
return true;
}

class AdapterManager : public EngineOwned
class CSP_PUBLIC AdapterManager : public EngineOwned
{
public:
AdapterManager( csp::Engine * );
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/engine/Feedback.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FeedbackOutputAdapter final : public OutputAdapter
};

template<typename T>
class FeedbackInputAdapter final : public InputAdapter
class CSP_PUBLIC FeedbackInputAdapter final : public InputAdapter
{
public:
using InputAdapter::InputAdapter;
Expand Down
4 changes: 2 additions & 2 deletions cpp/csp/engine/Struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,13 +756,13 @@ class Struct
void decref()
{
//Work around GCC12 bug mis-identifying this code as use-after-free
#ifdef __linux__
#if defined(__linux__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
#endif
if( --hidden() -> refcount == 0 )
delete this;
#ifdef __linux__
#if defined(__linux__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/python/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace csp::python
{

class PythonPassthrough : public csp::Exception
class CSP_PUBLIC PythonPassthrough : public csp::Exception
{
public:
PythonPassthrough( const char * exType, const std::string &r, const char * file,
Expand Down
19 changes: 18 additions & 1 deletion cpp/csp/python/InitHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace csp::python
{

class DLL_LOCAL InitHelper
class CSP_LOCAL InitHelper
{
public:
~InitHelper() {}
Expand Down Expand Up @@ -111,4 +111,21 @@ inline bool InitHelper::execute( PyObject * module )
}

}

//PyMODINIT_FUNC in Python <3.9 doesn't export the function/make visible
//this is required since we build with hidden visibility by default
//the below macro code can be removed once 3.8 support is dropped
//
//see similar issues:
//https://github.com/scipy/scipy/issues/15996
//https://github.com/mesonbuild/meson/pull/10369

#if PY_VERSION_HEX < 0x03090000
#ifdef PyMODINIT_FUNC
svatasoiu marked this conversation as resolved.
Show resolved Hide resolved
#undef PyMODINIT_FUNC
#endif

#define PyMODINIT_FUNC extern "C" CSP_PUBLIC PyObject*
#endif

#endif
2 changes: 1 addition & 1 deletion cpp/csp/python/PyCspEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct CSPTYPESIMPL_EXPORT PyCspEnumMeta : public PyHeapTypeObject
static PyTypeObject PyType;
};

//TODO Windows - need to figure out why adding DLL_PUBLIC to this class leads to weird compilation errors on CspEnumMeta's unordered_map...
//TODO Windows - need to figure out why adding CSP_PUBLIC to this class leads to weird compilation errors on CspEnumMeta's unordered_map...

//This is an extension of csp::CspEnumMeta for python dialect, we need it in order to
//keep a reference to the python enum type from conversion to/from csp::CspEnumMeta <-> PyObject properly
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/python/adapters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if(CSP_BUILD_PARQUET_ADAPTER)
endif()
target_link_libraries(parquetadapterimpl csp_core csp_engine cspimpl csp_parquet_adapter)
target_include_directories(parquetadapterimpl PUBLIC ${ARROW_INCLUDE_DIR} ${PARQUET_INCLUDE_DIR} "${VENDORED_PYARROW_ROOT}")
target_compile_definitions(parquetadapterimpl PUBLIC ARROW_PYTHON_STATIC)
target_compile_definitions(parquetadapterimpl PUBLIC ARROW_PYTHON_STATIC -DARROW_PYTHON_EXPORT=)
install(TARGETS parquetadapterimpl RUNTIME DESTINATION ${CSP_RUNTIME_INSTALL_SUBDIR} )
endif()

Expand Down
Loading