From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82240 invoked by alias); 6 Feb 2018 00:01:34 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 82230 invoked by uid 89); 6 Feb 2018 00:01:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=comparable, linux@carewolf.com, linuxcarewolfcom, H*f:sk:68CCCBE X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Feb 2018 00:01:32 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E7817ADCB; Tue, 6 Feb 2018 00:01:29 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 06 Feb 2018 00:01:00 -0000 From: Jan Hubicka To: Richard Biener Cc: gcc@gcc.gnu.org, Allan Sandfeld Jensen , jh@suse.cz Subject: Re: Resolving LTO symbols for static library boundary In-Reply-To: <68CCCBEA-05E1-4C80-B06C-9068FD1DD912@gmail.com> References: <38925973.88kXsFSiyi@twilight> <68CCCBEA-05E1-4C80-B06C-9068FD1DD912@gmail.com> Message-ID: X-Sender: jh@suse.de User-Agent: Roundcube Webmail X-SW-Source: 2018-02/txt/msg00041.txt.bz2 Dne 2018-02-05 18:44, Richard Biener napsal: > On February 5, 2018 12:26:58 PM GMT+01:00, Allan Sandfeld Jensen > wrote: >> Hello GCC >> >> In trying to make it possible to use LTO for distro-builds of Qt, I >> have again >> hit the problem of static libraries. In Qt in general we for LTO rely >> on a >> library boundary, where LTO gets resolved when generating the library >> but no >> LTO-symbols are exported in the shared library. This ensure the >> library >> has a >> well defined binary compatible interface and gets LTO optimizations >> within >> each library. For some private libraries we use static libraries >> however, >> because we don't need binary compatibility, but though we don't need >> BC >> >> between Qt versions, the libraries should still be linkable with >> different gcc >> versions (and with different compilers). However when LTO is enabled >> the >> static libraries will contain definitions that depend on a single gcc >> version >> making it unsuitable for distribution. >> >> One solution is to enable fat-lto object files for static libraries >> but >> that >> is both a waste of space and compile time, and disables any LTO >> optimization >> within the library. Ideally I would like to have the static library do >> LTO >> optimizations internally just like a shared library, but then exported >> as >> static library. >> >> I suspect this is more of gcc task than ar/ld task, as it basically >> boils down >> to gcc doing for a static library what it does for shared library, but >> maybe >> export the result as a single combined .o file, that can then be ar'ed >> into a >> compatible static library. >> >> Is this possible? > > Hmm. I think you could partially link the static archive contents into > a single relocatable object. Or we could add a mode where you do a > 1to1 LTO link of the objects and stop at the ltrans object files. You > could stuff those into an archive again. > > I'm not sure how far Honza got partial LTO linking to work? Parital linking of lto .o files into single non-lto .o file should work and it will get you cross-module optimization done. The problem is that without resolution info compiler needs to assume that all symbols exported by object files are possibly referneced by the later incremental link and thus the code quality will definitly not be comparable with what you get for LTO on final binary or DSO. Still should be better than non-lto build. I would be curious if it is useful for you in practice. Honza > > Richard. > >> Best regards >> 'Allan Jensen