Better-sqlite3: can't build under Linux anymore

Created on 11 May 2018  Â·  7Comments  Â·  Source: JoshuaWise/better-sqlite3

Had no issues with compilation of better-sqlite3 under Arch Linux until recently. I tried different Node/npm versions.
Command make of node deps/install is failing without too much useful information.
So I tried to run manually make in better-sqlite3/build folder and getting 2 errors of error: static assertion failed: comparison object must be invocable with two arguments of key type

............

In file included from /usr/include/c++/8.1.0/set:60,
                 from ./src/better_sqlite3.lzz:6,
                 from ../src/better_sqlite3.cpp:4:
/usr/include/c++/8.1.0/bits/stl_tree.h: In instantiation of ‘class std::_Rb_tree<Statement*, Statement*, std::_Identity<Statement*>, Query::Compare, std::allocator<Statement*> >’:
/usr/include/c++/8.1.0/bits/stl_set.h:133:17:   required from ‘class std::set<Statement*, Query::Compare>’
./src/objects/database.lzz:71:43:   required from here
/usr/include/c++/8.1.0/bits/stl_tree.h:452:21: error: static assertion failed: comparison object must be invocable with two arguments of key type
       static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{},
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.1.0/bits/stl_tree.h: In instantiation of ‘class std::_Rb_tree<Transaction*, Transaction*, std::_Identity<Transaction*>, Query::Compare, std::allocator<Transaction*> >’:
/usr/include/c++/8.1.0/bits/stl_set.h:133:17:   required from ‘class std::set<Transaction*, Query::Compare>’
./src/objects/database.lzz:72:45:   required from here
/usr/include/c++/8.1.0/bits/stl_tree.h:452:21: error: static assertion failed: comparison object must be invocable with two arguments of key type
In file included from ./src/better_sqlite3.lzz:9,
                 from ../src/better_sqlite3.cpp:4:
./src/better_sqlite3.lzz: At global scope:
/home/k2s/.node-gyp/8.11.1/include/node/node.h:475:43: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
       (node::addon_register_func) (regfunc),                          \
                                           ^

............

make: *** [better_sqlite3.target.mk:101: Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1

this is full output https://pastebin.com/U9xQjpYQ of LZZ_COMPAT=1 npm install

bug

Most helpful comment

Fixed in v4.1.3, thanks to @theflyingape's suggestion

All 7 comments

This worked for me:

sudo pacman -S gcc54
CC=gcc-5 CXX=g++-5 npm install

I confirm that @three solution works and it works also with gcc6:

sudo pacman -S gcc6
CC=gcc-6 CXX=g++-6 npm install

Is it possible to fix the code to work also with gcc8 ?

@JoshuaWise seems to be related to other projects having issue with C++17 mode enforcement; refer to an explanation and potential fix here: clamr fails to build with gcc-8.0.1

The issue also occurs in sumo (https://github.com/eclipse/sumo/issues/4110). The issue isnt caused by the missing const modifier as indicated by the clamr bug though, rather it occurs because the Key type is of incomplete type. From a quick glance at better-sqlite3's code it looks like this is also the case for better-sqlite3.

Does @mightyCelu approach to fix look helpful in addressing the build failure here?

Unclear how/why this works for me, but using @mightyCelu exampled use of a template class, I altered query.lzz to:

class Compare { public:
template<class T>
    bool operator() (const T* const a, const T* const b) const {
        return a->extras->id < b->extras->id;
    }
};

... and the module builds using gcc-c++ 8.1.

Fixed in v4.1.3, thanks to @theflyingape's suggestion

Was this page helpful?
0 / 5 - 0 ratings

Related issues

imtbl picture imtbl  Â·  6Comments

DrDonkeyPunch picture DrDonkeyPunch  Â·  5Comments

Silve2611 picture Silve2611  Â·  6Comments

BrianMagus picture BrianMagus  Â·  5Comments

k1ngrnbz picture k1ngrnbz  Â·  4Comments