ufo-kit / ufo-filters

Common plugin suite for the ufo-core processing framework
GNU Lesser General Public License v3.0
10 stars 14 forks source link

Current glib check breaks build #223

Open matze opened 1 year ago

matze commented 1 year ago

This is an interesting one. The error looks like this

In file included from /usr/include/glib-2.0/glib/glib-typeof.h:39,
                 from /usr/include/glib-2.0/glib/gatomic.h:28,
                 from /usr/include/glib-2.0/glib/gthread.h:32,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
                 from /usr/include/glib-2.0/glib.h:32,
                 from /usr/include/glib-2.0/gobject/gbinding.h:28,
                 from /usr/include/glib-2.0/glib-object.h:22,
                 from /home/matthias/.local/share/cenv/mesa/include/ufo-0/ufo/ufo-basic-ops.h:27,
                 from /home/matthias/.local/share/cenv/mesa/include/ufo-0/ufo/ufo.h:25,
                 from ../deps/oclfft/oclFFT.h:68,
                 from ../deps/oclfft/fft_internal.h:52,
                 from ../deps/oclfft/fft_execute.cpp:49:
/usr/include/c++/11/type_traits:3300:3: error: template with C linkage
 3300 |   template<typename _Tp>
      |   ^~~~~~~~
In file included from ../deps/oclfft/fft_internal.h:52,
                 from ../deps/oclfft/fft_execute.cpp:49:
../deps/oclfft/oclFFT.h:58:1: note: ‘extern "C"’ linkage started here
   58 | extern "C" {
      | ^~~~~~~~~~

The problem is caused by this:

  1. oclfft declares C linkage but of course needs to be compiled with a C++ compiler
  2. oclfft includes ufo.h in order to integrate with the profiling infrastructure
  3. ufo.h needs GLib which at some point checks if it is compiled with a C++ compiler (which it is) but fails because templates do not work with C linkage

I see three options:

  1. Hack around with

    #pragma push_macro("__cplusplus")
    #undef __cplusplus
    #include <ufo/ufo.h>
    #pragma pop_macro("__cplusplus")

    in oclFFT.h.

  2. Ask upstream to improve the check somehow.
  3. Drop the profiling integration.
tfarago commented 1 year ago

Oh man, that's just lovely. Hopefully early next year there will be more brainpower for doing these things, postponing until then ;-) Anyway, thanks for pointing this out.

matze commented 1 year ago

Well, for a quick fix, number 1 works without much brainpower. 2 relies on external factors that could take years to land (i.e. Ubuntu 24.04) and 3, well one might not want to do that anyway.

tfarago commented 1 year ago

@gabs1234 could you please take a look at this? We can then discuss how to go about this on Friday, thanks a lot! It's the stuff we briefly discussed the day before yesterday.