* [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC
@ 2018-11-15 4:01 Alexey Brodkin
2018-11-15 10:17 ` Nicolas Cavallari
2018-11-15 14:09 ` Arnout Vandecappelle
0 siblings, 2 replies; 6+ messages in thread
From: Alexey Brodkin @ 2018-11-15 4:01 UTC (permalink / raw)
To: buildroot
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.
Also it seems like all libc's we support in Buildroot (Glibc, uClibc and musl)
support __cxa_at_exit() so enable it unconditionally.
[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@synopsys.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Mark Corbin <mark.corbin@embecosm.com>
Cc: Romain Naour <romain.naour@gmail.com>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Bernd Kuhls <bernd.kuhls@t-online.de>
Cc: Claudiu Zissulescu <claziss@synopsys.com>
Cc: Cupertino Miranda <cmiranda@synopsys.com>
Cc: Vineet Gupta <vgupta@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 \
--
2.16.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC
2018-11-15 4:01 [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC Alexey Brodkin
@ 2018-11-15 10:17 ` Nicolas Cavallari
2018-11-15 10:22 ` Alexey Brodkin
2018-11-15 14:09 ` Arnout Vandecappelle
1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Cavallari @ 2018-11-15 10:17 UTC (permalink / raw)
To: buildroot
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.
>
For what is is worth, we enabled cxa_atexit in BR2_EXTRA_GCC_CONFIG_OPTIONS five
years ago, to fix a crash that occurred when catching exceptions and logging
them using a log system that used global variables. But we couldn't remember
the details.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC
2018-11-15 10:17 ` Nicolas Cavallari
@ 2018-11-15 10:22 ` Alexey Brodkin
2018-11-15 10:35 ` Romain Naour
0 siblings, 1 reply; 6+ messages in thread
From: Alexey Brodkin @ 2018-11-15 10:22 UTC (permalink / raw)
To: buildroot
Hi Nicolas,
On Thu, 2018-11-15 at 11:17 +0100, Nicolas Cavallari wrote:
> 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.
> >
>
> For what is is worth, we enabled cxa_atexit in BR2_EXTRA_GCC_CONFIG_OPTIONS five
> years ago, to fix a crash that occurred when catching exceptions and logging
> them using a log system that used global variables. But we couldn't remember
> the details.
So you've been using BR with cxa_atexit since then, right?
Or you mean it was enabled in upstream BR for some time and then reverted back to disabled state?
-Alexey
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC
2018-11-15 10:22 ` Alexey Brodkin
@ 2018-11-15 10:35 ` Romain Naour
2018-11-15 10:50 ` Alexey Brodkin
0 siblings, 1 reply; 6+ messages in thread
From: Romain Naour @ 2018-11-15 10:35 UTC (permalink / raw)
To: buildroot
Hi Alexey,
Le 15/11/2018 ? 11:22, Alexey Brodkin a ?crit?:
> Hi Nicolas,
>
> On Thu, 2018-11-15 at 11:17 +0100, Nicolas Cavallari wrote:
>> 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.
>>>
>>
>> For what is is worth, we enabled cxa_atexit in BR2_EXTRA_GCC_CONFIG_OPTIONS five
>> years ago, to fix a crash that occurred when catching exceptions and logging
>> them using a log system that used global variables. But we couldn't remember
>> the details.
>
> So you've been using BR with cxa_atexit since then, right?
> Or you mean it was enabled in upstream BR for some time and then reverted back to disabled state?
--disable-__cxa_atexit is present since 2002/2003 in Buildroot, I'm not sure the
reason for disabling atexit is still relevant.
Best regards,
Romain
>
> -Alexey
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC
2018-11-15 10:35 ` Romain Naour
@ 2018-11-15 10:50 ` Alexey Brodkin
0 siblings, 0 replies; 6+ messages in thread
From: Alexey Brodkin @ 2018-11-15 10:50 UTC (permalink / raw)
To: buildroot
Hi Romain,
On Thu, 2018-11-15 at 11:35 +0100, Romain Naour wrote:
> Hi Alexey,
>
> Le 15/11/2018 ? 11:22, Alexey Brodkin a ?crit :
> > Hi Nicolas,
> >
> > On Thu, 2018-11-15 at 11:17 +0100, Nicolas Cavallari wrote:
> > > 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.
> > > >
> > >
> > > For what is is worth, we enabled cxa_atexit in BR2_EXTRA_GCC_CONFIG_OPTIONS five
> > > years ago, to fix a crash that occurred when catching exceptions and logging
> > > them using a log system that used global variables. But we couldn't remember
> > > the details.
> >
> > So you've been using BR with cxa_atexit since then, right?
> > Or you mean it was enabled in upstream BR for some time and then reverted back to disabled state?
>
> --disable-__cxa_atexit is present since 2002/2003 in Buildroot, I'm not sure the
> reason for disabling atexit is still relevant.
For me there was a reason to get cxa_atexit enabled - SEGFAULT in one of Glibc
tests on ARC so I do it it solves something as for whih problems that change might introduce
I have no ideas :)
I did a build test with all libc's for x86 but nothing more serious.
Also if we look around we'll see
1. In OpenEmbedded it is enabled for everything except gcc-cross-initial:
https://github.com/openembedded/openembedded-core/blob/master/meta/recipes-devtools/gcc/gcc-configure-common.inc#L59
https://github.com/openembedded/openembedded-core/blob/master/meta/recipes-devtools/gcc/gcc-cross-initial.inc#L23
2. In Crosstool-NG it is enabled by default:
https://github.com/crosstool-ng/crosstool-ng/blob/master/config/cc/gcc.in#L270
3. In OpenWrt it is disabled only for uClibc, otherwise enabled:
https://github.com/openwrt/openwrt/blob/master/toolchain/gcc/common.mk#L170
So I think it looks promising.
-Alexey
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC
2018-11-15 4:01 [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC Alexey Brodkin
2018-11-15 10:17 ` Nicolas Cavallari
@ 2018-11-15 14:09 ` Arnout Vandecappelle
1 sibling, 0 replies; 6+ messages in thread
From: Arnout Vandecappelle @ 2018-11-15 14:09 UTC (permalink / raw)
To: buildroot
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@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@synopsys.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: Mark Corbin <mark.corbin@embecosm.com>
> Cc: Romain Naour <romain.naour@gmail.com>
> Cc: Peter Korsgaard <peter@korsgaard.com>
> Cc: Bernd Kuhls <bernd.kuhls@t-online.de>
> Cc: Claudiu Zissulescu <claziss@synopsys.com>
> Cc: Cupertino Miranda <cmiranda@synopsys.com>
> Cc: Vineet Gupta <vgupta@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 \
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-11-15 14:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-15 4:01 [Buildroot] [PATCH] gcc: Enable __cxa_atexit for final GCC Alexey Brodkin
2018-11-15 10:17 ` Nicolas Cavallari
2018-11-15 10:22 ` Alexey Brodkin
2018-11-15 10:35 ` Romain Naour
2018-11-15 10:50 ` Alexey Brodkin
2018-11-15 14:09 ` Arnout Vandecappelle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.