Skip to content

Commit 0289af2

Browse files
Alex Sergeevwesm
authored andcommitted
ARROW-5130: [C++][Python] Limit exporting of std::* symbols
This patch addresses the incompatibility of `pyarrow` and `tensorflow` wheels provided by Google. It has been tested with: ```python import pyarrow import tensorflow ``` As well as more complicated examples such as https://github.com/horovod/horovod/blob/master/examples/keras_spark_rossmann.py which uses PyArrow + Petastorm to read the data. Fixes https://issues.apache.org/jira/browse/ARROW-5130 Author: Alex Sergeev <asergeev@uber.com> Closes #4232 from alsrgv/simple_symbols and squashes the following commits: b82e320 <Alex Sergeev> Add *std::__once_call* to excluded symbols 21ecb9e <Alex Sergeev> Add __once_proxy to excluded symbols 54de31c <Alex Sergeev> Limit exporting of std::* symbols
1 parent e32c0b3 commit 0289af2

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

cpp/src/arrow/symbols.map

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
{
1919
global:
2020
extern "C++" {
21-
# Export pthread_once-related symbols so that two SO files
22-
# (e.g. libarrow.so and libplasma.so) don't use separate copies of
23-
# those symbols.
24-
# See https://github.com/apache/arrow/pull/1953#issuecomment-386057063
25-
std::__once*;
2621
# The leading asterisk is required for symbols such as
2722
# "typeinfo for arrow::SomeClass".
2823
# Unfortunately this will also catch template specializations

cpp/src/parquet/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ if(NOT APPLE AND NOT MSVC)
209209
# Localize thirdparty symbols using a linker version script. This hides them
210210
# from the client application. The OS X linker does not support the
211211
# version-script option.
212-
set(SHARED_LINK_FLAGS
213-
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/parquet/symbols.map")
212+
set(PARQUET_SHARED_LINK_FLAGS
213+
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/symbols.map")
214214
endif()
215215

216216
# Because of PARQUET-1420 (Thrift-generated symbols not exported in DLL),

cpp/src/parquet/symbols.map

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
local:
2222
# devtoolset / static-libstdc++ symbols
2323
__cxa_*;
24+
__once_proxy;
2425

2526
extern "C++" {
2627
# boost
@@ -34,5 +35,6 @@
3435
# a system with an older libstdc++ which doesn't include the necessary
3536
# c++11 symbols.
3637
std::*;
38+
*std::__once_call*;
3739
};
3840
};

cpp/src/plasma/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,23 @@ if(ARROW_CUDA)
8080
add_definitions(-DPLASMA_CUDA)
8181
endif()
8282

83+
if(NOT APPLE AND NOT MSVC)
84+
# Localize thirdparty symbols using a linker version script. This hides them
85+
# from the client application. The OS X linker does not support the
86+
# version-script option.
87+
set(PLASMA_SHARED_LINK_FLAGS
88+
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/symbols.map")
89+
endif()
90+
8391
add_arrow_lib(plasma
8492
SOURCES
8593
${PLASMA_SRCS}
8694
OUTPUTS
8795
PLASMA_LIBRARIES
8896
DEPENDENCIES
8997
gen_plasma_fbs
98+
SHARED_LINK_FLAGS
99+
${PLASMA_SHARED_LINK_FLAGS}
90100
SHARED_LINK_LIBS
91101
${PLASMA_LINK_LIBS}
92102
STATIC_LINK_LIBS

cpp/src/plasma/symbols.map

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
{
19+
# Symbols marked as 'local' are not exported by the DSO and thus may not
20+
# be used by client applications.
21+
local:
22+
# devtoolset / static-libstdc++ symbols
23+
__cxa_*;
24+
__once_proxy;
25+
26+
extern "C++" {
27+
# devtoolset or -static-libstdc++ - the Red Hat devtoolset statically
28+
# links c++11 symbols into binaries so that the result may be executed on
29+
# a system with an older libstdc++ which doesn't include the necessary
30+
# c++11 symbols.
31+
std::*;
32+
*std::__once_call*;
33+
};
34+
};

0 commit comments

Comments
 (0)