Skip to content

Commit 3b3684b

Browse files
authored
GH-46714: [C++] Use hidden symbol visibility in Meson configuration (#46715)
### Rationale for this change This will eventually make it easier to support Windows through the Meson configuration, while also providing the documented benefits of hidden symbol visibility ### What changes are included in this PR? Meson libraries have been set to use hidden symbol visibility, and corresponding definitions have been updated to use the ARROW_EXPORT macro ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: #46714 Authored-by: Will Ayd <william.ayd@icloud.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 5bc7267 commit 3b3684b

12 files changed

Lines changed: 30 additions & 21 deletions

File tree

cpp/src/arrow/acero/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ arrow_acero_lib = library(
8181
'arrow-acero',
8282
sources: arrow_acero_srcs,
8383
dependencies: [arrow_compute_dep, arrow_dep],
84+
gnu_symbol_visibility: 'hidden',
8485
)
8586

8687
arrow_acero_dep = declare_dependency(link_with: [arrow_acero_lib])

cpp/src/arrow/array/array_base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ class ARROW_EXPORT Array {
265265

266266
private:
267267
ARROW_DISALLOW_COPY_AND_ASSIGN(Array);
268-
269-
ARROW_FRIEND_EXPORT friend void PrintTo(const Array& x, std::ostream* os);
270268
};
271269

270+
ARROW_EXPORT void PrintTo(const Array& x, std::ostream* os);
271+
272272
static inline std::ostream& operator<<(std::ostream& os, const Array& x) {
273273
os << x.ToString();
274274
return os;

cpp/src/arrow/compute/expression.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void PrintTo(const Expression& expr, std::ostream* os) {
219219
}
220220

221221
bool Expression::Equals(const Expression& other) const {
222-
if (Identical(*this, other)) return true;
222+
if (Expression::Identical(*this, other)) return true;
223223

224224
if (impl_ == nullptr || other.impl_ == nullptr) return false;
225225

@@ -260,7 +260,9 @@ bool Expression::Equals(const Expression& other) const {
260260
return false;
261261
}
262262

263-
bool Identical(const Expression& l, const Expression& r) { return l.impl_ == r.impl_; }
263+
bool Expression::Identical(const Expression& l, const Expression& r) {
264+
return l.impl_ == r.impl_;
265+
}
264266

265267
size_t Expression::hash() const {
266268
if (auto lit = literal()) {
@@ -1452,7 +1454,7 @@ Result<Expression> SimplifyWithGuarantee(Expression expr,
14521454
return inequality->Simplify(std::move(expr));
14531455
}));
14541456

1455-
if (Identical(simplified, expr)) continue;
1457+
if (Expression::Identical(simplified, expr)) continue;
14561458

14571459
expr = std::move(simplified);
14581460
RETURN_NOT_OK(CanonicalizeAndFoldConstants());
@@ -1463,7 +1465,7 @@ Result<Expression> SimplifyWithGuarantee(Expression expr,
14631465
auto simplified,
14641466
SimplifyIsValidGuarantee(std::move(expr), *CallNotNull(guarantee)));
14651467

1466-
if (Identical(simplified, expr)) continue;
1468+
if (Expression::Identical(simplified, expr)) continue;
14671469

14681470
expr = std::move(simplified);
14691471
RETURN_NOT_OK(CanonicalizeAndFoldConstants());

cpp/src/arrow/compute/expression.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ class ARROW_EXPORT Expression {
132132
explicit Expression(Datum literal);
133133
explicit Expression(Parameter parameter);
134134

135+
static bool Identical(const Expression& l, const Expression& r);
136+
135137
private:
136138
using Impl = std::variant<Datum, Parameter, Call>;
137139
std::shared_ptr<Impl> impl_;
138-
139-
ARROW_FRIEND_EXPORT friend bool Identical(const Expression& l, const Expression& r);
140140
};
141141

142142
inline bool operator==(const Expression& l, const Expression& r) { return l.Equals(r); }

cpp/src/arrow/compute/expression_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ TEST(Expression, ExecuteDictionaryTransparent) {
990990
void ExpectIdenticalIfUnchanged(Expression modified, Expression original) {
991991
if (modified == original) {
992992
// no change -> must be identical
993-
EXPECT_TRUE(Identical(modified, original)) << " " << original.ToString();
993+
EXPECT_TRUE(Expression::Identical(modified, original)) << " " << original.ToString();
994994
}
995995
}
996996

cpp/src/arrow/compute/kernels/ree_util_internal.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "arrow/array/data.h"
2828
#include "arrow/compute/exec.h"
2929
#include "arrow/compute/kernel.h"
30+
#include "arrow/compute/visibility.h"
3031
#include "arrow/result.h"
3132
#include "arrow/status.h"
3233
#include "arrow/type_traits.h"
@@ -346,7 +347,7 @@ Result<std::shared_ptr<ArrayData>> PreallocateRunEndsArray(
346347
/// \param has_validity_buffer a validity buffer must be allocated
347348
/// \param length the length of the values array
348349
/// \param data_buffer_size the size of the data buffer for string and binary types
349-
Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
350+
ARROW_COMPUTE_EXPORT Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
350351
const std::shared_ptr<DataType>& value_type, bool has_validity_buffer, int64_t length,
351352
MemoryPool* pool, int64_t data_buffer_size);
352353

@@ -362,7 +363,7 @@ Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
362363
/// data.child_data[1].buffer[0] != NULLPTR
363364
///
364365
/// \param data_buffer_size the size of the data buffer for string and binary types
365-
Result<std::shared_ptr<ArrayData>> PreallocateREEArray(
366+
ARROW_COMPUTE_EXPORT Result<std::shared_ptr<ArrayData>> PreallocateREEArray(
366367
std::shared_ptr<RunEndEncodedType> ree_type, bool has_validity_buffer,
367368
int64_t logical_length, int64_t physical_length, MemoryPool* pool,
368369
int64_t data_buffer_size);
@@ -377,7 +378,7 @@ Result<std::shared_ptr<ArrayData>> PreallocateREEArray(
377378
/// - run_ends fits in the run-end type without overflow
378379
void WriteSingleRunEnd(ArrayData* run_ends_data, int64_t run_end);
379380

380-
Result<std::shared_ptr<ArrayData>> MakeNullREEArray(
381+
ARROW_COMPUTE_EXPORT Result<std::shared_ptr<ArrayData>> MakeNullREEArray(
381382
const std::shared_ptr<DataType>& run_end_type, int64_t logical_length,
382383
MemoryPool* pool);
383384

cpp/src/arrow/compute/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Result<Expression> ModifyExpression(Expression expr, const PreVisit& pre,
149149
ARROW_ASSIGN_OR_RAISE(auto modified_argument,
150150
ModifyExpression(call->arguments[i], pre, post_call));
151151

152-
if (Identical(modified_argument, call->arguments[i])) {
152+
if (Expression::Identical(modified_argument, call->arguments[i])) {
153153
continue;
154154
}
155155

cpp/src/arrow/filesystem/azurefs_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ enum class HierarchicalNamespaceSupport {
7070
/// account.
7171
/// \return kEnabled/kDisabled/kContainerNotFound (kUnknown is never
7272
/// returned).
73-
Result<HierarchicalNamespaceSupport> CheckIfHierarchicalNamespaceIsEnabled(
73+
ARROW_EXPORT Result<HierarchicalNamespaceSupport> CheckIfHierarchicalNamespaceIsEnabled(
7474
const Azure::Storage::Files::DataLake::DataLakeFileSystemClient& adlfs_client,
7575
const arrow::fs::AzureOptions& options);
7676

cpp/src/arrow/filesystem/mockfs.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ class MockFSInputStream : public io::BufferReader {
255255

256256
} // namespace
257257

258-
std::ostream& operator<<(std::ostream& os, const MockDirInfo& di) {
258+
ARROW_EXPORT std::ostream& operator<<(std::ostream& os, const MockDirInfo& di) {
259259
return os << "'" << di.full_path << "' [mtime=" << di.mtime.time_since_epoch().count()
260260
<< "]";
261261
}
262262

263-
std::ostream& operator<<(std::ostream& os, const MockFileInfo& di) {
263+
ARROW_EXPORT std::ostream& operator<<(std::ostream& os, const MockFileInfo& di) {
264264
return os << "'" << di.full_path << "' [mtime=" << di.mtime.time_since_epoch().count()
265265
<< ", size=" << di.data.length() << "]";
266266
}

cpp/src/arrow/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ arrow_lib = library(
422422
include_directories: arrow_includes,
423423
dependencies: arrow_deps,
424424
install: true,
425+
gnu_symbol_visibility: 'hidden',
426+
cpp_shared_args: ['-DARROW_EXPORTING'],
425427
)
426428

427429
arrow_dep = declare_dependency(
@@ -484,6 +486,7 @@ if needs_compute
484486
sources: arrow_compute_lib_sources,
485487
dependencies: arrow_dep,
486488
install: true,
489+
cpp_shared_args: ['-DARROW_COMPUTE_EXPORTING'],
487490
)
488491
arrow_compute_dep = declare_dependency(
489492
link_with: arrow_compute_lib,

0 commit comments

Comments
 (0)