From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E0DC3A0613 for ; Tue, 24 Sep 2019 15:00:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BBA8E2C5E; Tue, 24 Sep 2019 15:00:05 +0200 (CEST) Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id B3A292BE6 for ; Tue, 24 Sep 2019 15:00:04 +0200 (CEST) Received: from cpe-2606-a000-111b-43ee-0-0-0-162e.dyn6.twc.com ([2606:a000:111b:43ee::162e] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1iCkPz-0003zy-IR; Tue, 24 Sep 2019 08:59:50 -0400 Date: Tue, 24 Sep 2019 08:59:42 -0400 From: Neil Horman To: Bruce Richardson Cc: Andrzej Ostruszka , Thomas Monjalon , Ray Kinsella , dev@dpdk.org, Aaron Conole , Michael Santana , John McNamara , Marko Kovacevic , David Hunt , Vladimir Medvedkin , Robert Sanford , Erik Gabriel Carrillo , mattias.ronnblom@ericsson.com, stephen@networkplumber.org, Andrzej Ostruszka Message-ID: <20190924125942.GA6041@hmswarspite.think-freely.org> References: <20190917075754.8310-1-amo@semihalf.com> <20190919151624.GA1999@bricha3-MOBL.ger.corp.intel.com> <1873473.QF300kEeir@xps> <20190923120658.GA2003@bricha3-MOBL.ger.corp.intel.com> <20190923161326.GB2003@bricha3-MOBL.ger.corp.intel.com> <42bc3e03-768f-b90c-5f81-5a1cb525bb2f@semihalf.com> <20190924102534.GA2021@bricha3-MOBL.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190924102534.GA2021@bricha3-MOBL.ger.corp.intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Spam-Score: -2.9 (--) X-Spam-Status: No Subject: Re: [dpdk-dev] [PATCH v2 01/10] build: add an option to enable LTO build X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Sep 24, 2019 at 12:25:35PM +0200, Bruce Richardson wrote: > On Tue, Sep 24, 2019 at 08:46:25AM +0200, Andrzej Ostruszka wrote: > > On 9/23/19 6:13 PM, Bruce Richardson wrote: > > [...] > > > However, testing on my system with the meson build, I'm getting lots of > > > link errors [See below]. Any suggestions? > > > > > > /Bruce > > > > > > /usr/bin/ld: /tmp/dpdk-testpmd.hncbtE.ltrans93.ltrans.o: in function `ena_stop': > > > :(.text+0x9ed6): undefined reference to `rte_timer_stop' > > [...] > > > > What is 'default_library'? It should be 'shared' as mentioned in the > > docs. The problem is that RTE_BUILD_SHARED_LIB is statically defined in > > rte_config.h used by meson build. This results in broken static > > libraries (those that are using versioned symbols - like > > timer/lpm/distributor) - since the MAP_STATIC_SYMBOL macro defining the > > default alias is empty. With LTO compiler (or rather linker) is quite > > aggressive in removing stuff that it thinks is not needed. > > > > Regards > > Andrzej > > > > PS. IMHO this SHARED_LIB define should be removed from the rte_config.h > > and meson.build should be updated to detect 'default_library' and add it > > as needed. Don't know exactly how meson behaves if 'default_library' is > > 'both' - the docs say that it reuses objects from static build, so we > > might have to work around it for LTO & 'both'. > > That proposal won't work either as we build both static and shared > libraries in all cases - the default_library value only affects whether the > test apps are linked against the .a or .so files. > > The real issue seems to be that the compat.h header has different > compilation paths for static and shared libraries, which means that any C > file including it can't have a .o file that can be used for both a .a and a > .so simultaneously. Having it default to the shared library path seems to > work fine thus far, but with LTO it seems broken as you say. Adding Neil as > the original file author of this in case he has any suggestions here. I'd > really rather not have to go back to building .a's and .so's separately. > The notion of using the same object file to link to a static archive and a dso seems somewhat suspect to me in general. I say that because I don't see a way for the linker to know/prove at link time that the options used to compile an object for target (a) will be the same as those used to compile the same object for target (b). In this particular case, you've identified an issue in compilation changes that triggers off the building of dso's vs static archives, but I could envision a scenario in which you might try to build targets for BSD and Linux in parallel, or even for different machines (i.e. build for a least common denominator x8664 target, and a highly optimized recent x8664 processor with all the ISA extensions enabled). We don't do that currently now of course, but we could, and the only way we could do so would be to rebuild all the objects with the compilation flags for each separately. That said, if the goal is to just overcome this particular situation, it might (strong might), be sufficient to simply augment the MAP_STATIC_SYMBOL macro in the CONFIG_RTE_BUILD_SHARED_LIB=n case to append the 'used' attribute. Ostensibly, LTO would be smart enough then to not eliminate the symbol? Just a thought. But I think we need to take care here. While its fine solve this particular situation, I think the notion of reusing objects for multiple link targets has the potential to uncover many issues of this class, which won't be as solveable without having to just rebuild objects from scratch. Neil > Regards, > /Bruce >