From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 2EA6E388C03C for ; Thu, 12 Aug 2021 14:31:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2EA6E388C03C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy02.your-server.de ([78.47.166.47]) by dedi548.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1mEBkT-0006lg-QZ; Thu, 12 Aug 2021 16:31:57 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEBkT-000FkR-Nn; Thu, 12 Aug 2021 16:31:57 +0200 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 687462A1610; Thu, 12 Aug 2021 16:31:57 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id aok1-q2oOolS; Thu, 12 Aug 2021 16:31:57 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 070BF2A165B; Thu, 12 Aug 2021 16:31:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3VO9h1jfg5Rx; Thu, 12 Aug 2021 16:31:56 +0200 (CEST) Received: from shuber-nb-linux.eb.localhost (unknown [10.10.171.10]) by mail.embedded-brains.de (Postfix) with ESMTPSA id CCD212A1610; Thu, 12 Aug 2021 16:31:56 +0200 (CEST) Subject: Re: gcc_assert() and inhibit_libc To: =?UTF-8?Q?Martin_Li=c5=a1ka?= , GCC Development References: <7a2725f1-5f72-f0e6-15a4-84ba31e4d527@embedded-brains.de> <5ccb584d-67b1-67f8-c2ad-72ee1421b146@embedded-brains.de> <95100b45-f2e6-58cd-e77c-ba2026660a45@suse.cz> From: Sebastian Huber Message-ID: Date: Thu, 12 Aug 2021 16:31:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <95100b45-f2e6-58cd-e77c-ba2026660a45@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.103.2/26261/Thu Aug 12 10:22:34 2021) X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 14:32:09 -0000 On 12/08/2021 16:29, Martin Li=C5=A1ka wrote: > On 8/12/21 4:12 PM, Sebastian Huber wrote: >> On 12/08/2021 16:08, Martin Li=C5=A1ka wrote: >>> On 7/21/21 2:44 PM, Sebastian Huber wrote: >>>> Hello, >>>> >>>> while testing this patch >>>> >>>> https://www.google.com/search?client=3Dfirefox-b-e&q=3Dgcc+enable_ru= ntime_checking=20 >>>> >>>> >>>> I noticed that __gcov_info_to_gcda() uses abort(). This is due to=20 >>>> (from tsystem.h): >>>> >>>> #ifdef ENABLE_RUNTIME_CHECKING >>>> #define gcc_assert(EXPR) ((void)(!(EXPR) ? abort (), 0 : 0)) >>>> #else >>>> /* Include EXPR, so that unused variable warnings do not occur.=C2=A0= */ >>>> #define gcc_assert(EXPR) ((void)(0 && (EXPR))) >>>> #endif >>>> >>>> In tsystem.h there is this if inhibit_libc is defined: >>>> >>>> #ifndef abort >>>> extern void abort (void) __attribute__ ((__noreturn__)); >>>> #endif >>>> >>>> Who is supposed to define abort here optionally? Can this be defined= =20 >>>> for example by a target configuration header like gcc/config/rtems.h= ? >>>> >>> >>> Apparently, it's a hairy revision: >>> https://gcc.gnu.org/git/gitweb.cgi?p=3Dgcc.git;h=3D7e7de68b8938 >>> >>> What happens now on RTERM where you have inhibit_libc set to true? Do= =20 >>> you end up with an undefined symbol? >> >> No, we have abort() in RTEMS (from Newlib).=C2=A0 The problem is that=20 >> abort() is a very heavy weight function which pulls in the signal and=20 >> file streams support. >=20 > Oh, I see. >=20 >> >> In case of RTEMS, the application and the operating system is=20 >> statically linked into one executable. The more features an=20 >> application uses the bigger will be the executable. The abort()=20 >> function pulls in a lot of stuff since it uses signals and may attempt= =20 >> to close all open streams. It would be nice if the gcc_assert() could=20 >> be customized by the target configuration. For RTEMS we could use the=20 >> Newlib defined __assert_func() from : >> >> # define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__,=20 >> __LINE__, \ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __ASSERT_FUNC, #__e)) >> >> >> void __assert_func (const char *, int, const char *, const char *) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 _ATTRIBUTE ((__noretu= rn__)); >> >=20 > Then what about adding a condition to gcc/tsystem.h where where you=20 > would define > a different gcc_assert based on rtems target? This would be suitable for me, however, I am not sure if you want such a=20 customization feature just for a niche operating system. --=20 embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M=C3=BCnchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch=C3=A4ftsf=C3=BChrer: Peter Rasmussen, Thomas= D=C3=B6rfler Unsere Datenschutzerkl=C3=A4rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/