From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smarthost2.atos.net (smtppost.atos.net [193.56.114.177]) by sourceware.org (Postfix) with ESMTPS id BCA1E3858D39 for ; Thu, 21 Oct 2021 12:39:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BCA1E3858D39 X-IronPort-AV: E=Sophos;i="5.87,169,1631570400"; d="scan'208,217";a="275120477" X-MGA-submission: =?us-ascii?q?MDHcScp5KB0T1kafcrWKBJ/EcDtzV4HSQfEdP3?= =?us-ascii?q?H6f84IZ/lL1XNXnC3u6Hem9AUja73+q27L4ij/PykUs5x2jFONLXlJhn?= =?us-ascii?q?o9riHGON1vbLMWZ8U+VhY/k4QQ/0N0Oel168Cu6VZDv6rJn8aJJzKU1a?= =?us-ascii?q?8h?= Received: from mail.sis.atos.net (HELO GITEXCPRDMB21.ww931.my-it-solutions.net) ([10.89.29.131]) by smarthost2.atos.net with ESMTP/TLS/AES256-GCM-SHA384; 21 Oct 2021 14:39:57 +0200 Received: from GITEXCPRDMB24.ww931.my-it-solutions.net (10.89.29.134) by GITEXCPRDMB21.ww931.my-it-solutions.net (10.89.29.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 21 Oct 2021 14:39:56 +0200 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (172.16.214.171) by GITEXCPRDMB24.ww931.my-it-solutions.net (10.89.29.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15 via Frontend Transport; Thu, 21 Oct 2021 14:39:56 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=byHXeWf4XMBszbd34DTJePNQe6RO8sgBnNW6LVIeEjC8KSfCfvQyOZVq5XuvR3U4R4NyfaG9tgoFPezcramN37uLWDyO3LJlDMLcRZiT78jT7Sg65pqjCyTYnpizApGznPk+eGLKiM6eRvUTPabv1DzHqjBzt0FXPoedoy4g6UxgzLiW2x1YLzGZEBbE9d6Tp8Tv1SbJ3d55HKiD88mOpR86jLeSZyXa04MqNPj3vht9noAbD87btqfTLn3ovEn7ratStdr5ae93QJrYQ6GGcPln3lZ4sjiQV3dDE3O4QpuiJAu3PVEICvHhwT0t3lA90a6k8Uq6u5NbuVmQ5BtfYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DGaO7oatpqpB7V2PWINTewrcJIiM+a2UO1NECc9e+60=; b=LZBT7ZqapfgYWB1we2ogmuzyJhHKArs9Yh0XmLUazYkMVm/VtQSZPhigZ1EPHnIHxE5oM5FOVWoNRdhIfvCQfM0B8DSskMmSXDu2NF7BLV65GLRHdLLJ8j5G1Cs6+i5C3DCsEQmwcfJ+ChP1piMmgNqBCX59B3zoilaNplQ9UO668Xpjd49WlJZbINvbj6P+JQpc0QWsgbeYm4tGDy3sZT2QHgAlNdVBNCAlAmmzBLQUiKjzg2ai+jtoMm8xdKC5yQZ44og/e6KoHms/l/G5ZzVhIBAk02ENx7mJdbQXr3Dj/4BuF+DcwC+/Wcf3i2Y3nIGw3zODP68teyeigTRysQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atos.net; dmarc=pass action=none header.from=atos.net; dkim=pass header.d=atos.net; arc=none Received: from PA4PR02MB6686.eurprd02.prod.outlook.com (2603:10a6:102:ff::14) by PR1PR02MB4761.eurprd02.prod.outlook.com (2603:10a6:102:e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Thu, 21 Oct 2021 12:39:55 +0000 Received: from PA4PR02MB6686.eurprd02.prod.outlook.com ([fe80::d85f:8147:a57e:92cb]) by PA4PR02MB6686.eurprd02.prod.outlook.com ([fe80::d85f:8147:a57e:92cb%5]) with mapi id 15.20.4608.020; Thu, 21 Oct 2021 12:39:55 +0000 From: "CHIGOT, CLEMENT" To: David Edelsohn CC: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH] gcc: implement AIX-style constructors Thread-Topic: [PATCH] gcc: implement AIX-style constructors Thread-Index: AQHXw/UayPzaxZrHSUWl8igmK/p7lavaw/oAgAKjTUQ= Date: Thu, 21 Oct 2021 12:39:55 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_e463cba9-5f6c-478d-9329-7b2295e4e8ed_Enabled=True; MSIP_Label_e463cba9-5f6c-478d-9329-7b2295e4e8ed_SiteId=33440fc6-b7c7-412c-bb73-0e70b0198d5a; MSIP_Label_e463cba9-5f6c-478d-9329-7b2295e4e8ed_SetDate=2021-10-21T12:39:54.884Z; MSIP_Label_e463cba9-5f6c-478d-9329-7b2295e4e8ed_Name=Atos For Internal Use - All Employees; MSIP_Label_e463cba9-5f6c-478d-9329-7b2295e4e8ed_ContentBits=0; MSIP_Label_e463cba9-5f6c-478d-9329-7b2295e4e8ed_Method=Standard; suggested_attachment_session_id: 377ac625-35c5-7bf1-4932-bbabd7e0ca4a x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e9cb9d6d-8f79-4a90-ef6a-08d9948fe2c5 x-ms-traffictypediagnostic: PR1PR02MB4761: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9CCulg8cuRs7ocpUKOQ8C4dM/xn+A5Kfcp+NG3FAVmdMcuABkGNsW023xs/P/Nls6CDeaqAgvfJ4AsgDluYQIiWc5cOCiQqguNfarkVFK2eCuQWtbuEvPmoyTT1SRA+qAToEE1emzXga5WjJwykjsxF/FlT+IRftJqdqvkAnj0XxkbasbdCp6SH7Pn4KQieoLCbuVkGRNg8pIek0nZKQ+mmhnmi/PanTPN4BqWAOxunWDOz7EMW23LTm2YX9uzT2TwWDH14iScd5Tah3pthOg3PZ55/Jwg31cYDUn6zw2XZxeurZrOwL4oVCAb0C2XdL1UU/i6VvGHTE78ias9SlmMh0Q+6Nlayl2tdWn6ImHcXcuAD+wKnPMBCORr7Ytdau3XtlJ1oBbCRoepHa+s35aEUDRMbY+TPbsuy/xubflMTZlObpWBWFTB0oHo8FqbGYdiP+06gjh1rgwzmE5B02XvTr8jlfwxykHTEkIxOAlRZrmzTeMVXpctTATse8S2DnUDMT/wIdixVQcx+jJiwX03FJDP4gY6dnptndFoVPZueVJXbl8pquJMW/ptMgLgxxPI3PXALTdZ26/hzgpN1DQkjbszXmXxdHBws2A0nqoyPhzEJ+2L/Br6A293jgiqTMl2M51CWIqYouSwEMorebpAqGsW+cHQbEHJiuI2g3ZAmKahB/rfQpGT7YOWt5NVTsvlMDde2wvM63W9iy8qBI23SS/PSRUj5P8k/RY7PDztdCSCVnUy5tVVDnRlkd4RiZaL55DXwtczHTAm+TGVgIkGJ7+pd3VhG0SFIMZdoJyEM= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR02MB6686.eurprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(122000001)(38100700002)(86362001)(33656002)(19627405001)(64756008)(2906002)(66946007)(91956017)(76116006)(53546011)(9686003)(5660300002)(7696005)(186003)(52536014)(55016002)(66556008)(4326008)(66476007)(66446008)(6506007)(508600001)(8936002)(66574015)(26005)(6916009)(71200400001)(8676002)(82960400001)(316002)(38070700005)(83380400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: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T9bWrrCMwyrn8JvIqzO0Oe+XMaotlgxrWzZ5?= =?iso-8859-1?Q?kmMF4wuhs3dKLNmzKJTiYNqOrYd6ioBHA/pouWekAsDp48pvNpAq9p0ii8?= =?iso-8859-1?Q?T0SdiUpE5tnwnbJTzoB609SZzWa0cDFgTIbwer7rCEbwBE/SU/yqha8kbE?= =?iso-8859-1?Q?XV7hcmw/3XfCPa4KRvjm0n4aFJ7fbuSulKH9xWsKLclM6Fym/6IqcWVfMR?= =?iso-8859-1?Q?VVil+ekIeBE0A93vDFhAq9CeTeIRQGqndFJZhoDug9r4MxwGnoVCemHpGf?= =?iso-8859-1?Q?ajNYNss0ONZISZ+aFY6CTVTc208YarO4pKMO3Z4HYQUE1HciaW1PkNbl/i?= =?iso-8859-1?Q?b7xPjYC/qGnv62bJd8qVVXdgSSEBZDkNNavumoKjB6KqRk27SrFJcW1uvW?= =?iso-8859-1?Q?QG6YbkMEWWIV+2lJ6kA6sLWRq2RgvpGuguKrTnPD+HdYyIxR2cxIsAihjX?= =?iso-8859-1?Q?NSyCQHRc/KZ3VA8x6wSkZGMl7q6b/dY6+1yf2iXb2AftmSm/LYtpaNes0e?= =?iso-8859-1?Q?K535MgrVZIOeSPeBMmWm598Qrmzy3IDgTOgHt8+JZ5kYvFoqoVS35207lX?= =?iso-8859-1?Q?iA57coXH4ptsdRyK6yEcnhvYEthnOJ6TRPcZ7GmlkO70uBV4wrGnFJDDuC?= =?iso-8859-1?Q?E=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR02MB6686.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9cb9d6d-8f79-4a90-ef6a-08d9948fe2c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Oct 2021 12:39:55.3879 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 33440fc6-b7c7-412c-bb73-0e70b0198d5a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: clement.chigot@atos.net X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR1PR02MB4761 X-OriginatorOrg: atos.net X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, HTML_MESSAGE, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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, 21 Oct 2021 12:40:00 -0000 Hi David, The problem is that cdtors is created by the linker only when -bcdtors flag is provided. Thus, if we add "extern void (* _cdtors[]) (void);" to the "crtcxa.c", we can't used it without using the new constructor types. One solution would be to create another crtcxa (eg crtcxa_cdtors.o) which w= ill be replacing the default crtcxa.o when needed. I didn't thought about that when creating the patch. But it might be a better approach. What do you thi= nk ? About documentation, I wasn't aware of that. I'll do it. Cl=E9ment ________________________________ From: David Edelsohn Sent: Tuesday, October 19, 2021 10:14 PM To: CHIGOT, CLEMENT Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] gcc: implement AIX-style constructors Caution! External email. Do not open attachments or click links, unless thi= s email comes from a known sender and you know the content is safe. Clement, + /* Use __C_runtime_pstartup to run ctors and register dtors. + This whole part should normally be in libgcc but as + AIX cdtors format is currently not the default, managed + that in collect2. */ Why are you emitting the special startup function call in collect2.c instead of placing it in libgcc. The comment mentions that the special startup function should be defined in libgcc. Yes, the AIX ld bcdtors mechanism is not the default, but what is the harm? The symbol will be defined and exported by libgcc. If the AIX linker -bcdtors functionality is not invoked, the symbol is not used. And if a user does invoke the AIX linker with -bcdtors, the behavior will be the same (either the program was compiled to use AIX cdtors or not, which is the same if the startup function is emitted by collect2.c. Also, the patch should include documentation of the option. The documentation should mention that this is for interoperability with IBM XL Compiler, and the option will not operate correctly unless the application and the GCC runtime are built with the option. Thanks, David On Mon, Oct 18, 2021 at 3:55 AM CHIGOT, CLEMENT w= rote: > > AIX linker now supports constructors and destructors detection. For such > functions to be detected, their name must starts with __sinit or __sterm. > and -bcdtors must be passed to linker calls. It will create "_cdtors" > symbol which can be used to launch the initialization. > > This patch creates a new RS6000 flag "-mcdtors=3D". > With "-mcdtors=3Daix", gcc will generate these new constructors/destructo= rs. > With "-mcdtors=3Dgcc", which is currently the default, gcc will continue > to generate "gcc" format for constructors (ie _GLOBAL__I and _GLOBAL__D > symbols). > Ideally, it would have been better to enable the AIX format by default > instead of using collect2. However, the compatibility between the > previously-built binaries and the new ones is too complex to be done. > > gcc/ChangeLog: > 2021-10-04 Cl=E9ment Chigot > > * collect2.c (aixbcdtors_flags): New variable. > (main): Use it to detect -bcdtors and remove -binitfini flag. > (write_c_file_stat): Adapt to new AIX format. > * config/rs6000/aix.h (FILE_SINIT_FORMAT): New define. > (FILE_STERM_FORMAT): New define. > (TARGET_FILE_FUNCTION_FORMAT): New define. > * config/rs6000/aix64.opt: Add -mcdtors flag. > * config/rs6000/aix71.h (LINK_SPEC_COMMON): Pass -bcdtors when > -mcdtors=3Daix is passed. > * config/rs6000/aix72.h (LINK_SPEC_COMMON): Likewise. > * config/rs6000/aix73.h (LINK_SPEC_COMMON): Likewise. > * config/rs6000/rs6000-opts.h (enum rs6000_cdtors): New enum. > * tree.c (get_file_function_name): Add > TARGET_FILE_FUNCTION_FORMAT support. > > gcc/testsuite/ChangeLog: > 2021-10-04 Cl=E9ment Chigot > > * gcc.target/powerpc/constructor-aix.c: New test. > >