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

SNOW-1524259: Reduce dependencies size in libsnowflakeclient #782

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
89 changes: 88 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,20 @@ if (MOCK)
endif ()

add_library(snowflakeclient STATIC ${SOURCE_FILES} ${SOURCE_FILES_PUT_GET} ${SOURCE_FILES_CPP_WRAPPER})

set_target_properties(snowflakeclient PROPERTIES LINKER_LANGUAGE CXX)
set_property(TARGET snowflakeclient PROPERTY C_STANDARD 99)
#set (CMAKE_CXX_STANDARD 11)

if (BUILD_SHARED_LIBS)
if (WIN32)
add_library(snowflakeclient_dynamic ${SOURCE_FILES} ${SOURCE_FILES_PUT_GET} ${SOURCE_FILES_CPP_WRAPPER} ${CMAKE_CURRENT_SOURCE_DIR}/exports.def)
else()
add_library(snowflakeclient_dynamic ${SOURCE_FILES} ${SOURCE_FILES_PUT_GET} ${SOURCE_FILES_CPP_WRAPPER})
endif()
set_target_properties(snowflakeclient_dynamic PROPERTIES LINKER_LANGUAGE CXX)
set_property(TARGET snowflakeclient_dynamic PROPERTY C_STANDARD 99)
endif()

if(LINUX)
link_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/${CMAKE_BUILD_TYPE}/oob/lib"
Expand Down Expand Up @@ -512,6 +521,65 @@ elseif()
endif()
endif()

set(AWS_ALL_LIBS
${AWS_S3_LIB}
${AWS_CORE_LIB}
${AWS_CRT_CPP_LIB}
${AWS_C_EVENT_STREAM_LIB}
${AWS_C_CHECKSUMS_LIB}
${AWS_C_S3_LIB}
${AWS_C_AUTH_LIB}
${AWS_C_HTTP_LIB}
${AWS_C_COMPRESSION_LIB}
${AWS_C_IO_LIB}
${AWS_C_CAL_LIB}
${AWS_C_MQTT_LIB}
${AWS_S2N_LIB}
${AWS_C_COMMON_LIB}
${AWS_C_SDKUTILS_LIB}
)

if (LINUX)
set(ARROW_ALL_LIBS
${ARROW_ARROW_LIB}
${BOOST_FILESYSTEM_LIB} ${BOOST_REGEX_LIB} ${BOOST_SYSTEM_LIB}
${ARROW_BROTLIDEC_LIB} ${ARROW_BROTLIENC_LIB} ${ARROW_BROTLICOMMON_LIB}
${ARROW_DOUBLECONVERSION_LIB}
${ARROW_FLATBUFFERS_LIB}
${ARROW_GFLAGS_LIB}
${ARROW_GLOG_LIB}
${ARROW_JEMALLOCPIC_LIB}
${ARROW_LZ4_LIB} ${ARROW_LZO2_LIB}
${ARROW_SNAPPY_LIB}
${ARROW_ZSTD_LIB})
elseif (APPLE)
set(ARROW_ALL_LIBS
${ARROW_ARROW_LIB}
${BOOST_FILESYSTEM_LIB} ${BOOST_REGEX_LIB} ${BOOST_SYSTEM_LIB}
${ARROW_BROTLICOMMON_LIB} ${ARROW_BROTLIDEC_LIB} ${ARROW_BROTLIENC_LIB}
${ARROW_FLATBUFFERS_LIB}
${ARROW_GFLAGS_LIB}
${ARROW_GLOG_LIB}
${ARROW_JEMALLOCPIC_LIB}
${ARROW_LZ4_LIB} ${ARROW_LZO2_LIB}
${ARROW_SNAPPY_LIB}
${ARROW_ZSTD_LIB})
elseif (WIN32)
set(ARROW_ALL_LIBS
${ARROW_ARROW_LIB}
${BOOST_FILESYSTEM_LIB} ${BOOST_REGEX_LIB} ${BOOST_SYSTEM_LIB}
${ARROW_BROTLICOMMON_LIB} ${ARROW_BROTLIDEC_LIB} ${ARROW_BROTLIENC_LIB}
${ARROW_BZ2_LIB}
${ARROW_DOUBLECONVERSION_LIB}
${ARROW_EVENT_LIB} ${ARROW_EVENTCORE_LIB} ${ARROW_EVENTEXTRA_LIB}
${ARROW_FLATBUFFERS_LIB}
${ARROW_GFLAGS_LIB}
${ARROW_GLOG_LIB}
${ARROW_LZ4_LIB}
${ARROW_SNAPPY_LIB}
${ARROW_ZLIB_LIB} ${ARROW_ZSTD_LIB})
endif ()

if (LINUX)
# Linux
target_link_libraries(snowflakeclient rt dl z)
Expand All @@ -521,6 +589,25 @@ if (APPLE)
target_link_libraries(snowflakeclient dl z)
endif ()

if (BUILD_SHARED_LIBS)
if (LINUX)
set(DYNAMICLIB_LINK_OPTS rt dl z ${CMOCKA_LIB} ${ARROW_ALL_LIBS} ${AZURE_STORAGE_LITE_LIB} ${AWS_ALL_LIBS} -Wl,--whole-archive ${OOB_LIB} ${CURL_LIB} ${SSL_LIB} ${CRYPTO_LIB} ${UUID_LIB}
pthread -Wl,--no-whole-archive -Wl,--as-needed -static-libgcc -static-libstdc++ -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports_Linux.map)
elseif (APPLE)
set(DYNAMICLIB_LINK_OPTS dl z pthread -exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/exports_Darwin.map "-framework CoreFoundation -framework SystemConfiguration -framework security"
${CMOCKA_LIB} ${ARROW_ALL_LIBS} ${AZURE_STORAGE_LITE_LIB} ${AWS_ALL_LIBS} ${OOB_LIB} ${CURL_LIB} ${SSL_LIB} ${CRYPTO_LIB} ${UUID_LIB})
elseif (WIN32)
if (WIN32_DEBUG)
set(DYNAMICLIB_LINK_OPTS ${CMOCKA_LIB} ${ARROW_ALL_LIBS} ${AWS_ALL_LIBS} ${OOB_LIB} ${CURL_LIB} ${SSL_LIB} ${CRYPTO_LIB} ${ZLIB_LIB} ${AZURE_STORAGE_LITE_LIB}
Version.lib Userenv.lib Bcrypt.lib ucrtd.lib Secur32.lib Ncrypt.lib Shlwapi.lib)
else()
set(DYNAMICLIB_LINK_OPTS ${CMOCKA_LIB} ${AWS_ALL_LIBS} ${AZURE_STORAGE_LITE_LIB} ${ARROW_ALL_LIBS} ${CURL_LIB} ${OOB_LIB} ${SSL_LIB} ${CRYPTO_LIB} ${ZLIB_LIB}
Version.lib Userenv.lib Bcrypt.lib Secur32.lib Ncrypt.lib Shlwapi.lib)
endif()
endif()
target_link_libraries(snowflakeclient_dynamic ${DYNAMICLIB_LINK_OPTS})
endif()

add_subdirectory(examples)

if (BUILD_TESTS)
Expand Down
81 changes: 81 additions & 0 deletions exports.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@


SECTIONS

EXPORTS


snowflake_query_result_capture_init @1
snowflake_global_init @2
snowflake_global_term @3
snowflake_global_set_attribute @4
snowflake_global_get_attribute @5
snowflake_init @6
snowflake_term @7
snowflake_connect @8
snowflake_set_attribute @9
snowflake_get_attribute @10
snowflake_stmt @11
snowflake_query_result_capture_term @12
snowflake_stmt_term @13
snowflake_trans_begin @14
snowflake_trans_commit @15
snowflake_trans_rollback @16
snowflake_stmt_error @17
snowflake_error @18
snowflake_propagate_error @19
snowflake_query @20
snowflake_affected_rows @21
snowflake_num_rows @22
snowflake_num_fields @23
snowflake_sqlstate @24
snowflake_desc @25
snowflake_prepare @26
snowflake_stmt_set_attr @27
snowflake_stmt_get_attr @28
snowflake_execute @29
snowflake_execute_with_capture @30
snowflake_describe_with_capture @31
snowflake_fetch @32
snowflake_num_params @33
snowflake_bind_input_init @34
snowflake_bind_param @35
snowflake_bind_param_array @36
snowflake_sfqid @37
snowflake_type_to_string @38
snowflake_c_type_to_string @39
snowflake_column_as_boolean @40
snowflake_column_as_uint8 @41
snowflake_column_as_uint32 @42
snowflake_column_as_uint64 @43
snowflake_column_as_int8 @44
snowflake_column_as_int32 @45
snowflake_column_as_int64 @46
snowflake_column_as_float32 @47
snowflake_column_as_float64 @48
snowflake_column_as_timestamp @49
snowflake_column_as_const_str @50
snowflake_raw_value_to_str_rep @51
snowflake_column_as_str @52
snowflake_column_strlen @53
snowflake_column_is_null @54
snowflake_timestamp_from_parts @55
snowflake_timestamp_from_epoch_seconds @56
snowflake_timestamp_to_string @57
snowflake_timestamp_get_epoch_seconds @58
snowflake_timestamp_get_nanoseconds @59
snowflake_timestamp_get_seconds @60
snowflake_timestamp_get_minutes @61
snowflake_timestamp_get_hours @62
snowflake_timestamp_get_wday @63
snowflake_timestamp_get_mday @64
snowflake_timestamp_get_yday @65
snowflake_timestamp_get_month @66
snowflake_timestamp_get_year @67
snowflake_timestamp_get_tzoffset @68
snowflake_timestamp_get_scale @69
sf_setenv @70
sf_unsetenv @71
sf_getenv_s @72
sf_get_tmp_dir @73
uuid4_generate @74
81 changes: 81 additions & 0 deletions exports_Darwin.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

#
# List of symbols exported from dylib.
# Symbols must be in mangled form (prepended with underscore).
#


_snowflake_query_result_capture_init
_snowflake_global_init
_snowflake_global_term
_snowflake_global_set_attribute
_snowflake_global_get_attribute
_snowflake_init
_snowflake_term
_snowflake_connect
_snowflake_set_attribute
_snowflake_get_attribute
_snowflake_stmt
_snowflake_query_result_capture_term
_snowflake_stmt_term
_snowflake_trans_begin
_snowflake_trans_commit
_snowflake_trans_rollback
_snowflake_stmt_error
_snowflake_error
_snowflake_propagate_error
_snowflake_query
_snowflake_affected_rows
_snowflake_num_rows
_snowflake_num_fields
_snowflake_sqlstate
_snowflake_desc
_snowflake_prepare
_snowflake_stmt_set_attr
_snowflake_stmt_get_attr
_snowflake_execute
_snowflake_execute_with_capture
_snowflake_describe_with_capture
_snowflake_fetch
_snowflake_num_params
_snowflake_bind_input_init
_snowflake_bind_param
_snowflake_bind_param_array
_snowflake_sfqid
_snowflake_type_to_string
_snowflake_c_type_to_string
_snowflake_column_as_boolean
_snowflake_column_as_uint8
_snowflake_column_as_uint32
_snowflake_column_as_uint64
_snowflake_column_as_int8
_snowflake_column_as_int32
_snowflake_column_as_int64
_snowflake_column_as_float32
_snowflake_column_as_float64
_snowflake_column_as_timestamp
_snowflake_column_as_const_str
_snowflake_raw_value_to_str_rep
_snowflake_column_as_str
_snowflake_column_strlen
_snowflake_column_is_null
_snowflake_timestamp_from_parts
_snowflake_timestamp_from_epoch_seconds
_snowflake_timestamp_to_string
_snowflake_timestamp_get_epoch_seconds
_snowflake_timestamp_get_nanoseconds
_snowflake_timestamp_get_seconds
_snowflake_timestamp_get_minutes
_snowflake_timestamp_get_hours
_snowflake_timestamp_get_wday
_snowflake_timestamp_get_mday
_snowflake_timestamp_get_yday
_snowflake_timestamp_get_month
_snowflake_timestamp_get_year
_snowflake_timestamp_get_tzoffset
_snowflake_timestamp_get_scale
_sf_setenv
_sf_unsetenv
_sf_getenv_s
_sf_get_tmp_dir
_uuid4_generate
78 changes: 78 additions & 0 deletions exports_Linux.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
global:
snowflake_query_result_capture_init;
snowflake_global_init;
snowflake_global_term;
snowflake_global_set_attribute;
snowflake_global_get_attribute;
snowflake_init;
snowflake_term;
snowflake_connect;
snowflake_set_attribute;
snowflake_get_attribute;
snowflake_stmt;
snowflake_query_result_capture_term;
snowflake_stmt_term;
snowflake_trans_begin;
snowflake_trans_commit;
snowflake_trans_rollback;
snowflake_stmt_error;
snowflake_error;
snowflake_propagate_error;
snowflake_query;
snowflake_affected_rows;
snowflake_num_rows;
snowflake_num_fields;
snowflake_sqlstate;
snowflake_desc;
snowflake_prepare;
snowflake_stmt_set_attr;
snowflake_stmt_get_attr;
snowflake_execute;
snowflake_execute_with_capture;
snowflake_describe_with_capture;
snowflake_fetch;
snowflake_num_params;
snowflake_bind_input_init;
snowflake_bind_param;
snowflake_bind_param_array;
snowflake_sfqid;
snowflake_type_to_string;
snowflake_c_type_to_string;
snowflake_column_as_boolean;
snowflake_column_as_uint8;
snowflake_column_as_uint32;
snowflake_column_as_uint64;
snowflake_column_as_int8;
snowflake_column_as_int32;
snowflake_column_as_int64;
snowflake_column_as_float32;
snowflake_column_as_float64;
snowflake_column_as_timestamp;
snowflake_column_as_const_str;
snowflake_raw_value_to_str_rep;
snowflake_column_as_str;
snowflake_column_strlen;
snowflake_column_is_null;
snowflake_timestamp_from_parts;
snowflake_timestamp_from_epoch_seconds;
snowflake_timestamp_to_string;
snowflake_timestamp_get_epoch_seconds;
snowflake_timestamp_get_nanoseconds;
snowflake_timestamp_get_seconds;
snowflake_timestamp_get_minutes;
snowflake_timestamp_get_hours;
snowflake_timestamp_get_wday;
snowflake_timestamp_get_mday;
snowflake_timestamp_get_yday;
snowflake_timestamp_get_month;
snowflake_timestamp_get_year;
snowflake_timestamp_get_tzoffset;
snowflake_timestamp_get_scale;
sf_setenv;
sf_unsetenv;
sf_getenv_s;
sf_get_tmp_dir;
uuid4_generate;
local: *;
};
11 changes: 11 additions & 0 deletions scripts/build_libsnowflakeclient.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set vs_version=%3
:: for ODBC, dynamic runtime needs to be set to off
set dynamic_runtime=%4
set build_tests=%5
set share_lib=%6

set msvc_runtime_library=MultiThreaded

Expand All @@ -39,6 +40,11 @@ if not "%build_tests%"=="ON" (
)
echo === build_tests: %build_tests%

if not "%share_lib%"=="ON" (
set share_lib=OFF
)
echo === share_lib: %share_lib%

call "%scriptdir%_init.bat" %platform% %build_type% %vs_version%
if %ERRORLEVEL% NEQ 0 goto :error
set curdir=%cd%
Expand All @@ -59,6 +65,7 @@ if %ERRORLEVEL% NEQ 0 goto :error

cmake -G "%cmake_generator%" -A %cmake_architecture% ^
-DCMAKE_MSVC_RUNTIME_LIBRARY=%msvc_runtime_library% ^
-DBUILD_SHARED_LIBS=%share_lib% ^
-DBUILD_TESTS=%build_tests% ^
-DCMAKE_BUILD_TYPE=%build_type% ^
-DVSDIR:STRING=%vsdir% ..
Expand All @@ -82,6 +89,10 @@ copy /v /y ^
.\%cmake_dir%\%build_type%\snowflakeclient.* ^
.\deps-build\%build_dir%\libsnowflakeclient\lib

copy /v /y ^
.\%cmake_dir%\%build_type%\snowflakeclient_dynamic.* ^
.\deps-build\%build_dir%\libsnowflakeclient\lib

copy /v /y ^
.\include\snowflake\* ^
.\deps-build\%build_dir%\libsnowflakeclient\include\snowflake\*
Expand Down
Loading
Loading