Skip to content

Commit

Permalink
hide symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
samansmink committed Nov 13, 2024
1 parent f709a8e commit 86dbb2e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ add_definitions(-DDUCKDB_EXTENSION_NAME=${EXTENSION_NAME})
###
project(${EXTENSION_NAME} LANGUAGES C)

# Create Extension library
set(EXTENSION_SOURCES
src/add_numbers.c
src/capi_quack.c
src/add_numbers.c
src/capi_quack.c
)

add_library(${EXTENSION_NAME} SHARED ${EXTENSION_SOURCES})

# Hide symbols
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(VISIBILITY_INLINES_HIDDEN ON)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")

# Include own headers
target_include_directories(${EXTENSION_NAME} PRIVATE src/include)

# Include DuckDB C API headers
target_include_directories(${EXTENSION_NAME} PRIVATE duckdb_capi)
8 changes: 7 additions & 1 deletion duckdb_capi/duckdb_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,12 @@ typedef struct {
// Place in global scope of any C/C++ file that needs to access the extension API
#define DUCKDB_EXTENSION_EXTERN extern duckdb_ext_api_v0 duckdb_ext_api;

#ifdef _WIN32
#define ENTRYPOINT_VISIBILITY __declspec(dllexport)
#else
#define ENTRYPOINT_VISIBILITY __attribute__((visibility("default")))
#endif

//===--------------------------------------------------------------------===//
// Entrypoint Macros
//===--------------------------------------------------------------------===//
Expand All @@ -920,7 +926,7 @@ typedef struct {
#define DUCKDB_EXTENSION_ENTRYPOINT \
DUCKDB_EXTENSION_GLOBAL static bool DUCKDB_EXTENSION_GLUE(DUCKDB_EXTENSION_NAME, _init_c_api_internal)( \
duckdb_connection connection, duckdb_extension_info info, struct duckdb_extension_access * access); \
DUCKDB_EXTENSION_EXTERN_C_GUARD_OPEN DUCKDB_EXTENSION_API bool DUCKDB_EXTENSION_GLUE( \
ENTRYPOINT_VISIBILITY DUCKDB_EXTENSION_EXTERN_C_GUARD_OPEN DUCKDB_EXTENSION_API bool DUCKDB_EXTENSION_GLUE( \
DUCKDB_EXTENSION_NAME, _init_c_api)(duckdb_extension_info info, struct duckdb_extension_access * access) { \
DUCKDB_EXTENSION_API_INIT(info, access, DUCKDB_EXTENSION_API_VERSION_STRING); \
duckdb_database *db = access->get_database(info); \
Expand Down

0 comments on commit 86dbb2e

Please sign in to comment.