From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-oln040092003106.outbound.protection.outlook.com [40.92.3.106]) by sourceware.org (Postfix) with ESMTPS id 57D873951413 for ; Wed, 16 Sep 2020 19:38:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 57D873951413 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XXGppS0H+3f6WmuGu/bkJWu7jEQv8X6SQO/+jBCgRNb+yKVT4Xu9chyqUq27y0TYpk/oWQUi1DDpgM2PUcl6SzEv9SN4hAjE8BuFjGRxBFLyJ7UTHxQBzAmszUOb9sm2tLuSLzRDzhugVrB5ttOjHmUskMsSbI2i9hcEniaLWcCQ6v01+ItQpkEex355vTsM8fa/YUogr7RyDhdd+edNmWBWicg9NNV5W078byx7KQgjPTEyMitJU4htkK2h7tvCXxARA2INMIWNrZuP9T62fkN25g3nVAg2MJonoIXtZu+pAzJbC2T+apxRp97Ypz/xADqe7erZVCfDUOSec54ZUQ== 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-SenderADCheck; bh=Zr8Dn4WPt9Wm94imhVy4zlxTghb9gF4HYAYo6+Jj4mw=; b=Ec37uWXOZK0SuSX4ns4rQJlEq4Dvwy8ITIm0z7pJ4gCpGdgY9g/LRXjrhImO2++SNQZW/HlVnUHbHETE7Q9/ghERK1UbKVU2oS6c8V46a84k5mXdeQJSCQ/LUS+AFsSU54MJ94LjEytInzuyabakAuwRKdz7kzWeox26RcieylbEBwaq7Y2eqbaJkEXTJXQSg0qqpVmBfQ99qB9uHcl1xgxtOGz1Ah1oPCjC+pJl/4pQFSe1jn2RCwKzVAShZ/FbI8iQcShxGOkp5rBOssEjemZx5SbN6z1N8Ocw4ubDznOzt+5oBrEWNrWDpEr7BQaM+bqN1eWZm+V2ncwZfbINOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from CY1NAM02FT030.eop-nam02.prod.protection.outlook.com (10.152.74.58) by CY1NAM02HT127.eop-nam02.prod.protection.outlook.com (10.152.74.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 16 Sep 2020 19:38:10 +0000 Received: from CH2PR02MB6522.namprd02.prod.outlook.com (2a01:111:e400:7e45::43) by CY1NAM02FT030.mail.protection.outlook.com (2a01:111:e400:7e45::419) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16 via Frontend Transport; Wed, 16 Sep 2020 19:38:10 +0000 Received: from CH2PR02MB6522.namprd02.prod.outlook.com ([fe80::9b5:13b8:a669:a117]) by CH2PR02MB6522.namprd02.prod.outlook.com ([fe80::9b5:13b8:a669:a117%8]) with mapi id 15.20.3391.011; Wed, 16 Sep 2020 19:38:10 +0000 From: sotrdg sotrdg To: Ian Lance Taylor , "binutils@sourceware.org" Subject: RE: How does ld and gold deal with C++ duplicate templates? Thread-Topic: How does ld and gold deal with C++ duplicate templates? Thread-Index: AQHWjAsVWv8zM9xQU0q7F4CZskTyPKlrpYUAgAADsyE= Date: Wed, 16 Sep 2020 19:38:10 +0000 Message-ID: References: , In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:ED2B96C6FD9CDE3599B700FBA9147FCD868133B9F52C6A8E95B02F44F8662A99; UpperCasedChecksum:4DC9EB2EB7FB96F6178B4C0CF64BCA9E64765433B5E8B47E23645D19CF4A2855; SizeAsReceived:6999; Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [5/BQrihWB4iHAwg9pC0sUHNCTEkdrU5d] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: aa8b85d0-d285-4bc6-f4a1-08d85a780b52 x-ms-traffictypediagnostic: CY1NAM02HT127: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ln53wVLsSe1U7rVOJCQxvnBvul7NF/wnsJcG61i87mVNEIKcKsGzAQmqNZdH5+9RnmF/Kx6jlmgaDWADelgZ8PjwAFvbKaZNv2NVyzjxMEYHktam9ejkK3ITDXiEJpimbTRo1KG0Z4wSZmNkfijggNYK90qB7hlMlPupsWQ7hB2Mo/UmsJkBntOjv6PvnBqUr1+xX264j8F0tito9Q4Rx/QXA5gHkdlP096tYRKygXaJCRGzzAh2oSGypBj5Wkol x-ms-exchange-antispam-messagedata: L6c3NymobPNiHNTmPAALJJvQY+f650gmqNqvsEVtnkpXVyQKBHd5Jb8H+SMpR7yZoNGkIR62UG0H8/KP3LnvFQ0VoYlMhEH5rjNkBBTIJhDdGTiI6NlrTCxubbQKGEfXUCduoqrHDwhr64JnerOcgw== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT030.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: aa8b85d0-d285-4bc6-f4a1-08d85a780b52 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2020 19:38:10.5177 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT127 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2020 19:38:13 -0000 But gold linker is said to be removed in the future since no one is willing= to maintain it any more. BTW, I am using MinGW on Windows where gold does = not seem to be available. Does ld provide the same options? And why these optimizations are not applied by default? Sent from Mail for Window= s 10 From: Ian Lance Taylor Sent: Wednesday, September 16, 2020 15:23 To: sotrdg sotrdg Cc: binutils@sourceware.org Subject: Re: How does ld and gold deal with C++ duplicate templates? On Wed, Sep 16, 2020 at 2:26 AM sotrdg sotrdg via Binutils wrote: > > Like the bug I reported a month ago. > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96577 > > > > https://godbolt.org/z/haG4E7 > > https://godbolt.org/z/M8e7Kb > > > > First: > > > > #include > > #include > > #include > > > > template > > void f(Iter a,Iter b) > > { > > std::sort(a,b); > > } > > > > void g(std::vector::iterator b,std::vector::iterator e) > > { > > f(b,e); > > } > > > > void h(int* b,int* e) > > { > > f(b,e); > > } > > > > Second: > > > > > > #include > > #include > > #include > > > > template > > void f(Iter a,Iter b) > > { > > std::sort(a,b); > > } > > > > void g(std::vector::iterator b,std::vector::iterator e) > > { > > f(std::to_address(b),std::to_address(e)); > > } > > > > void h(int* b,int* e) > > { > > f(b,e); > > } > > > > > > The two sort function should generate exactly the same binary. However th= e first which is none to_address version generates twice as much as code as= the second one. > > Will the GNU ld remove the duplication definitions? For gold, see the --icf option. Ian