You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2016/03/10 22:44:13 UTC
svn commit: r1734460 - in /qpid/trunk/qpid/cpp/src: CMakeLists.txt check-abi
cppabi.cpp expand_types.cpp
Author: astitcher
Date: Thu Mar 10 21:44:13 2016
New Revision: 1734460
URL: http://svn.apache.org/viewvc?rev=1734460&view=rev
Log:
QPID-7137: Fix symbol export check to allow for new libstdc++ ABI
Added:
qpid/trunk/qpid/cpp/src/cppabi.cpp
qpid/trunk/qpid/cpp/src/expand_types.cpp
Modified:
qpid/trunk/qpid/cpp/src/CMakeLists.txt
qpid/trunk/qpid/cpp/src/check-abi
Modified: qpid/trunk/qpid/cpp/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/CMakeLists.txt?rev=1734460&r1=1734459&r2=1734460&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/CMakeLists.txt (original)
+++ qpid/trunk/qpid/cpp/src/CMakeLists.txt Thu Mar 10 21:44:13 2016
@@ -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 D
#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.
Modified: qpid/trunk/qpid/cpp/src/check-abi
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/check-abi?rev=1734460&r1=1734459&r2=1734460&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/check-abi (original)
+++ qpid/trunk/qpid/cpp/src/check-abi Thu Mar 10 21:44:13 2016
@@ -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
Added: qpid/trunk/qpid/cpp/src/cppabi.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/cppabi.cpp?rev=1734460&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/cppabi.cpp (added)
+++ qpid/trunk/qpid/cpp/src/cppabi.cpp Thu Mar 10 21:44:13 2016
@@ -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
+}
Added: qpid/trunk/qpid/cpp/src/expand_types.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/expand_types.cpp?rev=1734460&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/expand_types.cpp (added)
+++ qpid/trunk/qpid/cpp/src/expand_types.cpp Thu Mar 10 21:44:13 2016
@@ -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);
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org