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 9B9DCA04F6; Tue, 7 Jan 2020 10:30:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2205D1D982; Tue, 7 Jan 2020 10:30:53 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id C10EA1D981 for ; Tue, 7 Jan 2020 10:30:51 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2020 01:30:50 -0800 X-IronPort-AV: E=Sophos;i="5.69,405,1571727600"; d="scan'208";a="211077464" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.20.66]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Jan 2020 01:30:49 -0800 Date: Tue, 7 Jan 2020 09:30:45 +0000 From: Bruce Richardson To: Sachin Jain Cc: dev@dpdk.org Message-ID: <20200107093045.GA1258@bricha3-MOBL.ger.corp.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Subject: Re: [dpdk-dev] C++ app does not execute DPDK constructors. 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 Mon, Jan 06, 2020 at 01:24:36PM -0800, Sachin Jain wrote: > Hi > > *What am I trying to do?* > > I am trying to write Gtests for my application based on DPDK. > > *Details about the app:* > > The application compiles dpdk as static library. Its a pretty simple. For > now it just runs a dummy Gtest and create a memory pool. The key is, its a > C++ file. I see no issue if it were a C app. > > *Issue I am facing:* > > The call to rte_mempool_create fails() with "Err: No such file or > directory". > > *More debugging:* > > The reason for the above failure is, the constructor for the ring driver is > not getting called. Specifically below code in > ~/driver/mempool/ring/rte_mempool_ring.c. > > MEMPOOL_REGISTER_OPS(ops_mp_mc); > MEMPOOL_REGISTER_OPS(ops_sp_sc); > MEMPOOL_REGISTER_OPS(ops_mp_sc); > MEMPOOL_REGISTER_OPS(ops_sp_mc); > > So when I look at the C app which has these constructors called, I see the > init_array size to be much larger than the the C++ app. Considering the two > code are almost identical, I don't know what am I missing to have these > constructors run. They are definitely getting compiled but are not called. > > *What have I tried:* > > 1. I tried the --whole-archive LD option but I dont think that should play > a part here since the constructors does get called with C app. > Generally to get expected behaviour of constructors with static libs, you need to use both --whole-archive and --no-as-needed linker flags. Other than that, I'm not sure what the issue might be. The same .a files are used to link against the C and C++ objects? /Bruce