From 54de31c6c4e1d96afc69333556e0172d47a9cfea Mon Sep 17 00:00:00 2001 From: Alex Sergeev Date: Wed, 1 May 2019 02:15:18 +0000 Subject: [PATCH 1/3] Limit exporting of std::* symbols --- cpp/src/arrow/symbols.map | 5 ----- cpp/src/parquet/CMakeLists.txt | 4 ++-- cpp/src/plasma/CMakeLists.txt | 10 ++++++++++ cpp/src/plasma/symbols.map | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 cpp/src/plasma/symbols.map diff --git a/cpp/src/arrow/symbols.map b/cpp/src/arrow/symbols.map index 0149f9515d6..a8825250d05 100644 --- a/cpp/src/arrow/symbols.map +++ b/cpp/src/arrow/symbols.map @@ -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 diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index 3615246ef4c..679851020bf 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -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), diff --git a/cpp/src/plasma/CMakeLists.txt b/cpp/src/plasma/CMakeLists.txt index 729fba7e944..fa3b15795ee 100644 --- a/cpp/src/plasma/CMakeLists.txt +++ b/cpp/src/plasma/CMakeLists.txt @@ -80,6 +80,14 @@ 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} @@ -87,6 +95,8 @@ add_arrow_lib(plasma PLASMA_LIBRARIES DEPENDENCIES gen_plasma_fbs + SHARED_LINK_FLAGS + ${PLASMA_SHARED_LINK_FLAGS} SHARED_LINK_LIBS ${PLASMA_LINK_LIBS} STATIC_LINK_LIBS diff --git a/cpp/src/plasma/symbols.map b/cpp/src/plasma/symbols.map new file mode 100644 index 00000000000..49511c6a749 --- /dev/null +++ b/cpp/src/plasma/symbols.map @@ -0,0 +1,32 @@ +# 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_*; + + 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::*; + }; +}; From 21ecb9eb4b16350a916b01701085340d4c60b812 Mon Sep 17 00:00:00 2001 From: Alex Sergeev Date: Wed, 1 May 2019 03:11:56 +0000 Subject: [PATCH 2/3] Add __once_proxy to excluded symbols --- cpp/src/parquet/symbols.map | 1 + cpp/src/plasma/symbols.map | 1 + 2 files changed, 2 insertions(+) diff --git a/cpp/src/parquet/symbols.map b/cpp/src/parquet/symbols.map index e00751e35c3..7e5435a14a0 100644 --- a/cpp/src/parquet/symbols.map +++ b/cpp/src/parquet/symbols.map @@ -21,6 +21,7 @@ local: # devtoolset / static-libstdc++ symbols __cxa_*; + __once_proxy; extern "C++" { # boost diff --git a/cpp/src/plasma/symbols.map b/cpp/src/plasma/symbols.map index 49511c6a749..0b41d1513f0 100644 --- a/cpp/src/plasma/symbols.map +++ b/cpp/src/plasma/symbols.map @@ -21,6 +21,7 @@ local: # devtoolset / static-libstdc++ symbols __cxa_*; + __once_proxy; extern "C++" { # devtoolset or -static-libstdc++ - the Red Hat devtoolset statically From b82e3203689ce7431f74228fff907d5cf75463e8 Mon Sep 17 00:00:00 2001 From: Alex Sergeev Date: Wed, 1 May 2019 04:06:36 +0000 Subject: [PATCH 3/3] Add *std::__once_call* to excluded symbols --- cpp/src/parquet/symbols.map | 1 + cpp/src/plasma/symbols.map | 1 + 2 files changed, 2 insertions(+) diff --git a/cpp/src/parquet/symbols.map b/cpp/src/parquet/symbols.map index 7e5435a14a0..4bf032dd584 100644 --- a/cpp/src/parquet/symbols.map +++ b/cpp/src/parquet/symbols.map @@ -35,5 +35,6 @@ # a system with an older libstdc++ which doesn't include the necessary # c++11 symbols. std::*; + *std::__once_call*; }; }; diff --git a/cpp/src/plasma/symbols.map b/cpp/src/plasma/symbols.map index 0b41d1513f0..32c86daa440 100644 --- a/cpp/src/plasma/symbols.map +++ b/cpp/src/plasma/symbols.map @@ -29,5 +29,6 @@ # a system with an older libstdc++ which doesn't include the necessary # c++11 symbols. std::*; + *std::__once_call*; }; };