From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B05C6385734D; Wed, 28 Sep 2022 14:42:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B05C6385734D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664376162; bh=7gqDO4xDycKOEjqNgbkhdVNNQATqCx7NQ4tMcGlItHo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bZ1jF6e6FQkzPUmL2Xr2a1qHHt7rijVV+DSEfVY3WjI0IiDOQKC20EbaQnkCSWI1r rB43IsbqbFUSqtgVBXshEVEqFs09T/yVaaqNltXeZE6tuzNEJLDhvNvDxd/Ix/GvtL ZmRR4GpIkxTf/9GufQMvQ9Vr9hFN9EuUJtjWTsoo= From: "dumoulin.thibaut at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/68606] Reduce or disable the static emergency pool for C++ exceptions Date: Wed, 28 Sep 2022 14:42:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.3 X-Bugzilla-Keywords: patch X-Bugzilla-Severity: enhancement X-Bugzilla-Who: dumoulin.thibaut at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D68606 --- Comment #12 from Thibaut M. --- Thank you for the updated link! The problem with the original code is that it malloc unconditionally at lea= st 2.4ko on the heap. This cannot be avoided when liking with libstdc++. This malloc is done very early, when initializing `.init_array` section (in ResetHandler on an ARM Cortex M for example). As 2.4ko is a lot for some embedded systems, it would be nice to avoid this behavior. Also, even if this code is never used in your project, none of the symbols = in eh_malloc.cc are called; the constructor of the global variable `pool emergency_pool;` calls a non-pure functions, compiler cannot get rid of this function. If you do not use this code in your project, it will cost you, unconditiona= lly, 2.4ko of heap. This is the problem. This patch https://gcc.gnu.org/legacy-ml/gcc-patches/2016-12/msg01158.html seems a nice solution, it allocates a static buffer and if nobody is using = it, it can be stripped by the linker.=