From patchwork Tue Jan 24 09:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 63613 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 206833858439 for ; Tue, 24 Jan 2023 09:01:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id E6CB53858D1E for ; Tue, 24 Jan 2023 09:01:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E6CB53858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.97,242,1669104000"; d="scan'208,223";a="94394590" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 24 Jan 2023 01:01:30 -0800 IronPort-SDR: mikj/hpMJKp26GzSk4WDZguS5th6pG/ZDTi/lWxAg8SjwfIGrsIL5U87DYX4KseuinhSje9dG0 tQ+xB6qS3uESyM8diKfEXFCiO/LF3yqU+Sgpyr2S5y5pxj00it5bkPx/bFadwGU3tNLXgH5nyI VCMHzBCfcVcn+85H4cU7Fwf/UdVebyxehEkN+FOjlvsbcaGt2ss9923nw/JCarv2eW/YXUoSp1 r2E0ZhBTeA4UrgR4HSBS7Y7BR3zcmdIGW2oslswUxsX+LCEOw1I2g3MaRrTJlE0pvvtsNAJWqR DRY= From: Thomas Schwinge To: CC: Tom de Vries Subject: Make 'libgcc/config/nvptx/crt0.c' build '--without-headers' (was: [PING] nvptx: Support global constructors/destructors via 'collect2') In-Reply-To: <87fsdacxi0.fsf@euler.schwinge.homeip.net> References: <878rjqaku5.fsf@dem-tschwing-1.ger.mentorg.com> <87y1rq7wt4.fsf@dem-tschwing-1.ger.mentorg.com> <87fsdacxi0.fsf@euler.schwinge.homeip.net> User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Tue, 24 Jan 2023 10:01:16 +0100 Message-ID: <87edrk1f37.fsf@dem-tschwing-1.ger.mentorg.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2022-12-20T09:03:51+0100, I wrote: > Minor change in the attached > "nvptx: Support global constructors/destructors via 'collect2'": for > 'atexit', add '#include ' to 'libgcc/config/nvptx/crt0.c'. Turns out, it's not that easy. ;-) Pushed to devel/omp/gcc-12 branch commit d90a8a5685c8bd3657892feac01739fe87a457a5 "Make 'libgcc/config/nvptx/crt0.c' build '--without-headers'", see attached. Please consider that one 'fixup'ed into the GCC master branch submission. Grüße Thomas > --- a/libgcc/config/nvptx/crt0.c > +++ b/libgcc/config/nvptx/crt0.c > @@ -19,6 +19,9 @@ > see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > . */ > > +#include > +#include "gbl-ctors.h" > + > int *__exitval_ptr; > > extern void __attribute__((noreturn)) exit (int status); > @@ -47,5 +50,8 @@ __main (int *rval_ptr, int argc, void **argv) > __nvptx_stacks[0] = stack + sizeof stack; > __nvptx_uni[0] = 0; > > + __do_global_ctors (); > + atexit (__do_global_dtors); > + > exit (main (argc, argv)); > } ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From d90a8a5685c8bd3657892feac01739fe87a457a5 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 24 Jan 2023 09:49:34 +0100 Subject: [PATCH] Make 'libgcc/config/nvptx/crt0.c' build '--without-headers' ..., where it currently fails: [...]/libgcc/config/nvptx/crt0.c:22:10: fatal error: stdlib.h: No such file or directory 22 | #include | ^~~~~~~~~~ Fix-up for "nvptx: Support global constructors/destructors via 'collect2'". libgcc/ * config/nvptx/crt0.c [!HAVE_STDLIB_H]: Don't '#include '. (atexit): Prototype. --- libgcc/ChangeLog.omp | 5 +++++ libgcc/config/nvptx/crt0.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libgcc/ChangeLog.omp b/libgcc/ChangeLog.omp index c46f49bf5b7..cf509a70d61 100644 --- a/libgcc/ChangeLog.omp +++ b/libgcc/ChangeLog.omp @@ -1,3 +1,8 @@ +2023-01-24 Thomas Schwinge + + * config/nvptx/crt0.c [!HAVE_STDLIB_H]: Don't '#include '. + (atexit): Prototype. + 2023-01-20 Thomas Schwinge Andrew Stubbs diff --git a/libgcc/config/nvptx/crt0.c b/libgcc/config/nvptx/crt0.c index 860e2bfacad..02648bef84b 100644 --- a/libgcc/config/nvptx/crt0.c +++ b/libgcc/config/nvptx/crt0.c @@ -19,11 +19,16 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ -#include +#include "auto-target.h" + +#ifdef HAVE_STDLIB_H +# include +#endif #include "gbl-ctors.h" int *__exitval_ptr; +extern int atexit (void (*function) (void)); extern void __attribute__((noreturn)) exit (int status); extern int main (int, void **); -- 2.25.1