From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id 63D18386F006 for ; Wed, 16 Sep 2020 20:57:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 63D18386F006 Received: by mail-lf1-x12d.google.com with SMTP id y17so8441364lfa.8 for ; Wed, 16 Sep 2020 13:57:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=q0p5GzWw8+p1fJYWEWgCUL6eXUPIpMQtK2P8NOu12s4=; b=H/XO4tDyp4LsWLVH5cvG7xAwSL5OM37BNeezAPwdBcWyzZ7O3DS1LGsnjREoykIP8h o9hgRCAqeIFEmI270kd9CACN40F6FyLJyO+QE3KEJulwTPJYD0OoicxEo6XklFDEah/f LbR2RFXrskyAXrgYbXHNLztvCkN3wJEvZmX7cv2RX0fyMMDmMvdKDp0jLxQD/b2NPc8h p32GMXVitLRk/TRNr62QOuamslTnhJ7oikWoaku/6jReJePpbeCis9/Vv/1XTExzdjvL rvXb+P5dgrQvlAIujHF4PUml8Sviru0bAfrRVV8xAI9lQzFYVonHC28xNv+cSacKjMch 9vBQ== X-Gm-Message-State: AOAM532qJ8HOVWyCZ4dVfSHMlMYh3tgpptHwQw+SkZtEGZnd46oU4ieI seAoKWEXINzwzu5/voRMmE28bXvwjnXWHU6wDG20ruNCjjE= X-Google-Smtp-Source: ABdhPJyD2drSOM7XtE/WpysvlsZ33F63yKW/iVav4sPO/V2cD/Pd+B8byMy1zRiCLbh6mxvunUcTJ2KBFhOrjY9DAZc= X-Received: by 2002:ac2:489b:: with SMTP id x27mr8712070lfc.242.1600289821915; Wed, 16 Sep 2020 13:57:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ian Lance Taylor Date: Wed, 16 Sep 2020 13:56:50 -0700 Message-ID: Subject: Re: How does ld and gold deal with C++ duplicate templates? To: sotrdg sotrdg Cc: "binutils@sourceware.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-18.5 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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 20:57:05 -0000 On Wed, Sep 16, 2020 at 12:38 PM sotrdg sotrdg wrote: > > 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. Seems a pity, but OK. It's true that I don't have time to maintain it. And it's true that it doesn't work on Windows. > Does ld provide the same options? Not to my knowledge. > And why these optimizations are not applied by default? Because they measurably increase link times. Ian > 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=96577 > > > > > > > > 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 the 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 > >