From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 738D541EA1; Wed, 15 Mar 2023 16:56:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EBF640A7A; Wed, 15 Mar 2023 16:56:17 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id C067C40141 for ; Wed, 15 Mar 2023 16:56:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678895776; x=1710431776; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=1UVjTnhpkpDX/pphHfiukoXkg/KHmzdpDlLQS4Fayo8=; b=REBr1tZFGlC9Hh98YxOvK3JGa2bJNABc3c67/iuaUjVA/VDoUwKqu1Sk VcddUKAUo6GBQLKHHhP4VQIlgMYQ4Fkcryj7+aEz78QFct7m7BGxU+dhq DLu43Ex3Amk4I60O7t4RF0jRvKLySjUF8NyFHVWVzfu7WeNX1b+d0yzoz g1toaL2THsBMQl1YXfdVCSyr1DMpVFtbCVIMul/nxyQDKFm3LV1Z94IwT VGeiFecQrg3cnarE8GNz6sz+lyKVy0rT1qWhN/U00Ll+V5S8ShQabAmRB Aw1kTBNnK+N7tM/JVzw1LfMPkkN/myEvepctfM0x9/UfMNxTpzN+Oggek Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10650"; a="335234108" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="335234108" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 08:56:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10650"; a="743746670" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="743746670" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga008.fm.intel.com with ESMTP; 15 Mar 2023 08:56:09 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 08:56:08 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 08:56:08 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Wed, 15 Mar 2023 08:56:08 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.171) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Wed, 15 Mar 2023 08:56:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UYhIJo1H7epIBdgQmMj5oSFTfB+cmcH9UsyDNzjQyJBJ5TS92Sc4Dk3oI4e/aSAFwS4QLii732Jsvx9998pV3MaNUK+9ZoMyq5GCxtwEdOq++USA5WJDKc2AKNFDEURtgcrZmiL5qdntNCIzehS3ytZ4yKbGrqAA2PPFGSCzqTafyTFVCA4STycdZXTJw82mSvy2Chiq1R0P+SApOYw1qetichedVrmEtOyenDINTgcUn4oRdhBLmYmVlh6g8OB0w0aNaTlfcjCA/aXhFHUsbQJvSDL+jW4Xm60YlGNJM9Lw4cwR8c1WsbA2n+w6qAhYngGuTwyTjEG/aGNQ1u1xzA== 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=L1RcBxoa58kC4Ji2HOQKwvJzZxV/pevNiomd2hTVXaQ=; b=WJj2vESa0XAhgtcSahy7BgnIf7IWkJuDHH7icNNyKT8bDFxkkG3Da9oPwrnckBycSDzS0DuSCA8pabjBcsKKYjo8MHhokm+OA9ItH9GYDvolIkTHnNhQMINCEr2qXDrHDsVrDx+m/nPw7k5tfW9dVcO1tza1rvUv31q2oKXkkoHByIdTY+10g7easGj8sIo6uYQlLmoT+berIgANfTeDvfJJQja+J7n4of4btwbaNtppIOdA0DrM4k09TILYpEs6CxmWlDD/zOkzWkEnDOg46venb6nqSmT9JVX0VuxSE9SkeIPaWPvgrGR3vmvCXoJlm5oLX2JQMB63gpA4YP0zbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by CO1PR11MB4852.namprd11.prod.outlook.com (2603:10b6:303:9f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.26; Wed, 15 Mar 2023 15:56:05 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::18d0:ac53:aa1d:d19c]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::18d0:ac53:aa1d:d19c%5]) with mapi id 15.20.6178.024; Wed, 15 Mar 2023 15:56:05 +0000 Date: Wed, 15 Mar 2023 15:55:56 +0000 From: Bruce Richardson To: Mattias =?iso-8859-1?Q?R=F6nnblom?= CC: "dev@dpdk.org" , Mattias =?iso-8859-1?Q?R=F6nnblom?= Subject: Re: PIE static library builds Message-ID: References: <075645fc-f40d-82c6-52d5-ce8b23f3cdeb@lysator.liu.se> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: LNXP265CA0016.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::28) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|CO1PR11MB4852:EE_ X-MS-Office365-Filtering-Correlation-Id: 9655f80d-14bd-4091-34d0-08db256dc862 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KIW+Kwed4Td64o/L2UeZa1f8/w3vweX22IAwSGu2fR2ysN849TOsYIk1XR8ESHYaUc1D8qktxuPQcdAiYWNwJYVto1XfrCUv+OHMK/TdmOpNTK5WfjZZoQE7EWIS+QAzwM2MeoSK2LtaFpWSu5vvngGr7ChSkcSNUMyXO0q+Yo0Hw/dDsQAfBPOeB3ELysBcfbA/3v6Fc9evOS1axCAOabcUTTMT5i2TCPa7W3Ae++Xp5rkU2HUOB1rRLBluxHE/47kJw6ZUjFHnyqsaIJDWyTnF6ILfwwsia6M2WRS2XHDhlQPZUiLlHyBUDqCEPRwv2amcT2ceSXOdedHiRprTgLH0pne/1aKNmYu+1gfDwIuYlyrj2crA0U3fPUmpYddSR3huRjxDYUK0l5yUar49C1yUbXZYmENWB8gAu1h4l5YxFpZdTbX44/Ll6qTO+meRra1fPfHaLS2bVzKJopOAW2MkoNPcbCV+eVjdd0XU8Tk0KaXGdaHLurFSdAMwBwTKpDRz4cahAFv7mBbD6z47gN8rCCjzG8+VjiC/+9p7tihqB4bmezpn3kyUMO1+ctEjnS5+QZiRhvblQ/6YcVyxCVy6OXvimvr/4ccuJdyEAt0HXgWd2BpPYc7NhPIcXTxfnxJNZsQgojR9YTDdtFoxjQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(366004)(396003)(39860400002)(346002)(376002)(136003)(451199018)(86362001)(38100700002)(3480700007)(82960400001)(2906002)(41300700001)(5660300002)(8936002)(44832011)(4326008)(6512007)(6506007)(26005)(186003)(83380400001)(53546011)(66574015)(316002)(296002)(54906003)(8676002)(6916009)(66476007)(66556008)(66946007)(6486002)(6666004)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?V9M2W/9KRrFF6R9KAtwZNtG7Li4SRGL1xui3sRmNgCe/ARXNc0nNqGNXAz?= =?iso-8859-1?Q?96j8PxhWrAHHPnsS9YNIPSr96WPqGfRGg4pd+9jp6EhSW2a92FCD/Ije3Q?= =?iso-8859-1?Q?4MiUQj8VxNYzYHds86HLlLyHpjNYV3qGA8iiAwcoqToCrO6IUjynY5mIsy?= =?iso-8859-1?Q?+ZTiQ4XthVOojQ9ak2wLQMo/yBi2pd8QAhx3l3/ptokS6n+PpkEbZGgSM0?= =?iso-8859-1?Q?XP4ZAu9wValu+NXaBQUHZmRo/MHb8p9ZiDiI1txGQSnHtBX+Axh8CafKG6?= =?iso-8859-1?Q?cjRPMgf2rmKOtQMNakb0Mz6bFvwGhsKIvsA4yE6LolLONvX3fGcur1CW89?= =?iso-8859-1?Q?7w6cBrFNjvayhq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kKKbuow2Xwsq08CdbQw3IU?= =?iso-8859-1?Q?ZYXqnXGBE/skxG8NIC5Bw3jklvMZJOIHnUPl7iGqCxrscDM4ttD4aWttev?= =?iso-8859-1?Q?esarfKZHwAPFBt4m3S4/0rmn72vx6Wc63kK2jaEnp9XD6nPP7nyEpIdTKm?= =?iso-8859-1?Q?S4j7a3iASbI2S/WVKfV/CAam1/syeuB0+0e0yKpgw0QwhsptDR1RIFAgSg?= =?iso-8859-1?Q?L+SJrblyf9wnX1kHUECvAPSybd52Sc/DJBWYao0IIuIogNr3rDCQYAB/mH?= =?iso-8859-1?Q?V1qKQGZrompwf75OAWJQYGVPY4OYsnzM6/G1stD9FOZ920Gq5CqZVIoUZj?= =?iso-8859-1?Q?uRExUvGDQBwvdm7biEbAr3cMjn5LLYpeUdJIFW8a7vZ2W94mZE3R7MoOKf?= =?iso-8859-1?Q?R6QKJqUZ6uq80SPaQgJ0AJZYqsqQdBO1IgnMcd7UaGodGtnQAiZLB/cd28?= =?iso-8859-1?Q?UQA3aksUhUjZFxasx7c=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9655f80d-14bd-4091-34d0-08db256dc862 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2023 15:56:04.9255 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EPOnoZ6kiXM5l2+T0A03ilTCdojhElq/vQNA74Pn+eCr4di2sVr4YYsKcp+Kn+dUbHE5oXeEZvD4QhQfhbo+RrGWmMtRoB7gKNXedivcDMw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB4852 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Mar 15, 2023 at 04:45:26PM +0100, Mattias Rönnblom wrote: > On 2023-03-15 15:18, Bruce Richardson wrote: > > On Tue, Mar 14, 2023 at 06:31:41PM +0000, Bruce Richardson wrote: > > > On Tue, Mar 14, 2023 at 07:04:19PM +0100, Mattias Rönnblom wrote: > > > > On 2023-03-14 17:29, Bruce Richardson wrote: > > > > > On Tue, Mar 14, 2023 at 05:22:02PM +0100, Mattias Rönnblom wrote: > > > > > > Hi. > > > > > > > > > > > > Is the "b_staticpic" meson build option supposed to work with DPDK? > > > > > > > > > > > > Setting it to "false" (default is "true") causes link failures on > > > > > > Ubuntu 22.04, with GCC 9 and 11, on v23.03rc1 and v22.11: > > > > > > > > > > > > /usr/bin/ld: lib/librte_eal.a.p/eal_common_eal_common_errno.c.o: > > > > > > relocation R_X86_64_TPOFF32 against `per_lcore_retval.1' can not be > > > > > > used when making a shared object; recompile with -fPIC /usr/bin/ld: > > > > > > failed to set dynamic section sizes: bad value collect2: error: ld > > > > > > returned 1 exit status > > > > > > > > > > > > Does something per-lcore/TLS-related require PIC builds, even for > > > > > > static libraries? > > > > > > > > > > > I don't think that is the issue. The "issue" is that DPDK always does > > > > > both static and shared builds from the same object files, so without > > > > > -fPIC the shared library parts of the build fails. To support not > > > > > using staticpic, we'd have to disable building the .so's in those > > > > > cases, or each C file built twice. > > > > > > > > > > > > > With "default_library" set to "static", shouldn't the shared objects be > > > > skipped? I can see now, they are not. > > > > > > > > > > Yep, they aren't skipped. The reasons for this are partially historical, > > > and partially due to meson limitations around linking (which may now also > > > be historical). > > > > > > When we originally switched over to meson, IIRC there was no > > > "both_libraries" option, but we still had a situation where: * we wanted > > > to use and link staticly by default * we had *lots* of issues with > > > patches breaking builds as submitters had forgotten about shared libs > > > e.g. updating the version map Therefore, from the earliest versions of > > > the meson builds we had DPDK always build both libraries - using our own > > > logic. [This did have the desired effect of mostly eliminating version > > > map issues once everyone whiched over, which was nice!] > > > > > Symbols missing in version.map will be caught by the build bots, correct? > Provided they build shared object builds, as well as the default. This > feedback is received only after the patches have been submitted, but usually > there are still several revisions of a patch set anyways. > Yes, they are caught by buildbots, but it's much better that they are caught by the submitter before they even get to pushing out a patch. While it may be a fairly minor issue, we used to see a *lot* of patches submitted previously which did not pass a shared-library build (and not everyone checked the build bot results for their patches). > > > As things moved on, meson did add support for "both_libraries", and I did > > > investigate using it in DPDK to have proper static-only, shared-only and > > > both-library builds. Unfortunately, the assumption in meson was that if > > > both libraries were built, the apps would link against the shared > > > versions. Therefore, any change to use "both_library" support in DPDK > > > would unfortunately lead to a change in default behaviour as our builds > > > would all be shared, rather than static. [I have not checked recently to > > > see if this can be overcome.] > > > > > > This is why things as where they are right now. :-) > > > > > For the sake of completeness: one other complication I forgot to mention - > > using function versioning. When we have a library containing versioned > > functions the build needs to be performed slightly differently depending on > > whether we are building it as a static or a shared library. This is because > > the verisoning macro need to expand slightly differently depending on the > > build type. This prevents us from using "both_libraries" in these cases. > > [And why, right now, we need to explicitly tag any libs with versioned > > functions, so we can compile all the source files twice, with different > > flags]. > > > > I'm not sure I follow here. Are separate object files built for static and > shared libraries, or not? Here it sounds like they have to be built with > different flags, but earlier I thought you said static and dynamic libraries > were assembled from the same object files. Normally, they are only built once. However, if a library is using function versioning then the object files are built twice. > > If you set "b_staticpic=false" the build is still partially successful, and > you can build separate applications (e.g., dpdk-test). I ran some > performance tests, and it seems like there may be some performance to gain > from building with -fPIE. Great. There is probably a way we can make the DPDK build work to enable proper support for just static, just shared, or both libraries being built. It's probably not entirely straight-forward though. The biggest sticking point is like the function versioning in the "both_library" case, but we may be able to make that work with some overloading of the "pic" flag - since setting that to false will force double-compilation of the files in the "both" case. I think we'll also need a DPDK-specific build option too for specifying the link-preference of static/shared for the "both" case too, so as to keep static linking as default. /Bruce