[dpdk-dev] [PATCH v1 5/6] fix missing includes in exported headers

Bruce Richardson bruce.richardson at intel.com
Thu Dec 21 17:01:03 CET 2017


On Thu, Dec 21, 2017 at 03:50:31PM +0100, Adrien Mazarguil wrote:
> On Thu, Dec 21, 2017 at 02:12:57PM +0000, Bruce Richardson wrote:
> > On Thu, Dec 21, 2017 at 02:00:04PM +0100, Adrien Mazarguil wrote:
> > > Many exported headers rely on definitions found in rte_config.h without
> > > including it, as shown by the following command:
> > > 
> > >  grep -L '^#include <rte_config.h>' -- \
> > >   $(grep -Rl \
> > >     $(sed -n '/^#define \([^ ]\+\).*$/{s//\1/;H;};${x;s/\n//;s/\n/\\|/g;p;}' \
> > >       build/include/rte_config.h) \
> > >     -- build/include/)
> > > 
> > > We cannot assume external applications will include rte_config.h on their
> > > own, neither directly nor through a -include parameter like DPDK does
> > > internally.
> > > 
> > > This not only causes obvious compilation failures that can be reproduced
> > > with check-includes.sh such as:
> > > 
> > >  [...]/rte_memory.h:88:43: error: ‘RTE_CACHE_LINE_SIZE’ was not declared in
> > >      this scope
> > >   #define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE)
> > >                                             ^
> > > 
> > > It also results in less visible issues, for instance rte_hash_crc.h relying
> > > on RTE_ARCH_X86_64's presence to provide dedicated inline functions.
> > > 
> > > This patch partially reverts the commit below and adds missing include
> > > lines to the remaining files.
> > > 
> > > Fixes: f1a7a5c5f404 ("remove include of generated config header")
> > > Cc: Thomas Monjalon <thomas at monjalon.net>
> > > 
> > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
> > > ---
> > 
> > Hi Adrien,
> > 
> > Just FYI, when we move to the new DPDK build system and pass the
> > necessary build meta-data to the application using pkg-config, this
> > should be a non-issue, as the pkg-config information will include the
> > "-include rte_config.h" parameter.
> 
> Right, actually -include rte_config.h is also provided to applications that
> rely on the current DPDK build system, those are already safe.
> 
> The motivation behind this patch is other applications that casually
> #include things without even depending on the build features of DPDK (not
> even going through pkg-config manually), in order to meet a safety level
> worthy of /usr/include.
> 
> In my opinion it's fine if this usage is not supported and a prior #include
> <rte_config.h> is required, however in that case we need our header files to
> #error out. Adding #include directly as done in this patch was in fact just
> as easy.
> 
> > When investigating that, I also tried this approach of adding rte_config
> > to files explicitly but it did not work for me as expected, as there
> > were cases where the build was depending upon the rte_config.h always
> > being the first include in the file. Normally, the rte_* headers should
> > be last included, so putting it at the top just didn't seem right to me.
> > I don't remember the specifics, but it was something like using the RTE_
> > defines to determine which system header file to use e.g. BSD vs Linux.
> > However, this may be an internal DPDK-build restriction rather than one
> > that would affect user-apps our or examples.
> 
> Was it perhaps before we added consistency to all public headers?
> 
> check-includes.sh was added a few releases ago to make sure each of them
> could be included on its own, to ensure they properly fetched all their
> dependencies instead of triggering compilation errors.
> 
> Rule of thumb being if you need something, #include the file providing it
> first. I find it strange rte_config.h is somehow an exception.
> 
> > So, with transitioning to meson and pkg-config, this issue becomes less
> > significant.
> 
> Agreed, however I still think something needs to be done, so:
> 
> - Do we want to let applications not rely on our build flags yet still use
>   our exported headers?
> 
> - Is a missing #include <rte_config.h> supposed to trigger an explicit
>   #error for safety?
> 
> - How about putting back #include <rte_config.h> in our exported header
>   files directly given the above?
> 
> Note this discussion is only about exported headers. The rest remains
> unaffected and can safely continue to rely on -include rte_config.h.
> 
Sure, and to be clear I have no objection to having this patch applied.
Having the include on the compiler cmdline as well as having it the file
is fine, so there is no real conflict. As you say, it will make
individual headers more consumable for those not looking to use all of
DPDK.

/Bruce


More information about the dev mailing list