Re: [DynInst_API:] [PATCH 1/1] cmake: make the c++11 abi configurable, default unset


Date: Thu, 28 Apr 2016 13:48:58 -0700
From: Josh Stone <jistone@xxxxxxxxxx>
Subject: Re: [DynInst_API:] [PATCH 1/1] cmake: make the c++11 abi configurable, default unset
On 04/28/2016 01:42 PM, Josh Stone wrote:
> GCC 5 made several ABI changes for C++11 support, but they also kept
> support for the older ABI.  The macro _GLIBCXX_USE_CXX11_ABI can force
> which mode you compile against.

Note also, this ABI toggling occurs regardless of using a -std=c++11 or
later mode.  A program using an older standard can still link fine to a
C++11 library, as long everything uses the same _GLIBCXX_USE_CXX11_ABI.
(Or you could avoid ABI-affected types, but this includes std::string.)

> Fedora 22 shipped with GCC 5 configured to use the old ABI by default,
> as if -D_GLIBCXX_USE_CXX11_ABI=0, and Fedora 23 moved to the new ABI.
> In either case you could make a different choice with that macro, but
> any APIs you expose will be ABI-tagged, and programs you link with must
> use the same choice.  For working in a Linux distribution, it's usually
> best to leave it at the default.
> 
> Commit dbd452640a57 forced the old ABI unconditionally.  This patch adds
> a cmake USE_CXX11_ABI setting, left blank to use the compiler default,
> or set to a cmake boolean to force the new ABI on or off.
> 
> References:
>   http://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/
>   http://developers.redhat.com/blog/2015/02/10/gcc-5-in-fedora/
> ---
>  cmake/shared.cmake | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/cmake/shared.cmake b/cmake/shared.cmake
> index 88b0b6aa86fe..699c5b489796 100644
> --- a/cmake/shared.cmake
> +++ b/cmake/shared.cmake
> @@ -112,7 +112,14 @@ if(PLATFORM MATCHES nt OR PLATFORM MATCHES windows)
>    endif()
>  endif()
>  
> -add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
> +set (USE_CXX11_ABI "" CACHE STRING "Override the default GNU C++11 ABI setting")
> +if (NOT ("${USE_CXX11_ABI}" STREQUAL ""))
> +  if (${USE_CXX11_ABI})
> +    add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
> +  else()
> +    add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
> +  endif()
> +endif()
>  
>  #
>  # DyninstConfig.cmake
> 

[← Prev in Thread] Current Thread [Next in Thread→]