berthubert / simplomon

Very simple monitoring system with a single configuration file
MIT License
119 stars 15 forks source link

Ubuntu 20.04: compilation failed in `testrunner` #38

Open mrngm opened 6 months ago

mrngm commented 6 months ago

On Ubuntu 20.04, meson compile -C build/ fails in testrunner on 3 separate files.

As instructed, I'm using meson from pip, because meson on Ubuntu 20.04 has version 0.53.2

$ git lg | head -n 1
* b8b4ecc - (HEAD -> main, origin/main, origin/HEAD) remove prometheus command for now to fix build (5 days ago) <bert hubert>
$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ pip3 install meson ninja
(venv) $ meson --version
1.4.0
(venv) $ ninja --version
1.11.1.git.kitware.jobserver-1
(venv) $ meson setup build
[..]
simplomon undefined

  Subprojects
    cpp-httplib  : YES 3 warnings
    curl         : YES 1 warnings
    doctest      : YES
    fmt          : YES
    nlohmann_json: YES
    simplesockets: YES
    sqlitewriter : YES

Found ninja-1.11.1.git.kitware.jobserver-1 at /home/gerdriaan/scm/simplomon/venv/bin/ninja
(venv) $ meson compile -C build/ | tee -a /tmp/simplomon-compilelog
[..]
[175/214] Compiling C++ object subprojects/sqlitewriter/demo.p/demo.cc.o
[176/214] Compiling C++ object subprojects/simplesockets/testrunner.p/sclasses.cc.o
[177/214] Compiling C++ object subprojects/sqlitewriter/libsqlitewriter.a.p/jsonhelper.cc.o
[178/214] Compiling C++ object subprojects/sqlitewriter/demo.p/jsonhelper.cc.o
[179/214] Compiling C++ object subprojects/simplesockets/testrunner.p/swrappers.cc.o
[180/214] Compiling C++ object subprojects/sqlitewriter/testrunner.p/jsonhelper.cc.o
[181/214] Compiling C++ object subprojects/sqlitewriter/testrunner.p/testrunner.cc.o
ninja: build stopped: subcommand failed.
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/gerdriaan/scm/simplomon/venv/bin/ninja -C /home/gerdriaan/scm/simplomon/build
(venv) $

Excerpt from one error:

[172/214] Compiling C++ object subprojects/sqlitewriter/testrunner.p/sqlwriter.cc.o
FAILED: subprojects/sqlitewriter/testrunner.p/sqlwriter.cc.o 
c++ -Isubprojects/sqlitewriter/testrunner.p -Isubprojects/sqlitewriter -I../subprojects/sqlitewriter -I../subprojects/nlohmann_json-3.11.2/single_include -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++17 -O0 -g -pthread -MD -MQ subprojects/sqlitewriter/testrunner.p/sqlwriter.cc.o -MF subprojects/sqlitewriter/testrunner.p/sqlwriter.cc.o.d -o subprojects/sqlitewriter/testrunner.p/sqlwriter.cc.o -c ../subprojects/sqlitewriter/sqlwriter.cc
../subprojects/sqlitewriter/sqlwriter.cc: In member function ‘void MiniSQLite::execPrep(const string&, std::vector<std::unordered_map<std::__cxx11::basic_string<char>, std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t> > >*)’:
../subprojects/sqlitewriter/sqlwriter.cc:134:94: error: no match for ‘operator=’ (operand types are ‘std::unordered_map<std::__cxx11::basic_string<char>, std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t> >::mapped_type’ {aka ‘std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>’} and ‘sqlite3_int64’ {aka ‘long long int’})
  134 |           row[sqlite3_column_name(d_stmts[table], n)]= sqlite3_column_int64(d_stmts[table], n);
      |                                                                                              ^
In file included from ../subprojects/sqlitewriter/sqlwriter.hh:5,
                 from ../subprojects/sqlitewriter/sqlwriter.cc:1:
/usr/include/c++/9/variant:1299:16: note: candidate: ‘std::variant<_Types>& std::variant<_Types>::operator=(const std::variant<_Types>&) [with _Types = {double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t}]’
 1299 |       variant& operator=(const variant&) = default;
      |                ^~~~~~~~
/usr/include/c++/9/variant:1299:26: note:   no known conversion for argument 1 from ‘sqlite3_int64’ {aka ‘long long int’} to ‘const std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>&’
 1299 |       variant& operator=(const variant&) = default;
      |                          ^~~~~~~~~~~~~~
/usr/include/c++/9/variant:1300:16: note: candidate: ‘std::variant<_Types>& std::variant<_Types>::operator=(std::variant<_Types>&&) [with _Types = {double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t}]’
 1300 |       variant& operator=(variant&&) = default;
      |                ^~~~~~~~
/usr/include/c++/9/variant:1300:26: note:   no known conversion for argument 1 from ‘sqlite3_int64’ {aka ‘long long int’} to ‘std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>&&’
 1300 |       variant& operator=(variant&&) = default;
      |                          ^~~~~~~~~
/usr/include/c++/9/variant:1362:2: note: candidate: ‘template<class _Tp> std::enable_if_t<((__exactly_once<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type> > && is_constructible_v<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>, _Tp>) && is_assignable_v<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>&, _Tp>), std::variant<_Types>&> std::variant<_Types>::operator=(_Tp&&) [with _Tp = _Tp; _Types = {double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t}]’
 1362 |  operator=(_Tp&& __rhs)
      |  ^~~~~~~~
/usr/include/c++/9/variant:1362:2: note:   template argument deduction/substitution failed:
/usr/include/c++/9/variant: In substitution of ‘template<class ... _Types> template<class _Tp, class> using __accepted_type = std::variant<_Types>::__to_type<__accepted_index<_Tp> > [with _Tp = long long int&&; <template-parameter-2-2> = std::enable_if<true, void>::type; _Types = {double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t}]’:
/usr/include/c++/9/variant:1358:14:   required by substitution of ‘template<class _Tp> std::enable_if_t<((__exactly_once<std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type> > && is_constructible_v<std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>, _Tp>) && is_assignable_v<std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>&, _Tp>), std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>&> std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>::operator=<_Tp>(_Tp&&) [with _Tp = long long int]’
../subprojects/sqlitewriter/sqlwriter.cc:134:94:   required from here
/usr/include/c++/9/variant:1276:8: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
 1276 |  using __accepted_type = __to_type<__accepted_index<_Tp>>;
      |        ^~~~~~~~~~~~~~~

Two other failures, but full log omitted for brevity:

[173/214] Compiling C++ object subprojects/sqlitewriter/libsqlitewriter.a.p/sqlwriter.cc.o
FAILED: subprojects/sqlitewriter/libsqlitewriter.a.p/sqlwriter.cc.o 
c++ -Isubprojects/sqlitewriter/libsqlitewriter.a.p -Isubprojects/sqlitewriter -I../subprojects/sqlitewriter -I../subprojects/nlohmann_json-3.11.2/single_include -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++17 -O0 -g -fPIC -pthread -MD -MQ subprojects/sqlitewriter/libsqlitewriter.a.p/sqlwriter.cc.o -MF subprojects/sqlitewriter/libsqlitewriter.a.p/sqlwriter.cc.o.d -o subprojects/sqlitewriter/libsqlitewriter.a.p/sqlwriter.cc.o -c ../subprojects/sqlitewriter/sqlwriter.cc
../subprojects/sqlitewriter/sqlwriter.cc: In member function ‘void MiniSQLite::execPrep(const string&, std::vector<std::unordered_map<std::__cxx11::basic_string<char>, std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t> > >*)’:
../subprojects/sqlitewriter/sqlwriter.cc:134:94: error: no match for ‘operator=’ (operand types are ‘std::unordered_map<std::__cxx11::basic_string<char>, std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t> >::mapped_type’ {aka ‘std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>’} and ‘sqlite3_int64’ {aka ‘long long int’})
  134 |           row[sqlite3_column_name(d_stmts[table], n)]= sqlite3_column_int64(d_stmts[table], n);
      |                                                                                              ^
[174/214] Compiling C++ object subprojects/sqlitewriter/demo.p/sqlwriter.cc.o
FAILED: subprojects/sqlitewriter/demo.p/sqlwriter.cc.o 
c++ -Isubprojects/sqlitewriter/demo.p -Isubprojects/sqlitewriter -I../subprojects/sqlitewriter -I../subprojects/nlohmann_json-3.11.2/single_include -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++17 -O0 -g -pthread -MD -MQ subprojects/sqlitewriter/demo.p/sqlwriter.cc.o -MF subprojects/sqlitewriter/demo.p/sqlwriter.cc.o.d -o subprojects/sqlitewriter/demo.p/sqlwriter.cc.o -c ../subprojects/sqlitewriter/sqlwriter.cc
../subprojects/sqlitewriter/sqlwriter.cc: In member function ‘void MiniSQLite::execPrep(const string&, std::vector<std::unordered_map<std::__cxx11::basic_string<char>, std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t> > >*)’:
../subprojects/sqlitewriter/sqlwriter.cc:134:94: error: no match for ‘operator=’ (operand types are ‘std::unordered_map<std::__cxx11::basic_string<char>, std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t> >::mapped_type’ {aka ‘std::variant<double, long int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> >, std::nullptr_t>’} and ‘sqlite3_int64’ {aka ‘long long int’})
  134 |           row[sqlite3_column_name(d_stmts[table], n)]= sqlite3_column_int64(d_stmts[table], n);
      |                                                                                              ^

This looks similar to #5, except it's on Linux.

Currently installed dependency versions:

$ apt search '^(python3-pip|pkg-config|libnghttp2-dev|libssl-dev|liblua5.3-dev)' 2>/dev/null | grep -ie 'upgradable' -e 'install'
liblua5.3-dev/focal,now 5.3.3-1.1ubuntu2 amd64 [installed]
libnghttp2-dev/focal-updates,focal-security,now 1.40.0-1ubuntu0.2 amd64 [installed]
libssl-dev/focal-updates,focal-security 1.1.1f-1ubuntu2.22 amd64 [upgradable from: 1.1.1f-1ubuntu2.19]
pkg-config/focal,now 0.29.1-0ubuntu4 amd64 [installed,automatic]
python3-pip/focal-updates,focal-security 20.0.2-5ubuntu1.10 all [upgradable from: 20.0.2-5ubuntu1.9]
mrngm commented 6 months ago

It appears that subprojects/sqlitewriter is a Git repository as well. From a git blame, line 134 in the error message above was added/modified in 51169c8.

I noticed that sqlitewriter @ 51169c8 doesn't compile with the same error (albeit on a different line number). One commit earlier (36ef85b does compile (although it fails on linking psqlwriter due to missing dependencies).

github.com/berthubert/sqlitewriter is taken in as dependency and placed in the subprojects/ folder:

~/scm/simplomon/subprojects/sqlitewriter[main*]$ git lg
* 05b95d9 - (grafted, HEAD -> main, origin/main, origin/HEAD) Make sure we return (ill-advised) nul containing strings correctly, plus add a testcase. Closes #3 Thanks Wander Nauta for spotting this. (2 months ago) <bert hubert>

It seems Github Actions in that repository uses Ubuntu 22.04 as base image.

On Ubuntu 20.04:

$ c++ --version
c++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(which, eventually, can be found in the package g++-9).

On Ubuntu 22.04, it looks like c++ is sourced from g++-11.

Reading the porting to section in GCC11, a few things come to mind. The underlying standard has been upgraded from gnu++14 to gnu++17 (which is C++14, C++17 with GNU extensions). It seems template parameter matching has changed as well (P0522R0).

Could it be that sqlitewriter uses C++17 specific code that isn't supported in C++14 (or lower)?

wandernauta commented 6 months ago

Could it be that sqlitewriter uses C++17 specific code that isn't supported in C++14 (or lower)?

That sounds likely - sqlitewrite claims to require C++17 and simplomon asks for C++20.

mrngm commented 5 months ago

Could it be that sqlitewriter uses C++17 specific code that isn't supported in C++14 (or lower)?

That sounds likely - sqlitewrite claims to require C++17 and simplomon asks for C++20.

Thanks for the clarification, I'm not too familiar with cmake/meson build systems to have looked in this direction.