From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 8B6603858291 for ; Fri, 4 Nov 2022 09:07:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B6603858291 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.96,137,1665475200"; d="scan'208,223";a="86068869" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 04 Nov 2022 01:07:33 -0800 IronPort-SDR: CFNzOwfJvdHgLGX3elSrpeROs/dRQPcB8me0IzdzWQBdj6SGqY8cWYAc+C+XyDEQ8LK+exJSuV 22smZ+bocmdeuc3F+QF5IMazggAeXwuW/UJaN7V/0ZABv58FcWTApQlzIHJmsS2Dsi0I4aEYf7 38KvxbcN4awtlTZ/LVcKOw62xHdk3UH3d6OtfLfGB3fssPBsnmfOseGHPf2U9VTq6oI2xvYflz fhRnORFm90k+XqSdPwlRTls7xRXZfDYrOUFV3F796fDqaNPvwUIOWv5D4xQeRXZgSNJJ8xrP5J cNk= From: Thomas Schwinge To: Martin =?utf-8?Q?Li=C5=A1ka?= , CC: Richard Biener , Tom de Vries Subject: Re: Restore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR' (was: [PATCH 1/3] STABS: remove -gstabs and -gxcoff functionality) In-Reply-To: <87y1sr2ipw.fsf@euler.schwinge.homeip.net> References: <10a94ccc-e01b-b98a-0fcb-cd661c10c315@suse.cz> <87fsfviww8.fsf@euler.schwinge.homeip.net> <4893b6df-b624-9af7-fb8b-9ff0c5385d83@suse.cz> <87y1sr2ipw.fsf@euler.schwinge.homeip.net> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Fri, 4 Nov 2022 10:07:26 +0100 Message-ID: <87sfiz2ilt.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-09.mgc.mentorg.com (139.181.222.9) 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 List-Id: --=-=-= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi! On 2022-11-04T10:04:59+0100, wrote: > On 2022-10-12T11:21:19+0200, Martin Li=C5=A1ka wrote: >> On 10/10/22 16:19, Thomas Schwinge wrote: >>> attached >>> "Restore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCT= OR'". > >> Thanks for the fix, really appreciated! > > Pushed to master branch commit 4ee35c11fd328728c12f3e086ae016ca94624bf8 > "Restore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR= '" ..., see attached now. ;-) Gr=C3=BC=C3=9Fe Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename="0001-Restore-default-sorry-TARGET_ASM_CONSTRUCTOR-TARGET_.patch" >From 4ee35c11fd328728c12f3e086ae016ca94624bf8 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sun, 9 Oct 2022 22:39:02 +0200 Subject: [PATCH] Restore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR' ... that got lost in commit 7e0db0cdf01e9c885a29cb37415f5bc00d90c029 "STABS: remove -gstabs and -gxcoff functionality". Previously, if a back end was not 'USE_COLLECT2', nor manually defined 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR', or got pointed to the respective 'default_[...]' functions due to 'CTORS_SECTION_ASM_OP', 'DTORS_SECTION_ASM_OP', or 'TARGET_ASM_NAMED_SECTION', it got pointed to 'default_stabs_asm_out_constructor', 'default_stabs_asm_out_destructor'. These would emit 'sorry' for any global constructor/destructor they're run into. This is now gone, and thus in such a back end configuration case 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR' don't get defined anymore, and thus the subsequently following: #if !defined(TARGET_HAVE_CTORS_DTORS) # if defined(TARGET_ASM_CONSTRUCTOR) && defined(TARGET_ASM_DESTRUCTOR) # define TARGET_HAVE_CTORS_DTORS true # endif #endif ... doesn't define 'TARGET_HAVE_CTORS_DTORS' anymore, and thus per my understanding, 'gcc/final.cc:rest_of_handle_final': if (DECL_STATIC_CONSTRUCTOR (current_function_decl) && targetm.have_ctors_dtors) targetm.asm_out.constructor (XEXP (DECL_RTL (current_function_decl), 0), decl_init_priority_lookup (current_function_decl)); if (DECL_STATIC_DESTRUCTOR (current_function_decl) && targetm.have_ctors_dtors) targetm.asm_out.destructor (XEXP (DECL_RTL (current_function_decl), 0), decl_fini_priority_lookup (current_function_decl)); ... simply does nothing anymore for a 'DECL_STATIC_CONSTRUCTOR', 'DECL_STATIC_DESTRUCTOR'. This, effectively, means that GCC/nvptx now suddenly appears to "support" global constructors/destructors, which means that a ton of test cases now erroneously PASS that previously used to FAIL: sorry, unimplemented: global constructors not supported on this target Of course, such support didn't magically happen due to "STABS: remove -gstabs and -gxcoff functionality", so this is bad. And, corresponding execution testing then regularly FAILs (due to the global constructor/destructor functions never being invoked), for example: [-UNSUPPORTED:-]{+PASS:+} gcc.dg/initpri1.c {+(test for excess errors)+} {+FAIL: gcc.dg/initpri1.c execution test+} [-UNSUPPORTED:-]{+PASS:+} g++.dg/special/conpr-1.C {+(test for excess errors)+} {+FAIL: g++.dg/special/conpr-1.C execution test+} To restore the previous GCC/nvptx behavior, for traceability, this simply restores the previous code, stripped down to the bare minimum. gcc/ * Makefile.in (OBJS): Add 'dbxout.o'. * config/nvptx/nvptx.cc: '#include "dbxout.h"'. * dbxout.cc: New. * dbxout.h: Likewise. * target-def.h (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): Default to 'default_stabs_asm_out_constructor', 'default_stabs_asm_out_destructor'. --- gcc/Makefile.in | 1 + gcc/config/nvptx/nvptx.cc | 1 + gcc/dbxout.cc | 43 +++++++++++++++++++++++++++++++++++++++ gcc/dbxout.h | 25 +++++++++++++++++++++++ gcc/target-def.h | 4 ++++ 5 files changed, 74 insertions(+) create mode 100644 gcc/dbxout.cc create mode 100644 gcc/dbxout.h diff --git a/gcc/Makefile.in b/gcc/Makefile.in index f672e6ea5498..c4072d06a936 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1355,6 +1355,7 @@ OBJS = \ data-streamer.o \ data-streamer-in.o \ data-streamer-out.o \ + dbxout.o \ dbgcnt.o \ dce.o \ ddg.o \ diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 2fe120b38730..4cb5d02d40cd 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -52,6 +52,7 @@ #include "tm-preds.h" #include "tm-constrs.h" #include "langhooks.h" +#include "dbxout.h" #include "cfgrtl.h" #include "gimple.h" #include "stor-layout.h" diff --git a/gcc/dbxout.cc b/gcc/dbxout.cc new file mode 100644 index 000000000000..161eeb196537 --- /dev/null +++ b/gcc/dbxout.cc @@ -0,0 +1,43 @@ +/* Copyright (C) 1987-2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "diagnostic-core.h" +#include "dbxout.h" + +/* Record an element in the table of global destructors. SYMBOL is + a SYMBOL_REF of the function to be called; PRIORITY is a number + between 0 and MAX_INIT_PRIORITY. */ + +void +default_stabs_asm_out_destructor (rtx symbol ATTRIBUTE_UNUSED, + int priority ATTRIBUTE_UNUSED) +{ + sorry ("global destructors not supported on this target"); +} + +/* Likewise for global constructors. */ + +void +default_stabs_asm_out_constructor (rtx symbol ATTRIBUTE_UNUSED, + int priority ATTRIBUTE_UNUSED) +{ + sorry ("global constructors not supported on this target"); +} diff --git a/gcc/dbxout.h b/gcc/dbxout.h new file mode 100644 index 000000000000..ad0b538cabf1 --- /dev/null +++ b/gcc/dbxout.h @@ -0,0 +1,25 @@ +/* Copyright (C) 1998-2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_DBXOUT_H +#define GCC_DBXOUT_H + +extern void default_stabs_asm_out_destructor (rtx, int); +extern void default_stabs_asm_out_constructor (rtx, int); + +#endif /* GCC_DBXOUT_H */ diff --git a/gcc/target-def.h b/gcc/target-def.h index f81f8fe3bb39..1c4aa2963dc4 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -62,6 +62,8 @@ # else # ifdef TARGET_ASM_NAMED_SECTION # define TARGET_ASM_CONSTRUCTOR default_named_section_asm_out_constructor +# else +# define TARGET_ASM_CONSTRUCTOR default_stabs_asm_out_constructor # endif # endif #endif @@ -72,6 +74,8 @@ # else # ifdef TARGET_ASM_NAMED_SECTION # define TARGET_ASM_DESTRUCTOR default_named_section_asm_out_destructor +# else +# define TARGET_ASM_DESTRUCTOR default_stabs_asm_out_destructor # endif # endif #endif -- 2.35.1 --=-=-=--