Skip to content

Commit 8145374

Browse files
authored
GH-47554: [C++] Fix Meson Parquet symbol visibility issues (#47556)
### Rationale for this change This fixes symbol export visibility issues with the Parquet option enabled ### What changes are included in this PR? Updates to the Meson configuration, and one definition to get symbol exports to work ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: #47554 Authored-by: Will Ayd <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent d2dace9 commit 8145374

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

cpp/src/arrow/meson.build

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,7 @@ arrow_lib = library(
488488
include_directories: arrow_includes,
489489
dependencies: arrow_deps,
490490
install: true,
491-
# TODO: re-enable symbol visibility
492-
#gnu_symbol_visibility: 'inlineshidden',
491+
gnu_symbol_visibility: 'inlineshidden',
493492
cpp_shared_args: ['-DARROW_EXPORTING'],
494493
)
495494

cpp/src/arrow/util/byte_stream_split_internal.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,9 @@ inline void ByteStreamSplitDecodeScalarDynamic(const uint8_t* data, int width,
452452
}
453453

454454
template <int kNumStreams>
455-
void ByteStreamSplitDecodeSimdDispatch(const uint8_t* data, int width, int64_t num_values,
456-
int64_t stride, uint8_t* out);
455+
ARROW_EXPORT void ByteStreamSplitDecodeSimdDispatch(const uint8_t* data, int width,
456+
int64_t num_values, int64_t stride,
457+
uint8_t* out);
457458

458459
extern template ARROW_TEMPLATE_EXPORT void ByteStreamSplitDecodeSimdDispatch<2>(
459460
const uint8_t*, int, int64_t, int64_t, uint8_t*);

cpp/src/arrow/util/visibility.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@
6767
# ifndef ARROW_NO_EXPORT
6868
# define ARROW_NO_EXPORT [[gnu::visibility("hidden")]]
6969
# endif
70+
// The C++ language does not have clear rules for how to export explicit template
71+
// instantiations, and clang/gcc have differing syntax. See
72+
// https://github.com/llvm/llvm-project/issues/29464 and
73+
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0537r0.html
74+
# if defined(__clang__)
75+
# define ARROW_TEMPLATE_EXPORT
76+
# else
77+
# define ARROW_TEMPLATE_EXPORT ARROW_EXPORT
78+
# endif
7079
# else
7180
// Not C++, or not gcc/clang
7281
# ifndef ARROW_EXPORT
@@ -75,10 +84,10 @@
7584
# ifndef ARROW_NO_EXPORT
7685
# define ARROW_NO_EXPORT
7786
# endif
87+
# define ARROW_TEMPLATE_EXPORT
7888
# endif
7989

8090
# define ARROW_FRIEND_EXPORT
81-
# define ARROW_TEMPLATE_EXPORT
8291

8392
// [[gnu::visibility("default")]] even when #included by a non-arrow source
8493
# define ARROW_FORCE_EXPORT [[gnu::visibility("default")]]

cpp/src/parquet/meson.build

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ endif
8989

9090
parquet_deps = [arrow_dep, rapidjson_dep, thrift_dep]
9191

92-
if needs_parquet_encryption or get_option('parquet_require_encryption') == 'auto'
92+
if needs_parquet_encryption or get_option('parquet_require_encryption').auto()
9393
openssl_dep = dependency('openssl', required: needs_parquet_encryption)
9494
else
9595
openssl_dep = disabler()
@@ -120,8 +120,7 @@ parquet_lib = library(
120120
'arrow-parquet',
121121
sources: parquet_srcs,
122122
dependencies: parquet_deps,
123-
# TODO: enable hidden visibility by default
124-
#gnu_symbol_visibility: 'inlineshidden',
123+
gnu_symbol_visibility: 'inlineshidden',
125124
)
126125

127126
parquet_dep = declare_dependency(link_with: parquet_lib)
@@ -269,7 +268,27 @@ if needs_parquet_encryption
269268
}
270269
endif
271270

272-
parquet_test_dep = [parquet_dep, arrow_test_dep, thrift_dep]
271+
if get_option('default_library') != 'static'
272+
parquet_test_support_lib = static_library(
273+
'parquet-test-support',
274+
sources: files('../generated/parquet_types.cpp'),
275+
dependencies: [thrift_dep],
276+
include_directories: include_directories('..'),
277+
)
278+
parquet_test_support_dep = declare_dependency(
279+
link_with: [parquet_test_support_lib],
280+
)
281+
else
282+
parquet_test_support_dep = declare_dependency()
283+
endif
284+
285+
286+
parquet_test_dep = [
287+
parquet_dep,
288+
parquet_test_support_dep,
289+
arrow_test_dep,
290+
thrift_dep,
291+
]
273292

274293
foreach key, val : parquet_tests
275294
test_name = 'parquet-@0@'.format(key)
@@ -301,7 +320,12 @@ parquet_benchmarks = {
301320
'size_stats_benchmark': {'sources': files('arrow/size_stats_benchmark.cc')},
302321
}
303322

304-
parquet_benchmark_dep = [parquet_dep, arrow_benchmark_dep, thrift_dep]
323+
parquet_benchmark_dep = [
324+
parquet_dep,
325+
parquet_test_support_dep,
326+
arrow_benchmark_dep,
327+
thrift_dep,
328+
]
305329

306330
foreach key, val : parquet_benchmarks
307331
benchmark_name = 'parquet-@0@'.format(key)

0 commit comments

Comments
 (0)