romgrk / node-gtk

GTK+ bindings for NodeJS (via GObject introspection)
MIT License
493 stars 41 forks source link

node-gtk 0.12+ fails to compile against libgirepository1.0-dev <1.72 (Ubuntu 20) #357

Closed chfritz closed 5 months ago

chfritz commented 5 months ago

I've debugged the issue I reported in https://github.com/romgrk/node-gtk/commit/bd7951cfb7993ba12ec1dc4dadf5db6d0592404f#r119695610 a lot further. I've tested on all combinations of:

As it turns out the issue, as you suspected, is related to the build environment. Specifically, the change in 0.12 I commented on in the above PR is to account for a change in libgirepository1.0-dev 1.12, very visible here: https://github.com/GNOME/gobject-introspection/blob/main/girepository/girffi.h#L99-L122

The result of this is that node-gtk 0.12+ doesn't compile on Ubuntu 20 (which uses libgirepository1.0-dev 1.64). Likewise, the precompiled binaries don't work on Ubuntu 20, because it's libstdc++ only goes to GLIBCXX_3.4.28, but the precompiled binaries use GLIBCXX_3.4.29 (see #337).

Unfortunately, node-gtk 0.11 doesn't work with node 20, so the upshot of this all is that there is no working version of node-gtk for the Ubuntu 20 + node 20 combination.

chfritz commented 5 months ago

The good news is that simply reverting this change to src/callback.cc makes node-gtk 0.12+ compile again on all combinations: of node 16/20 and ubuntu 20/22.

Are you open to doing that or should we investigate a different option where we somehow check which version of libgirepository is installed and then use the appropriate function names? C is annoying in this case. In node.js we could just do foo1 = g_callable_info_destroy_closure || g_callable_info_free_closure; foo1(...)

chfritz commented 5 months ago

Actually we can just use:

    #ifdef GI_AVAILABLE_IN_1_72
    closure = g_callable_info_create_closure(info, &cif, Callback::Call, this);
    #else
    closure = g_callable_info_prepare_closure(info, &cif, Callback::Call, this);
    #endif

and

    #ifdef GI_AVAILABLE_IN_1_72
    g_callable_info_destroy_closure (this->info, this->closure);
    #else
    g_callable_info_free_closure (this->info, this->closure);
    #endif
romgrk commented 5 months ago

Sure that sounds good. Do you want to open a PR?

romgrk commented 5 months ago

I've published v0.13.0. I've triggered the workflow to generate the prebuilt binaries but I haven't had enough bandwidth to fix build issues in a while, not sure if they'll be available.