qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r1518408 - in /qpid/trunk/qpid/cpp/src: CMakeLists.txt check-abi
Date Wed, 28 Aug 2013 22:37:40 GMT
Author: astitcher
Date: Wed Aug 28 22:37:39 2013
New Revision: 1518408

URL: http://svn.apache.org/r1518408
Log:
QPID-5079: Deal better with compiling on 32 bit architectures
- The API check now varies the expansion it uses for uint64_t/int64_t/size_t
  by getting the compiler to tell it the actual type.

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=1518408&r1=1518407&r2=1518408&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/CMakeLists.txt (original)
+++ qpid/trunk/qpid/cpp/src/CMakeLists.txt Wed Aug 28 22:37:39 2013
@@ -26,6 +26,16 @@ 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)
@@ -148,7 +158,7 @@ ENDMACRO (add_msvc_version)
 # 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)
-    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)
+    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)
 ENDMACRO (add_api_test libname)
 

Modified: qpid/trunk/qpid/cpp/src/check-abi
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/check-abi?rev=1518408&r1=1518407&r2=1518408&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/check-abi (original)
+++ qpid/trunk/qpid/cpp/src/check-abi Wed Aug 28 22:37:39 2013
@@ -1,5 +1,35 @@
 #! /bin/bash
 
+# 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)
@@ -8,25 +38,28 @@ syms_extra=$(mktemp)
 
 trap 'rm $syms_desired $syms_library $syms_missing $syms_extra' EXIT
 
+CXX=$1
+export CXX
+
 # Extract exported symbols from library
-nm -DC --defined-only -f s $1 | cut -f1 -d'|' -s | sort -u > $syms_library
+nm -DC --defined-only -f s $2 | cut -f1 -d'|' -s | sort -u > $syms_library
 
 # Process API syms (substitute in some typedefs etc.)
-sed $2 -e '
-    s/uint64_t/unsigned long/
+sed $3 -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/unsigned long/
-    s/int64_t/long/
+    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>
>/
-    /^$/d
-    /^#.*$/d
-' | sort -u > $syms_desired
+    /^\$/d
+    /^#.*\$/d
+" | sort -u > $syms_desired
 
 comm -23 $syms_desired $syms_library > $syms_missing
 comm -13 $syms_desired $syms_library > $syms_extra



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message