[v4,7/7] buildtools/chkincs: test headers for C++ compatibility
Checks
Commit Message
Add support for checking each of our headers for issues when included in
a C++ file.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
.ci/linux-build.sh | 1 +
.github/workflows/build.yml | 2 +-
buildtools/chkincs/main.cpp | 4 ++++
buildtools/chkincs/meson.build | 20 ++++++++++++++++++++
devtools/test-meson-builds.sh | 3 ++-
5 files changed, 28 insertions(+), 2 deletions(-)
create mode 100644 buildtools/chkincs/main.cpp
Comments
10/02/2022 16:42, Bruce Richardson:
> +executable('chkincs-cpp', cpp_sources,
> + cpp_args: ['-include', 'rte_config.h', cflags],
> + link_args: dpdk_extra_ldflags,
> + include_directories: includes,
> + dependencies: deps,
> + link_whole: dpdk_static_libraries + dpdk_drivers,
> + install: false)
devtools/test-meson-builds.sh is failing on build-x86-generic
at link stage:
/usr/bin/ld: cannot find -lIPSec_MB
That's probably because there is no pkg-config file for this lib,
and it is not installed in a standard directory,
so my setup is adding -L in LDFLAGS.
On Thu, Feb 10, 2022 at 10:58:37PM +0100, Thomas Monjalon wrote:
> 10/02/2022 16:42, Bruce Richardson:
> > +executable('chkincs-cpp', cpp_sources, + cpp_args: ['-include',
> > 'rte_config.h', cflags], + link_args: dpdk_extra_ldflags, +
> > include_directories: includes, + dependencies: deps, +
> > link_whole: dpdk_static_libraries + dpdk_drivers, + install:
> > false)
>
> devtools/test-meson-builds.sh is failing on build-x86-generic at link
> stage: /usr/bin/ld: cannot find -lIPSec_MB That's probably because there
> is no pkg-config file for this lib, and it is not installed in a standard
> directory, so my setup is adding -L in LDFLAGS.
>
The test-meson-build.sh script works fine for me on my system with the
ipsec_mb libraries being found ok [installed in standard path]. Can you
share how you are adding the extra library paths, is it via environment or
via c_link_args?
/Bruce
On Fri, Feb 11, 2022 at 10:31:38AM +0000, Bruce Richardson wrote:
> On Thu, Feb 10, 2022 at 10:58:37PM +0100, Thomas Monjalon wrote:
> > 10/02/2022 16:42, Bruce Richardson:
> > > +executable('chkincs-cpp', cpp_sources, + cpp_args: ['-include',
> > > 'rte_config.h', cflags], + link_args: dpdk_extra_ldflags, +
> > > include_directories: includes, + dependencies: deps, +
> > > link_whole: dpdk_static_libraries + dpdk_drivers, + install:
> > > false)
> >
> > devtools/test-meson-builds.sh is failing on build-x86-generic at link
> > stage: /usr/bin/ld: cannot find -lIPSec_MB That's probably because there
> > is no pkg-config file for this lib, and it is not installed in a standard
> > directory, so my setup is adding -L in LDFLAGS.
> >
> The test-meson-build.sh script works fine for me on my system with the
> ipsec_mb libraries being found ok [installed in standard path]. Can you
> share how you are adding the extra library paths, is it via environment or
> via c_link_args?
>
Actually, I just realised that these chkincs binaries don't need to be
linked with all these libraries at all, since they don't actually call any
functions and are just meant to check includes. Let me test with removing
all the "link_whole:" parameters and if that works, submit it as a new
patch. That might solve your issues here - again depending on how your
environment is set up.
/Bruce
11/02/2022 11:57, Bruce Richardson:
> On Fri, Feb 11, 2022 at 10:31:38AM +0000, Bruce Richardson wrote:
> > On Thu, Feb 10, 2022 at 10:58:37PM +0100, Thomas Monjalon wrote:
> > > 10/02/2022 16:42, Bruce Richardson:
> > > > +executable('chkincs-cpp', cpp_sources, + cpp_args: ['-include',
> > > > 'rte_config.h', cflags], + link_args: dpdk_extra_ldflags, +
> > > > include_directories: includes, + dependencies: deps, +
> > > > link_whole: dpdk_static_libraries + dpdk_drivers, + install:
> > > > false)
> > >
> > > devtools/test-meson-builds.sh is failing on build-x86-generic at link
> > > stage: /usr/bin/ld: cannot find -lIPSec_MB That's probably because there
> > > is no pkg-config file for this lib, and it is not installed in a standard
> > > directory, so my setup is adding -L in LDFLAGS.
> > >
> > The test-meson-build.sh script works fine for me on my system with the
> > ipsec_mb libraries being found ok [installed in standard path]. Can you
> > share how you are adding the extra library paths, is it via environment or
> > via c_link_args?
> >
> Actually, I just realised that these chkincs binaries don't need to be
> linked with all these libraries at all, since they don't actually call any
> functions and are just meant to check includes. Let me test with removing
> all the "link_whole:" parameters and if that works, submit it as a new
> patch. That might solve your issues here - again depending on how your
> environment is set up.
As I said, it is configured via LDFLAGS environment variable:
export LDFLAGS=-L$aesnidep
@@ -74,6 +74,7 @@ fi
if [ "$BUILD_32BIT" = "true" ]; then
OPTS="$OPTS -Dc_args=-m32 -Dc_link_args=-m32"
+ OPTS="$OPTS -Dcpp_args=-m32 -Dcpp_link_args=-m32"
export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
fi
@@ -116,7 +116,7 @@ jobs:
libdw-dev
- name: Install i386 cross compiling packages
if: env.BUILD_32BIT == 'true'
- run: sudo apt install -y gcc-multilib
+ run: sudo apt install -y gcc-multilib g++-multilib
- name: Install aarch64 cross compiling packages
if: env.AARCH64 == 'true'
run: sudo apt install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross
new file mode 100644
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+int main(void) { return 0; }
@@ -28,3 +28,23 @@ executable('chkincs', sources,
dependencies: deps,
link_whole: dpdk_static_libraries + dpdk_drivers,
install: false)
+
+# run tests for c++ builds also
+if not add_languages('cpp', required: false)
+ subdir_done()
+endif
+
+gen_cpp_files = generator(gen_c_file_for_header,
+ output: '@BASENAME@.cpp',
+ arguments: ['@INPUT@', '@OUTPUT@'])
+
+cpp_sources = files('main.cpp')
+cpp_sources += gen_cpp_files.process(dpdk_chkinc_headers)
+
+executable('chkincs-cpp', cpp_sources,
+ cpp_args: ['-include', 'rte_config.h', cflags],
+ link_args: dpdk_extra_ldflags,
+ include_directories: includes,
+ dependencies: deps,
+ link_whole: dpdk_static_libraries + dpdk_drivers,
+ install: false)
@@ -246,7 +246,8 @@ if check_cc_flags '-m32' ; then
export PKG_CONFIG_LIBDIR='/usr/lib/pkgconfig'
fi
target_override='i386-pc-linux-gnu'
- build build-32b cc ABI -Dc_args='-m32' -Dc_link_args='-m32'
+ build build-32b cc ABI -Dc_args='-m32' -Dc_link_args='-m32' \
+ -Dcpp_args='-m32' -Dcpp_link_args='-m32'
target_override=
unset PKG_CONFIG_LIBDIR
fi