DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Sachin Jain <mail.sachin.jain@gmail.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] C++ app does not execute DPDK constructors.
Date: Tue, 7 Jan 2020 09:30:45 +0000	[thread overview]
Message-ID: <20200107093045.GA1258@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <CADSjHcUuATpx_QmngRqfrvmG8jynnY_fL4xT=fm25eum3AYM1Q@mail.gmail.com>

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

      reply	other threads:[~2020-01-07  9:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-06 21:24 Sachin Jain
2020-01-07  9:30 ` Bruce Richardson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200107093045.GA1258@bricha3-MOBL.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=mail.sachin.jain@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).