Skip to content

Commit

Permalink
ARROW-5130: [C++][Python] Limit exporting of std::* symbols
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Alex Sergeev authored and wesm committed May 2, 2019
1 parent e32c0b3 commit 0289af2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
5 changes: 0 additions & 5 deletions cpp/src/arrow/symbols.map
Expand Up @@ -18,11 +18,6 @@
{
global:
extern "C++" {
# Export pthread_once-related symbols so that two SO files
# (e.g. libarrow.so and libplasma.so) don't use separate copies of
# those symbols.
# See https://github.com/apache/arrow/pull/1953#issuecomment-386057063
std::__once*;
# The leading asterisk is required for symbols such as
# "typeinfo for arrow::SomeClass".
# Unfortunately this will also catch template specializations
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/parquet/CMakeLists.txt
Expand Up @@ -209,8 +209,8 @@ if(NOT APPLE AND NOT MSVC)
# Localize thirdparty symbols using a linker version script. This hides them
# from the client application. The OS X linker does not support the
# version-script option.
set(SHARED_LINK_FLAGS
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/parquet/symbols.map")
set(PARQUET_SHARED_LINK_FLAGS
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/symbols.map")
endif()

# Because of PARQUET-1420 (Thrift-generated symbols not exported in DLL),
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/parquet/symbols.map
Expand Up @@ -21,6 +21,7 @@
local:
# devtoolset / static-libstdc++ symbols
__cxa_*;
__once_proxy;

extern "C++" {
# boost
Expand All @@ -34,5 +35,6 @@
# a system with an older libstdc++ which doesn't include the necessary
# c++11 symbols.
std::*;
*std::__once_call*;
};
};
10 changes: 10 additions & 0 deletions cpp/src/plasma/CMakeLists.txt
Expand Up @@ -80,13 +80,23 @@ if(ARROW_CUDA)
add_definitions(-DPLASMA_CUDA)
endif()

if(NOT APPLE AND NOT MSVC)
# Localize thirdparty symbols using a linker version script. This hides them
# from the client application. The OS X linker does not support the
# version-script option.
set(PLASMA_SHARED_LINK_FLAGS
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/symbols.map")
endif()

add_arrow_lib(plasma
SOURCES
${PLASMA_SRCS}
OUTPUTS
PLASMA_LIBRARIES
DEPENDENCIES
gen_plasma_fbs
SHARED_LINK_FLAGS
${PLASMA_SHARED_LINK_FLAGS}
SHARED_LINK_LIBS
${PLASMA_LINK_LIBS}
STATIC_LINK_LIBS
Expand Down
34 changes: 34 additions & 0 deletions cpp/src/plasma/symbols.map
@@ -0,0 +1,34 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

{
# Symbols marked as 'local' are not exported by the DSO and thus may not
# be used by client applications.
local:
# devtoolset / static-libstdc++ symbols
__cxa_*;
__once_proxy;

extern "C++" {
# devtoolset or -static-libstdc++ - the Red Hat devtoolset statically
# links c++11 symbols into binaries so that the result may be executed on
# a system with an older libstdc++ which doesn't include the necessary
# c++11 symbols.
std::*;
*std::__once_call*;
};
};

0 comments on commit 0289af2

Please sign in to comment.