link-mink / mink-core

mINK Framework
http://link-mink.com
MIT License
3 stars 4 forks source link

Yocto build failing #14

Closed popovicd closed 3 years ago

popovicd commented 3 years ago

Building the framework with Yocto/OpenEmbededd (Poky reference, version honister) following issue occurs for x86_64

../git/src/cfg/mink_config.cpp:851:24: error: format not a string literal and no format arguments [-Werror=format-security]
  851 |                 wprintw(win, tmp_cmd.c_str());
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/mink_config.cpp: In member function 'void config::Config::show_commands(config::ConfigItem*, int, bool)':
../git/src/cfg/mink_config.cpp:919:35: error: format not a string literal and no format arguments [-Werror=format-security]
  919 |                 if(ncurses) printw(tmp_cmd.c_str()); else std::cout << tmp_cmd;
      |                             ~~~~~~^~~~~~~~~~~~~~~~~

../git/src/cfg/mink_config.cpp: In member function 'void config::Config::print_cfg_def(bool, bool, config::ConfigItem*, int, int, WINDOW*)':
../git/src/cfg/mink_config.cpp:1980:28: warning: field width specifier '*' expects argument of type 'int', but argument 3 has type 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wformat=]
 1980 |             wprintw(win, "%*s", max_length - def->children[i]->name.size(), tmp_prefix.c_str());
      |                           ~^~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                            |               |
      |                            int             std::__cxx11::basic_string<char>::size_type {aka long unsigned int}

../git/src/cfg/mink_config.cpp:2012:24: error: format not a string literal and no format arguments [-Werror=format-security]
 2012 |                 wprintw(win, def->children[i]->desc.c_str());
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/mink_config.cpp: In member function 'void config::Config::print_cfg_def(bool, bool, config::ConfigItem*, int, int)':
../git/src/cfg/mink_config.cpp:2083:23: error: format not a string literal and no format arguments [-Werror=format-security]
 2083 |                 printw(tmp_val->c_str());
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~

../git/src/cfg/mink_config.cpp:2091:23: error: format not a string literal and no format arguments [-Werror=format-security]
 2091 |                 printw(def->children[i]->desc.c_str());
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

x86_64-poky-linux-g++  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/linux/poky/build/tmp/work/core2-64-poky-linux/link-mink/1.0-r0/recipe-sysroot -std=c++11 -DHAVE_CONFIG_H   -Isrc/include -Ilib/libantlr3c-3.4/include -Ilib/libantlr3c-3.4 -Isrc/services/config   -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/opt/linux/poky/build/tmp/work/core2-64-poky-linux/link-mink/1.0-r0=/usr/src/debug/link-mink/1.0-r0                      -fdebug-prefix-map=/opt/linux/poky/build/tmp/work/core2-64-poky-linux/link-mink/1.0-r0=/usr/src/debug/link-mink/1.0-r0                      -fdebug-prefix-map=/opt/linux/poky/build/tmp/work/core2-64-poky-linux/link-mink/1.0-r0/recipe-sysroot=                      -fdebug-prefix-map=/opt/linux/poky/build/tmp/work/core2-64-poky-linux/link-mink/1.0-r0/recipe-sysroot-native=  -fvisibility-inlines-hidden  -O -c -o src/services/config/configd-events.o `test -f 'src/services/config/events.cpp' || echo '../git/'`src/services/config/events.cpp

../git/src/services/config/events.cpp:12:10: fatal error: events.h: No such file or directory
   12 | #include <events.h>
      |          ^~~~~~~~~~

compilation terminated.

Also:

../git/src/cfg/plgcfg.cpp: In member function 'virtual void HbeatMissed::run(gdt::GDTCallbackArgs*)':
../git/src/cfg/plgcfg.cpp:57:15: error: format not a string literal and no format arguments [-Werror=format-security]
   57 |         printw(cli::CLIService::CURRENT_CLI_SERVICE->get_prompt()->c_str());
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/plgcfg.cpp: In function 'void* block_handler(void**, int)':
../git/src/cfg/plgcfg.cpp:184:15: error: format not a string literal and no format arguments [-Werror=format-security]
  184 |         printw(cli->get_prompt()->c_str());
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/plgcfg.cpp:185:15: error: format not a string literal and no format arguments [-Werror=format-security]
  185 |         printw(cli->get_current_line()->c_str());
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/plgcfg.cpp:195:15: error: format not a string literal and no format arguments [-Werror=format-security]
  195 |         printw(cli->get_prompt()->c_str());
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/plgcfg.cpp:330:15: error: format not a string literal and no format arguments [-Werror=format-security]
  330 |         printw(cli->get_prompt()->c_str());
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/plgcfg.cpp:331:15: error: format not a string literal and no format arguments [-Werror=format-security]
  331 |         printw(cli->get_current_line()->c_str());
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/plgcfg.cpp:633:15: error: format not a string literal and no format arguments [-Werror=format-security]
  633 |         printw(cli->get_prompt()->c_str());
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

../git/src/cfg/plgcfg.cpp: In function 'void* block_handler_init(void**, int)':
../git/src/cfg/plgcfg.cpp:706:62: warning: unknown conversion type character '!' in format [-Wformat=]
  706 |                     printw("Invalid daemon address format '%'!\n", optarg);
      |                                                              ^

../git/src/cfg/plgcfg.cpp:706:28: warning: too many arguments for format [-Wformat-extra-args]
  706 |                     printw("Invalid daemon address format '%'!\n", optarg);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dfranusic commented 3 years ago

Please provide the output of gcc -v. With the following setup, the issue cannot be reproduced:

Using built-in specs.  COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper Target:
x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc Thread model: posix Supported LTO
compression algorithms: zlib zstd gcc version 11.1.0 (GCC) 
dfranusic commented 3 years ago

With the added security flags (-Wformat-extra-args -Wformat -Werror=format-security):

g++ -std=c++11 -DHAVE_CONFIG_H \
-I. -Isrc/include -Wformat-extra-args -Wformat -Werror=format-security \
-O -MT src/cfg/libcfg_la-mink_config.lo -MD -MP \
-MF src/cfg/.deps/libcfg_la-mink_config.Tpo -c src/cfg/mink_config.cpp  \
-fPIC -DPIC \
-o src/cfg/.libs/libcfg_la-mink_config.o

I havee also tried with your default Yocto flags:

g++ -std=c++11 -m64 -mtune=core2 -msse3 -mfpmath=sse -fstack-protector-strong -DHAVE_CONFIG_H \
-I. -Isrc/include -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security \
-O2 -MT src/cfg/libcfg_la-mink_config.lo -MD -MP -MF src/cfg/.deps/libcfg_la-mink_config.Tpo \
-c src/cfg/mink_config.cpp  -fPIC -DPIC -o src/cfg/.libs/libcfg_la-mink_config.o
popovicd commented 3 years ago

Here is the output (it must be loaded against Yocto lib locations):

Using built-in specs.
COLLECT_GCC=./work/core2-64-poky-linux/gcc/11.2.0-r0/package/usr/bin/x86_64-poky-linux-gcc-11.2.0
COLLECT_LTO_WRAPPER=/opt/linux/poky/build/tmp/work/core2-64-poky-linux/gcc/11.2.0-r0/package/usr/bin/../libexec/gcc/x86_64-poky-linux/11.2.0/lto-wrapper
Target: x86_64-poky-linux
Configured with: ../../../../../../work-shared/gcc-11.2.0-r0/gcc-11.2.0/configure --build=x86_64-linux --host=x86_64-poky-linux --target=x86_64-poky-linux --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec --datadir=/usr/share --sysconfdir=/etc --sharedstatedir=/com --localstatedir=/var --libdir=/usr/lib --includedir=/usr/include --oldincludedir=/usr/include --infodir=/usr/share/info --mandir=/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/ --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-default-pie --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=x86_64-poky-linux- --without-local-prefix --disable-install-libiberty --disable-libssp --enable-libitm --enable-lto --disable-bootstrap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --without-isl --with-build-sysroot=/ --enable-standard-branch-protection --disable-static --enable-nls --with-glibc-version=2.28 --enable-initfini-array --enable-__cxa_atexit --with-arch=native
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC) 

This is from the Yocto automatic generated toolchain from the build system - no modification upon it whatsoever.

In the mean time, I managed to bypass the issue with adding the following into the recipe:

TARGET_CPPFLAGS:appen = "-Wno-format-security"
dfranusic commented 3 years ago

This seems to be ncurses related. Can you check which version you're using in your Yocto build?

dfranusic commented 3 years ago

@popovicd , I will close this issue for the time being since it is not directly related to mINK.