diff --git a/cpp/src/arrow/python/CMakeLists.txt b/cpp/src/arrow/python/CMakeLists.txt index a14ea962d77fe..75d9694991e79 100644 --- a/cpp/src/arrow/python/CMakeLists.txt +++ b/cpp/src/arrow/python/CMakeLists.txt @@ -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}" ) diff --git a/python/manylinux1/scripts/check_arrow_visibility.sh b/cpp/src/arrow/python/symbols.map old mode 100755 new mode 100644 similarity index 77% rename from python/manylinux1/scripts/check_arrow_visibility.sh rename to cpp/src/arrow/python/symbols.map index bed357edf664a..137eb714316c4 --- a/python/manylinux1/scripts/check_arrow_visibility.sh +++ b/cpp/src/arrow/python/symbols.map @@ -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 @@ -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: + *; +}; \ No newline at end of file diff --git a/cpp/src/arrow/symbols.map b/cpp/src/arrow/symbols.map index 10f6d7c343114..0f6f072cd1452 100644 --- a/cpp/src/arrow/symbols.map +++ b/cpp/src/arrow/symbols.map @@ -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; + *; +}; \ No newline at end of file diff --git a/cpp/src/arrow/util/thread-pool-test.cc b/cpp/src/arrow/util/thread-pool-test.cc index a70f0164e832c..47859907676d2 100644 --- a/cpp/src/arrow/util/thread-pool-test.cc +++ b/cpp/src/arrow/util/thread-pool-test.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/python/manylinux1/Dockerfile-x86_64 b/python/manylinux1/Dockerfile-x86_64 index 5bd64d1d9681e..82418e0119ee3 100644 --- a/python/manylinux1/Dockerfile-x86_64 +++ b/python/manylinux1/Dockerfile-x86_64 @@ -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 diff --git a/python/manylinux1/scripts/check_arrow_visibility.py b/python/manylinux1/scripts/check_arrow_visibility.py new file mode 100755 index 0000000000000..143ad7c29e39c --- /dev/null +++ b/python/manylinux1/scripts/check_arrow_visibility.py @@ -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)