summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2016-03-10 21:44:13 +0000
committerAndrew Stitcher <astitcher@apache.org>2016-03-10 21:44:13 +0000
commitb7bf0badc4a3417e4bea00885c8f676eaba04194 (patch)
tree292467e253756f107d10775e412bad61ead0b14f
parent071665cf704ed3ed8b89b520bdd0c73394594e56 (diff)
downloadqpid-python-b7bf0badc4a3417e4bea00885c8f676eaba04194.tar.gz
QPID-7137: Fix symbol export check to allow for new libstdc++ ABI
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1734460 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/CMakeLists.txt40
-rwxr-xr-xqpid/cpp/src/check-abi49
-rw-r--r--qpid/cpp/src/cppabi.cpp32
-rw-r--r--qpid/cpp/src/expand_types.cpp58
4 files changed, 116 insertions, 63 deletions
diff --git a/qpid/cpp/src/CMakeLists.txt b/qpid/cpp/src/CMakeLists.txt
index 41dbb76b16..45f5987a6c 100644
--- a/qpid/cpp/src/CMakeLists.txt
+++ b/qpid/cpp/src/CMakeLists.txt
@@ -26,16 +26,6 @@ foreach (r ${REQUIRE})
message(STATUS "Forcing ${r} to ${${r}_force}")
endforeach(r)
-# Capture specified C++ compiler (if any)
-if (NOT ENV_CXX)
- if (NOT "$ENV{CXX}" STREQUAL "")
- set(CXX $ENV{CXX})
- else(NOT "$ENV{CXX}" STREQUAL "")
- set(CXX ${CMAKE_CXX_COMPILER})
- endif(NOT "$ENV{CXX}" STREQUAL "")
- set(ENV_CXX ${CXX} CACHE INTERNAL "C++ compiler specified in cmake environment")
-endif (NOT ENV_CXX)
-
include(CheckFunctionExists)
include(CheckIncludeFileCXX)
include(CheckIncludeFiles)
@@ -64,12 +54,20 @@ find_package_handle_standard_args(SASL DEFAULT_MSG FOUND_SASL_LIB FOUND_SASL_H)
#set (CMAKE_VERBOSE_MAKEFILE ON) # for debugging
-# Add a test to check the exported library API against expected API symbols
-MACRO (add_api_test libname)
- if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND BUILD_TESTING)
- add_test(api_check_${libname} ${CMAKE_CURRENT_SOURCE_DIR}/check-abi "${ENV_CXX}" ${CMAKE_CURRENT_BINARY_DIR}/lib${libname}.so ${CMAKE_CURRENT_SOURCE_DIR}/lib${libname}-api-symbols.txt)
- endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND BUILD_TESTING)
-ENDMACRO (add_api_test libname)
+if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND BUILD_TESTING)
+ # Executables used in testing the library ABIs
+ add_executable(cppabi cppabi.cpp)
+ add_executable(expand_types expand_types.cpp)
+
+ # Add a test to check the exported library API against expected API symbols
+ MACRO (add_api_test libname)
+ add_test(api_check_${libname} ${CMAKE_CURRENT_SOURCE_DIR}/check-abi ${CMAKE_CURRENT_BINARY_DIR}/lib${libname}.so ${CMAKE_CURRENT_SOURCE_DIR}/lib${libname}-api-symbols.txt)
+ ENDMACRO (add_api_test libname)
+else (NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND BUILD_TESTING)
+ # If the test isn't applicable use a dummy macro
+ MACRO (add_api_test libname)
+ ENDMACRO (add_api_test libname)
+endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND BUILD_TESTING)
# check if we generate source as part of the build
@@ -157,7 +155,15 @@ if (NOT ENABLE_WARNINGS)
set (WARNING_FLAGS "")
endif (NOT ENABLE_WARNINGS)
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS} ${WARNING_FLAGS}")
+if (GCC_VERSION AND NOT GCC_VERSION VERSION_LESS 5.1)
+ option(ENABLE_GLIBCXX_OLD_ABI "Enable old (pre GCC 5.1) C++ ABI" OFF)
+endif ()
+
+if (ENABLE_GLIBCXX_OLD_ABI)
+ set (ABI_DEF "-D_GLIBCXX_USE_CXX11_ABI=0")
+endif (ENABLE_GLIBCXX_OLD_ABI)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ABI_DEF} ${COMPILER_FLAGS} ${WARNING_FLAGS}")
# Expand a bit from the basic Find_Boost; be specific about what's needed.
# Boost.system is sometimes needed; it's handled separately, below.
diff --git a/qpid/cpp/src/check-abi b/qpid/cpp/src/check-abi
index 3e85dab862..498c6bd322 100755
--- a/qpid/cpp/src/check-abi
+++ b/qpid/cpp/src/check-abi
@@ -21,36 +21,6 @@
MKTEMP="mktemp /tmp/tmp.XXXXXXXXXX"
-# Ask the compiler the implementation specific type for a standard typedeffed type
-# (int64_t, size_t etc.). Operates by test compiling and using the demangling ABI call.
-#
-# This works for gcc and clang on Unix.
-full_type_of () {
- prog=$($MKTEMP)
- trap "rm $prog" EXIT
-
- ${CXX:-g++} -x c++ -o $prog - <<END-FILE
-#include <stdint.h>
-#include <stdlib.h>
-#include <cxxabi.h>
-#include <iostream>
-#include <typeinfo>
-
-int main() {
- int status;
- char* printable_type =
- __cxxabiv1::__cxa_demangle(typeid($1).name(), 0, 0, &status);
- if (printable_type) {
- std::cout << printable_type;
- } else {
- std::cout << "$1";
- }
- ::free(printable_type);
-}
-END-FILE
-$prog
-}
-
rc=0
syms_desired=$($MKTEMP)
syms_library=$($MKTEMP)
@@ -59,31 +29,18 @@ syms_extra=$($MKTEMP)
trap 'rm $syms_desired $syms_library $syms_missing $syms_extra' EXIT
-CXX=$1
-export CXX
-
LC_ALL=C
export LC_ALL
# Extract exported symbols from library
-nm -DC --defined-only -f s $2 | cut -f1 -d'|' -s | sort -u > $syms_library
+nm -DC --defined-only -f s $1 | cut -f1 -d'|' -s | sed -e "$(./cppabi)" | sort -u > $syms_library
# Process API syms (substitute in some typedefs etc.)
sed -e "
- s/uint64_t/$(full_type_of uint64_t)/
- s/uint32_t/unsigned int/
- s/uint16_t/unsigned short/
- s/uint8_t/unsigned char/
- s/size_t/$(full_type_of size_t)/
- s/int64_t/$(full_type_of int64_t)/
- s/int32_t/int/
- s/int16_t/short/
- s/int8_t/signed char/
- s/qpid::types::Variant::Map/std::map<std::string, qpid::types::Variant, std::less<std::string>, std::allocator<std::pair<std::string const, qpid::types::Variant> > >/
- s/qpid::types::Variant::List/std::list<qpid::types::Variant, std::allocator<qpid::types::Variant> >/
+ $(./expand_types)
/^\$/d
/^#.*\$/d
-" $3 | sort -u > $syms_desired
+" $2 | sort -u > $syms_desired
comm -23 $syms_desired $syms_library > $syms_missing
comm -13 $syms_desired $syms_library > $syms_extra
diff --git a/qpid/cpp/src/cppabi.cpp b/qpid/cpp/src/cppabi.cpp
new file mode 100644
index 0000000000..5767d6084c
--- /dev/null
+++ b/qpid/cpp/src/cppabi.cpp
@@ -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.
+ *
+ */
+#include <cxxabi.h>
+
+#include <iostream>
+
+int main() {
+#if _GLIBCXX_USE_CXX11_ABI
+ std::cout << "s/\\[abi:cxx11\\]//";
+ return 0;
+#else
+ return 1;
+#endif
+}
diff --git a/qpid/cpp/src/expand_types.cpp b/qpid/cpp/src/expand_types.cpp
new file mode 100644
index 0000000000..9e8cd1ee69
--- /dev/null
+++ b/qpid/cpp/src/expand_types.cpp
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include <stdint.h>
+#include <stdlib.h>
+#include <cxxabi.h>
+#include <iostream>
+#include <string>
+#include <typeinfo>
+
+#include "qpid/types/Variant.h"
+
+void print_type(const char* type, const char* mangled_type)
+{
+ int status;
+ char* demangled_type =
+ abi::__cxa_demangle(mangled_type, 0, 0, &status);
+ if (demangled_type) {
+ std::cout << "s/" << type << "/" << demangled_type << "/g\n";
+ }
+ ::free(demangled_type);
+}
+
+#define mangle_name(x) typeid(x).name()
+
+#define print_subst(x) print_type(#x, mangle_name(x))
+
+int main() {
+ print_subst(uint64_t);
+ print_subst(uint32_t);
+ print_subst(uint16_t);
+ print_subst(uint8_t);
+ print_subst(size_t);
+ print_subst(int64_t);
+ print_subst(int32_t);
+ print_subst(int16_t);
+ print_subst(int8_t);
+ print_subst(std::string);
+ print_subst(qpid::types::Variant::Map);
+ print_subst(qpid::types::Variant::List);
+}