Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-2657: [C++] Undo export pthread_once related symbols. #2096

Closed
wants to merge 12 commits into from
11 changes: 9 additions & 2 deletions cpp/src/arrow/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ if (MSVC)
)
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(ARROW_PYTHON_SHARED_LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/symbols.map")
endif()

ADD_ARROW_LIB(arrow_python
SOURCES ${ARROW_PYTHON_SRCS}
SHARED_LINK_FLAGS ""
SHARED_LINK_LIBS ${ARROW_PYTHON_SHARED_LINK_LIBS}
SHARED_LINK_FLAGS ${ARROW_PYTHON_SHARED_LINK_FLAGS}
SHARED_PRIVATE_LINK_LIBS ${ARROW_PYTHON_SHARED_LINK_LIBS}
STATIC_LINK_LIBS "${PYTHON_OTHER_LIBS}"
)

Expand Down
21 changes: 10 additions & 11 deletions ...ylinux1/scripts/check_arrow_visibility.sh → cpp/src/arrow/python/symbols.map
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash -ex
# 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
Expand All @@ -16,14 +15,14 @@
# specific language governing permissions and limitations
# under the License.

nm -D -C /arrow-dist/lib64/libarrow.so > nm_arrow.log
grep ' T ' nm_arrow.log | grep -v arrow > visible_symbols.log
{
global:
extern "C++" {
*arrow::*;
};
arrow_*;
pyarrow_*;

if [[ `cat visible_symbols.log | wc -l` -eq 2 ]]
then
exit 0
fi

cat visible_symbols.log

exit 1
local:
*;
};
68 changes: 8 additions & 60 deletions cpp/src/arrow/symbols.map
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,12 @@
# under the License.

{
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*;
};
global:
extern "C++" {
*arrow::*;
};

# 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;

# Static libraries that are linked in e.g. the manylinux1 build
# Brotli compression library
Brotli*;
# zlib
adler32*;
crc32*;
deflate*;
inflate*;
get_crc_table;
zcalloc;
zcfree;
zError;
zlibCompileFlags;
zlibVersion;
_tr_*;
# lz4
LZ4_*;
# zstandard
ZSTD_*;
ZSTDv*;
HUF_*;
HUFv*;
FSE_*;
FSEv*;
ZBUFFv*;
ERR_getErrorString;
# jemalloc
je_arrow_*;
# ORC destructors
_ZThn8_N3orc*;

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::*;

# Statically linked C++ dependencies
boost::*;
google::*;
orc::*;
snappy::*;
};
};
local:
__once_proxy;
*;
};
1 change: 1 addition & 0 deletions cpp/src/arrow/util/thread-pool-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <algorithm>
#include <chrono>
#include <functional>
#include <memory>
#include <thread>
#include <vector>

Expand Down
4 changes: 2 additions & 2 deletions python/manylinux1/Dockerfile-x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ WORKDIR /arrow/cpp/build-plain
RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/arrow-dist -DARROW_BUILD_TESTS=OFF -DARROW_BUILD_SHARED=ON -DARROW_BOOST_USE_SHARED=ON -DARROW_JEMALLOC=ON -DARROW_RPATH_ORIGIN=ON -DARROW_JEMALLOC_USE_SHARED=OFF -DBoost_NAMESPACE=arrow_boost -DBOOST_ROOT=/arrow_boost_dist ..
RUN ninja install

ADD scripts/check_arrow_visibility.sh /
RUN /check_arrow_visibility.sh
ADD scripts/check_arrow_visibility.py /
RUN /check_arrow_visibility.py

WORKDIR /
RUN git clone https://github.com/apache/parquet-cpp.git
Expand Down
35 changes: 35 additions & 0 deletions python/manylinux1/scripts/check_arrow_visibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python

# 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.

import subprocess

exceptions = []

process = subprocess.Popen(['nm', '-D', '-C', '/arrow-dist/lib64/libarrow.so'],
stdout=subprocess.PIPE)
stdout_data, _ = process.communicate()
stdout_data = stdout_data.decode('ascii')
lines = stdout_data.split('\n')
lines = [line for line in lines if ' T ' in line]
lines = [line for line in lines if 'arrow' not in line]
symbols = [line.split(' ')[2] for line in lines]
symbols = [symbol for symbol in symbols if symbol not in exceptions]

if len(symbols) > 0:
raise Exception(symbols)