[Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC

Arnout Vandecappelle arnout at mind.be
Thu Nov 15 14:09:56 UTC 2018



On 15/11/2018 05:01, Alexey Brodkin wrote:
> This is what GCC manual says [1]:
> -------------------------->8----------------------
> --enable-__cxa_atexit
> 
>     Define if you want to use __cxa_atexit, rather than atexit,
>     to register C++ destructors for local statics and global objects.
> 
>     This is essential for fully standards-compliant handling of destructors,
>     but requires __cxa_atexit in libc.
> 
>     This option is currently only available on systems with GNU libc
>     ...
> -------------------------->8----------------------
> 
> Important disadvantages of a simple atexit() are that [2]:
> -------------------------->8----------------------
> 1999 C Standard only requires that the implementation support 32
> registered functions, although most implementations support many more.
> 
> More important it does not deal at all with the ability in most implementations
> to remove DSOs from a running program image by calling dlclose
> prior to program termination.
> -------------------------->8----------------------
> 
> Essentially for initial GCC there's no point in enabling that feature
> as we're not going to build CPP applications wit hit.
                                               ^^^^^^^ with it

 But also, there's no point disabling the feature. So I'd set it to enabled in
both initial and final.

> 
> Also it seems like all libc's we support in Buildroot (Glibc, uClibc and musl)
> support __cxa_at_exit() so enable it unconditionally.

 Also, it seems that gcc's configure will default it to yes and do a
AC_CHECK_FUNC(__cxa_atexit, ...) as well.

 Finally, it looks like the handling of this option hasn't changed at all since
4.8, so we're safe in that aspect as well.

 So, with the --enable in the common options:

  Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout at mind.be>

 Regards,
 Arnout

> 
> [1] https://gcc.gnu.org/install/configure.html
> [2] https://itanium-cxx-abi.github.io/cxx-abi/abi.html#dso-dtor-motivation
> 
> Signed-off-by: Alexey Brodkin <abrodkin at synopsys.com>
> Cc: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
> Cc: Mark Corbin <mark.corbin at embecosm.com>
> Cc: Romain Naour <romain.naour at gmail.com>
> Cc: Peter Korsgaard <peter at korsgaard.com>
> Cc: Bernd Kuhls <bernd.kuhls at t-online.de>
> Cc: Claudiu Zissulescu <claziss at synopsys.com>
> Cc: Cupertino Miranda <cmiranda at synopsys.com>
> Cc: Vineet Gupta <vgupta at synopsys.com>
> ---
>  package/gcc/gcc-initial/gcc-initial.mk | 1 +
>  package/gcc/gcc.mk                     | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/package/gcc/gcc-initial/gcc-initial.mk b/package/gcc/gcc-initial/gcc-initial.mk
> index d5d925a3d9..745a85607a 100644
> --- a/package/gcc/gcc-initial/gcc-initial.mk
> +++ b/package/gcc/gcc-initial/gcc-initial.mk
> @@ -40,6 +40,7 @@ HOST_GCC_INITIAL_CONF_OPTS = \
>  	--with-newlib \
>  	--disable-largefile \
>  	--disable-nls \
> +	--disable-__cxa_atexit \
>  	$(call qstrip,$(BR2_EXTRA_GCC_CONFIG_OPTIONS))
>  
>  HOST_GCC_INITIAL_CONF_ENV = \
> diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk
> index e47435677e..5901624ea5 100644
> --- a/package/gcc/gcc.mk
> +++ b/package/gcc/gcc.mk
> @@ -87,7 +87,7 @@ HOST_GCC_COMMON_DEPENDENCIES = \
>  HOST_GCC_COMMON_CONF_OPTS = \
>  	--target=$(GNU_TARGET_NAME) \
>  	--with-sysroot=$(STAGING_DIR) \
> -	--disable-__cxa_atexit \
> +	--enable-__cxa_atexit \
>  	--with-gnu-ld \
>  	--disable-libssp \
>  	--disable-multilib \
> 


More information about the buildroot mailing list