ARROW-4903: [C++] Fix static/shared-only builds

This commit is contained in:
Uwe L. Korn committed 2019-03-15 20:48:34 +01:00
1 parent 0451b9942e
commit d16900d2b8
7 files changed
+95 -45

No files matched your search

+3
View File
@@ -50,6 +50,9 @@ cmake -GNinja \
-DARROW_BUILD_UTILITIES=${ARROW_BUILD_UTILITIES:-ON} \
-DARROW_INSTALL_NAME_RPATH=${ARROW_INSTALL_NAME_RPATH:-ON} \
-DARROW_EXTRA_ERROR_CONTEXT=ON \
-DARROW_BUILD_SHARED=${ARROW_BUILD_SHARED:-ON} \
-DARROW_BUILD_STATIC=${ARROW_BUILD_STATIC:-ON} \
-DARROW_TEST_LINKAGE=${ARROW_TEST_LINKAGE:-shared} \
-DCMAKE_CXX_FLAGS=$CXXFLAGS \
${CMAKE_ARGS} \
${source_dir}
+6 -1
View File
@@ -23,7 +23,12 @@ target_link_libraries(parquet-low-level-example parquet_static)
target_link_libraries(parquet-low-level-example2 parquet_static)
add_executable(parquet-arrow-example parquet-arrow/reader-writer.cc)
target_link_libraries(parquet-arrow-example parquet_shared)
# Prefer shared linkage but use static if shared build is deactivated
if (ARROW_BUILD_SHARED)
target_link_libraries(parquet-arrow-example parquet_shared)
else()
target_link_libraries(parquet-arrow-example parquet_static)
endif()
add_dependencies(parquet
parquet-low-level-example
+13 -9
View File
@@ -31,11 +31,19 @@ if(GRPC_HAS_ADDRESS_SORTING)
list(APPEND ARROW_FLIGHT_STATIC_LINK_LIBS gRPC::address_sorting)
endif()
set(ARROW_FLIGHT_TEST_LINK_LIBS
arrow_flight_shared
arrow_flight_testing_shared
${ARROW_TEST_SHARED_LINK_LIBS}
${ARROW_FLIGHT_STATIC_LINK_LIBS})
if (ARROW_TEST_LINKAGE STREQUAL "static")
set(ARROW_FLIGHT_TEST_LINK_LIBS
arrow_flight_static
arrow_flight_testing_static
${ARROW_TEST_STATIC_LINK_LIBS}
${ARROW_FLIGHT_STATIC_LINK_LIBS})
else()
set(ARROW_FLIGHT_TEST_LINK_LIBS
arrow_flight_shared
arrow_flight_testing_shared
${ARROW_TEST_SHARED_LINK_LIBS}
${ARROW_FLIGHT_STATIC_LINK_LIBS})
endif()
# TODO(wesm): Protobuf shared vs static linking
@@ -150,16 +158,12 @@ if(ARROW_BUILD_BENCHMARKS)
add_executable(arrow-flight-perf-server perf-server.cc perf.pb.cc)
target_link_libraries(arrow-flight-perf-server
arrow_flight_shared
arrow_flight_testing_shared
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::GTest)
add_executable(arrow-flight-benchmark flight-benchmark.cc perf.pb.cc)
target_link_libraries(arrow-flight-benchmark
arrow_flight_static
arrow_testing_static
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::GTest)
+24 -24
View File
@@ -67,7 +67,7 @@ static inline void CompareBatchColumnsDetailed(const RecordBatch& result,
const auto kListInt32 = list(int32());
const auto kListListInt32 = list(kListInt32);
Status MakeRandomInt32Array(int64_t length, bool include_nulls, MemoryPool* pool,
static inline Status MakeRandomInt32Array(int64_t length, bool include_nulls, MemoryPool* pool,
std::shared_ptr<Array>* out, uint32_t seed = 0) {
random::RandomArrayGenerator rand(seed);
const double null_probability = include_nulls ? 0.5 : 0.0;
@@ -77,7 +77,7 @@ Status MakeRandomInt32Array(int64_t length, bool include_nulls, MemoryPool* pool
return Status::OK();
}
Status MakeRandomListArray(const std::shared_ptr<Array>& child_array, int num_lists,
static inline Status MakeRandomListArray(const std::shared_ptr<Array>& child_array, int num_lists,
bool include_nulls, MemoryPool* pool,
std::shared_ptr<Array>* out) {
// Create the null list values
@@ -123,7 +123,7 @@ Status MakeRandomListArray(const std::shared_ptr<Array>& child_array, int num_li
typedef Status MakeRecordBatch(std::shared_ptr<RecordBatch>* out);
Status MakeRandomBooleanArray(const int length, bool include_nulls,
static inline Status MakeRandomBooleanArray(const int length, bool include_nulls,
std::shared_ptr<Array>* out) {
std::vector<uint8_t> values(length);
random_null_bytes(length, 0.5, values.data());
@@ -142,7 +142,7 @@ Status MakeRandomBooleanArray(const int length, bool include_nulls,
return Status::OK();
}
Status MakeBooleanBatchSized(const int length, std::shared_ptr<RecordBatch>* out) {
static inline Status MakeBooleanBatchSized(const int length, std::shared_ptr<RecordBatch>* out) {
// Make the schema
auto f0 = field("f0", boolean());
auto f1 = field("f1", boolean());
@@ -155,11 +155,11 @@ Status MakeBooleanBatchSized(const int length, std::shared_ptr<RecordBatch>* out
return Status::OK();
}
Status MakeBooleanBatch(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeBooleanBatch(std::shared_ptr<RecordBatch>* out) {
return MakeBooleanBatchSized(1000, out);
}
Status MakeIntBatchSized(int length, std::shared_ptr<RecordBatch>* out,
static inline Status MakeIntBatchSized(int length, std::shared_ptr<RecordBatch>* out,
uint32_t seed = 0) {
// Make the schema
auto f0 = field("f0", int32());
@@ -175,7 +175,7 @@ Status MakeIntBatchSized(int length, std::shared_ptr<RecordBatch>* out,
return Status::OK();
}
Status MakeIntRecordBatch(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeIntRecordBatch(std::shared_ptr<RecordBatch>* out) {
return MakeIntBatchSized(10, out);
}
@@ -215,7 +215,7 @@ Status MakeBinaryArrayWithUniqueValues(int64_t length, bool include_nulls,
return builder.Finish(out);
}
Status MakeStringTypesRecordBatch(std::shared_ptr<RecordBatch>* out,
static inline Status MakeStringTypesRecordBatch(std::shared_ptr<RecordBatch>* out,
bool with_nulls = true) {
const int64_t length = 500;
auto string_type = utf8();
@@ -243,11 +243,11 @@ Status MakeStringTypesRecordBatch(std::shared_ptr<RecordBatch>* out,
return Status::OK();
}
Status MakeStringTypesRecordBatchWithNulls(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeStringTypesRecordBatchWithNulls(std::shared_ptr<RecordBatch>* out) {
return MakeStringTypesRecordBatch(out, true);
}
Status MakeNullRecordBatch(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeNullRecordBatch(std::shared_ptr<RecordBatch>* out) {
const int64_t length = 500;
auto f0 = field("f0", null());
auto schema = ::arrow::schema({f0});
@@ -256,7 +256,7 @@ Status MakeNullRecordBatch(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeListRecordBatch(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeListRecordBatch(std::shared_ptr<RecordBatch>* out) {
// Make the schema
auto f0 = field("f0", kListInt32);
auto f1 = field("f1", kListListInt32);
@@ -279,7 +279,7 @@ Status MakeListRecordBatch(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeZeroLengthRecordBatch(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeZeroLengthRecordBatch(std::shared_ptr<RecordBatch>* out) {
// Make the schema
auto f0 = field("f0", kListInt32);
auto f1 = field("f1", kListListInt32);
@@ -299,7 +299,7 @@ Status MakeZeroLengthRecordBatch(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeNonNullRecordBatch(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeNonNullRecordBatch(std::shared_ptr<RecordBatch>* out) {
// Make the schema
auto f0 = field("f0", kListInt32);
auto f1 = field("f1", kListListInt32);
@@ -322,7 +322,7 @@ Status MakeNonNullRecordBatch(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeDeeplyNestedList(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeDeeplyNestedList(std::shared_ptr<RecordBatch>* out) {
const int batch_length = 5;
auto type = int32();
@@ -342,7 +342,7 @@ Status MakeDeeplyNestedList(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeStruct(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeStruct(std::shared_ptr<RecordBatch>* out) {
// reuse constructed list columns
std::shared_ptr<RecordBatch> list_batch;
RETURN_NOT_OK(MakeListRecordBatch(&list_batch));
@@ -372,7 +372,7 @@ Status MakeStruct(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeUnion(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeUnion(std::shared_ptr<RecordBatch>* out) {
// Define schema
std::vector<std::shared_ptr<Field>> union_types(
{field("u0", int32()), field("u1", uint8())});
@@ -438,7 +438,7 @@ Status MakeUnion(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeDictionary(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeDictionary(std::shared_ptr<RecordBatch>* out) {
const int64_t length = 6;
std::vector<bool> is_valid = {true, true, false, true, true, true};
@@ -519,7 +519,7 @@ Status MakeDictionary(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeDictionaryFlat(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeDictionaryFlat(std::shared_ptr<RecordBatch>* out) {
const int64_t length = 6;
std::vector<bool> is_valid = {true, true, false, true, true, true};
@@ -557,7 +557,7 @@ Status MakeDictionaryFlat(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeDates(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeDates(std::shared_ptr<RecordBatch>* out) {
std::vector<bool> is_valid = {true, true, true, false, true, true, true};
auto f0 = field("f0", date32());
auto f1 = field("f1", date64());
@@ -577,7 +577,7 @@ Status MakeDates(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeTimestamps(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeTimestamps(std::shared_ptr<RecordBatch>* out) {
std::vector<bool> is_valid = {true, true, true, false, true, true, true};
auto f0 = field("f0", timestamp(TimeUnit::MILLI));
auto f1 = field("f1", timestamp(TimeUnit::NANO, "America/New_York"));
@@ -596,7 +596,7 @@ Status MakeTimestamps(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeTimes(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeTimes(std::shared_ptr<RecordBatch>* out) {
std::vector<bool> is_valid = {true, true, true, false, true, true, true};
auto f0 = field("f0", time32(TimeUnit::MILLI));
auto f1 = field("f1", time64(TimeUnit::NANO));
@@ -631,7 +631,7 @@ void AppendValues(const std::vector<bool>& is_valid, const std::vector<T>& value
}
}
Status MakeFWBinary(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeFWBinary(std::shared_ptr<RecordBatch>* out) {
std::vector<bool> is_valid = {true, true, true, false};
auto f0 = field("f0", fixed_size_binary(4));
auto f1 = field("f1", fixed_size_binary(0));
@@ -655,7 +655,7 @@ Status MakeFWBinary(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeDecimal(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeDecimal(std::shared_ptr<RecordBatch>* out) {
constexpr int kDecimalPrecision = 38;
auto type = decimal(kDecimalPrecision, 4);
auto f0 = field("f0", type);
@@ -684,7 +684,7 @@ Status MakeDecimal(std::shared_ptr<RecordBatch>* out) {
return Status::OK();
}
Status MakeNull(std::shared_ptr<RecordBatch>* out) {
static inline Status MakeNull(std::shared_ptr<RecordBatch>* out) {
auto f0 = field("f0", null());
// Also put a non-null field to make sure we handle the null array buffers properly
+11 -4
View File
@@ -46,7 +46,7 @@ function(ADD_PARQUET_TEST REL_TEST_NAME)
# By default we prefer shared linking with libparquet, as it's faster
# and uses less disk space, but in some cases we need to force static
# linking (see rationale below).
if(ARG_USE_STATIC_LINKING)
if(ARG_USE_STATIC_LINKING OR ARROW_TEST_LINKAGE STREQUAL "static")
add_test_case(${REL_TEST_NAME} STATIC_LINK_LIBS ${PARQUET_STATIC_TEST_LINK_LIBS}
${TEST_ARGUMENTS})
else()
@@ -110,10 +110,12 @@ set(PARQUET_SHARED_TEST_LINK_LIBS
parquet_shared
Thrift::thrift)
set(PARQUET_STATIC_TEST_LINK_LIBS ${PARQUET_MIN_TEST_LIBS}
${ARROW_LIBRARIES_FOR_STATIC_TESTS} parquet_static)
set(PARQUET_STATIC_TEST_LINK_LIBS
${PARQUET_MIN_TEST_LIBS}
parquet_static
${ARROW_LIBRARIES_FOR_STATIC_TESTS})
if(WIN32)
if(WIN32 OR NOT ARROW_BUILD_SHARED)
# The benchmarks depend on some static Thrift symbols
set(PARQUET_BENCHMARK_LINK_OPTION STATIC_LINK_LIBS benchmark::benchmark_main
parquet_static)
@@ -238,6 +240,11 @@ add_arrow_lib(parquet
STATIC_LINK_LIBS
${PARQUET_STATIC_LINK_LIBS})
if(ARROW_BUILD_STATIC AND WIN32)
# ARROW-4848: Static Parquet lib needs to import static symbols on Windows
target_compile_definitions(parquet_static PUBLIC ARROW_STATIC)
endif()
add_dependencies(parquet ${PARQUET_LIBRARIES})
# Thrift requires these definitions for some types that we use
+15 -7
View File
@@ -126,7 +126,12 @@ list(APPEND PLASMA_EXTERNAL_STORE_SOURCES "external_store.cc" "hash_table_store.
# We use static libraries for the plasma_store_server executable so that it can
# be copied around and used in different locations.
add_executable(plasma_store_server ${PLASMA_EXTERNAL_STORE_SOURCES} store.cc)
target_link_libraries(plasma_store_server plasma_static ${PLASMA_STATIC_LINK_LIBS})
if (ARROW_BUILD_STATIC)
target_link_libraries(plasma_store_server plasma_static ${PLASMA_STATIC_LINK_LIBS})
else()
# Fallback to shared libs in the case that static libraries are not build.
target_link_libraries(plasma_store_server plasma_shared ${PLASMA_LINK_LIBS})
endif()
add_dependencies(plasma plasma_store_server)
if(ARROW_RPATH_ORIGIN)
@@ -237,17 +242,20 @@ function(ADD_PLASMA_TEST REL_TEST_NAME)
${ARG_UNPARSED_ARGUMENTS})
endfunction()
add_plasma_test(test/serialization_tests EXTRA_LINK_LIBS plasma_shared
${PLASMA_LINK_LIBS})
if (ARROW_BUILD_SHARED)
set(PLASMA_TEST_LIBS plasma_shared ${PLASMA_LINK_LIBS})
else()
set(PLASMA_TEST_LIBS plasma_static ${PLASMA_STATIC_LINK_LIBS})
endif()
add_plasma_test(test/serialization_tests EXTRA_LINK_LIBS ${PLASMA_TEST_LIBS})
add_plasma_test(test/client_tests
EXTRA_LINK_LIBS
plasma_shared
${PLASMA_LINK_LIBS}
${PLASMA_TEST_LIBS}
EXTRA_DEPENDENCIES
plasma_store_server)
add_plasma_test(test/external_store_tests
EXTRA_LINK_LIBS
plasma_shared
${PLASMA_LINK_LIBS}
${PLASMA_TEST_LIBS}
EXTRA_DEPENDENCIES
plasma_store_server)
+23
View File
@@ -94,6 +94,29 @@ services:
PARQUET_TEST_DATA: /arrow/cpp/submodules/parquet-testing/data
volumes: *ubuntu-volumes
cpp-static-only:
# Usage:
# docker-compose build cpp
# docker-compose run cpp-static-only
image: arrow:cpp
shm_size: 2G
environment:
ARROW_BUILD_SHARED: "OFF"
ARROW_TEST_LINKAGE: "static"
PARQUET_TEST_DATA: /arrow/cpp/submodules/parquet-testing/data
volumes: *ubuntu-volumes
cpp-shared-only:
# Usage:
# docker-compose build cpp
# docker-compose run cpp-static-only
image: arrow:cpp
shm_size: 2G
environment:
ARROW_BUILD_STATIC: "OFF"
PARQUET_TEST_DATA: /arrow/cpp/submodules/parquet-testing/data
volumes: *ubuntu-volumes
cpp-cmake32:
# Usage:
# docker-compose build cpp-cmake32