From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 4BD513839424 for ; Thu, 19 Aug 2021 16:08:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4BD513839424 Received: by mail-pj1-x1030.google.com with SMTP id u13-20020a17090abb0db0290177e1d9b3f7so11706425pjr.1 for ; Thu, 19 Aug 2021 09:08:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=EIwcc7gRenjFW7myx3jk5xwJ5eWYpJzZ6qeHKN52QLE=; b=rvNa0hqgUqErOcQDEbnRVzq8ELortcIab4yoQ4VGj1ud1FoCcJhyhWANQChd76LkAA B7WIb8me5kYoAS/tVDFs6pYyU4cPb4jO0AVqH8dpy5U15T3LNFFc7H4/UTXJhzTr3UyG dxDwTdU8DhtYmCQewmycLEZaKRCVlJMSd3iHfwoYdpGdLtS/gJaBxOw40N3lMp+xQoF3 tY6r5DlosYX4CYoIq+wGGgtksXXN+sqzUkjPYuF+o074zNg51PRyrh2s0o2+v/lhh42r Cmqzwfaf76krSj41Tjy36mbt3Ro00DDPb4TEgm7IHCOxr0kPqzx7Khu5ORJnzz1iRpdR rqiA== X-Gm-Message-State: AOAM531OSZ8YpzX9dKrVWw6IaeuwQrZ16tWj0ONu3VyopiV+6v/f7gIY LhdE9qec3TX8ZorrlBuoNNVGIj9y459Syg== X-Google-Smtp-Source: ABdhPJzoOTULI/qe6/xGmVOXsyD8IE41rVor8wnoy8PvF5leogTlsKiFTjeO109QfymvP8x553z6OA== X-Received: by 2002:a17:90b:3608:: with SMTP id ml8mr16026948pjb.22.1629389291895; Thu, 19 Aug 2021 09:08:11 -0700 (PDT) Received: from [192.168.1.10] (65-130-1-109.slkc.qwest.net. [65.130.1.109]) by smtp.gmail.com with ESMTPSA id e31sm3512265pjk.19.2021.08.19.09.08.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Aug 2021 09:08:11 -0700 (PDT) Subject: Re: [PATCH] Use __builtin_trap() for abort() if inhibit_libc To: Sebastian Huber , gcc-patches@gcc.gnu.org References: <20210817084120.14503-1-sebastian.huber@embedded-brains.de> From: Jeff Law Message-ID: <302a6fe2-e0a7-1755-adec-df5cbddb470f@gmail.com> Date: Thu, 19 Aug 2021 10:08:10 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210817084120.14503-1-sebastian.huber@embedded-brains.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2021 16:08:14 -0000 On 8/17/2021 2:41 AM, Sebastian Huber wrote: > abort() is used in gcc_assert() and gcc_unreachable() which is used by target > libraries such as libgcov.a. This patch changes the abort() definition under > certain conditions. If inhibit_libc is defined and abort is not already > defined, then abort() is defined to __builtin_trap(). > > The inhibit_libc define is usually defined if GCC is built for targets running > in embedded systems which may optionally use a C standard library. If > inhibit_libc is defined, then there may be still a full featured abort() > available. abort() is a heavy weight function which depends on signals and > file streams. For statically linked applications, this means that a dependency > on gcc_assert() pulls in the support for signals and file streams. This could > prevent using gcov to test low end targets for example. Using __builtin_trap() > avoids these dependencies if the target implements a "trap" instruction. The > application or operating system could use a trap handler to react to failed GCC > runtime checks which caused a trap. > > gcc/ > > * tsystem.h (abort): Define abort() if inhibit_libc is defined and it > is not already defined. OK. Jeff