hyprwm / xdg-desktop-portal-hyprland

xdg-desktop-portal backend for Hyprland
BSD 3-Clause "New" or "Revised" License
273 stars 47 forks source link

[1.0.0] Fails to build with Clang #81

Closed jbeich closed 1 year ago

jbeich commented 1 year ago

According to relnotes GCC 12 -> 13 indeed helps but Clang 16 -> 17 doesn't:

$ export CC=clang CXX=clang++ CXXFLAGS=-stdlib=libc++
$ meson setup _build
$ meson compile -C _build
[...]
../src/shared/ScreencopyShared.cpp:230:69: error: taking the address of a temporary object of type 'struct spa_rectangle' [-Waddress-of-temporary]
  230 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle(&SPA_RECTANGLE(width, height)), 0);
      |                                                   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:66:39: note: expanded from macro 'SPA_POD_Rectangle'
   66 | #define SPA_POD_Rectangle(val)                          "R",val
      |                                                             ^~~
../src/shared/ScreencopyShared.cpp:232:73: error: taking the address of a temporary object of type 'struct spa_fraction' [-Waddress-of-temporary]
  232 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&SPA_FRACTION(0, 1)), 0);
      |                                                        ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:71:38: note: expanded from macro 'SPA_POD_Fraction'
   71 | #define SPA_POD_Fraction(val)                           "F",val
      |                                                             ^~~
../src/shared/ScreencopyShared.cpp:233:89: error: taking the address of a temporary object of type 'struct spa_fraction' [-Waddress-of-temporary]
  233 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(framerate, 1), &SPA_FRACTION(1, 1), &SPA_FRACTION(framerate, 1)), 0);
      |                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:73:77: note: expanded from macro 'SPA_POD_CHOICE_RANGE_Fraction'
   73 | #define SPA_POD_CHOICE_RANGE_Fraction(def,min,max)      "?rF", SPA_CHOICE_RANGE((def),(min),(max))
      |                                                                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:27:44: note: expanded from macro 'SPA_CHOICE_RANGE'
   27 | #define SPA_CHOICE_RANGE(def,min,max)                   3,(def),(min),(max)
      |                                                            ^~~
../src/shared/ScreencopyShared.cpp:233:118: error: taking the address of a temporary object of type 'struct spa_fraction' [-Waddress-of-temporary]
  233 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(framerate, 1), &SPA_FRACTION(1, 1), &SPA_FRACTION(framerate, 1)), 0);
      |                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:73:83: note: expanded from macro 'SPA_POD_CHOICE_RANGE_Fraction'
   73 | #define SPA_POD_CHOICE_RANGE_Fraction(def,min,max)      "?rF", SPA_CHOICE_RANGE((def),(min),(max))
      |                                                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:27:50: note: expanded from macro 'SPA_CHOICE_RANGE'
   27 | #define SPA_CHOICE_RANGE(def,min,max)                   3,(def),(min),(max)
      |                                                                  ^~~
../src/shared/ScreencopyShared.cpp:233:139: error: taking the address of a temporary object of type 'struct spa_fraction' [-Waddress-of-temporary]
  233 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(framerate, 1), &SPA_FRACTION(1, 1), &SPA_FRACTION(framerate, 1)), 0);
      |                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:73:89: note: expanded from macro 'SPA_POD_CHOICE_RANGE_Fraction'
   73 | #define SPA_POD_CHOICE_RANGE_Fraction(def,min,max)      "?rF", SPA_CHOICE_RANGE((def),(min),(max))
      |                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:27:56: note: expanded from macro 'SPA_CHOICE_RANGE'
   27 | #define SPA_CHOICE_RANGE(def,min,max)                   3,(def),(min),(max)
      |                                                                        ^~~
../src/shared/ScreencopyShared.cpp:267:69: error: taking the address of a temporary object of type 'struct spa_rectangle' [-Waddress-of-temporary]
  267 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle(&SPA_RECTANGLE(width, height)), 0);
      |                                                   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:66:39: note: expanded from macro 'SPA_POD_Rectangle'
   66 | #define SPA_POD_Rectangle(val)                          "R",val
      |                                                             ^~~
../src/shared/ScreencopyShared.cpp:269:73: error: taking the address of a temporary object of type 'struct spa_fraction' [-Waddress-of-temporary]
  269 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&SPA_FRACTION(0, 1)), 0);
      |                                                        ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:71:38: note: expanded from macro 'SPA_POD_Fraction'
   71 | #define SPA_POD_Fraction(val)                           "F",val
      |                                                             ^~~
../src/shared/ScreencopyShared.cpp:270:89: error: taking the address of a temporary object of type 'struct spa_fraction' [-Waddress-of-temporary]
  270 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(framerate, 1), &SPA_FRACTION(1, 1), &SPA_FRACTION(framerate, 1)), 0);
      |                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:73:77: note: expanded from macro 'SPA_POD_CHOICE_RANGE_Fraction'
   73 | #define SPA_POD_CHOICE_RANGE_Fraction(def,min,max)      "?rF", SPA_CHOICE_RANGE((def),(min),(max))
      |                                                                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:27:44: note: expanded from macro 'SPA_CHOICE_RANGE'
   27 | #define SPA_CHOICE_RANGE(def,min,max)                   3,(def),(min),(max)
      |                                                            ^~~
../src/shared/ScreencopyShared.cpp:270:118: error: taking the address of a temporary object of type 'struct spa_fraction' [-Waddress-of-temporary]
  270 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(framerate, 1), &SPA_FRACTION(1, 1), &SPA_FRACTION(framerate, 1)), 0);
      |                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:73:83: note: expanded from macro 'SPA_POD_CHOICE_RANGE_Fraction'
   73 | #define SPA_POD_CHOICE_RANGE_Fraction(def,min,max)      "?rF", SPA_CHOICE_RANGE((def),(min),(max))
      |                                                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:27:50: note: expanded from macro 'SPA_CHOICE_RANGE'
   27 | #define SPA_CHOICE_RANGE(def,min,max)                   3,(def),(min),(max)
      |                                                                  ^~~
../src/shared/ScreencopyShared.cpp:270:139: error: taking the address of a temporary object of type 'struct spa_fraction' [-Waddress-of-temporary]
  270 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(framerate, 1), &SPA_FRACTION(1, 1), &SPA_FRACTION(framerate, 1)), 0);
      |                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:73:89: note: expanded from macro 'SPA_POD_CHOICE_RANGE_Fraction'
   73 | #define SPA_POD_CHOICE_RANGE_Fraction(def,min,max)      "?rF", SPA_CHOICE_RANGE((def),(min),(max))
      |                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/spa-0.2/spa/pod/vararg.h:27:56: note: expanded from macro 'SPA_CHOICE_RANGE'
   27 | #define SPA_CHOICE_RANGE(def,min,max)                   3,(def),(min),(max)
      |                                                                        ^~~
../src/core/PortalManager.cpp:172:5: error: assigning to 'uint16_t *' (aka 'unsigned short *') from incompatible type 'void *'
  172 |     wl_array_for_each(idx, indices) {
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/wayland-util.h:592:22: note: expanded from macro 'wl_array_for_each'
  592 |         for (pos = (array)->data;                                       \
      |                    ~~~~~~~~~^~~~
../src/portals/Screencopy.cpp:785:28: error: cannot initialize a variable of type 'uint64_t *' (aka 'unsigned long *') with an rvalue of type 'void *'
  785 |             uint64_t*      modifiers   = SPA_POD_CHOICE_VALUES(pod_modifier);
      |                            ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/portals/Screencopy.cpp:857:17: error: assigning to 'const spa_pod *' from incompatible type 'void *'
  857 |     params[1] = spa_pod_builder_add_object(&dynBuilder[1].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header), SPA_PARAM_META_size,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  858 |                                            SPA_POD_Int(sizeof(struct spa_meta_header)));
      |                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/builder.h:633:54: note: expanded from macro 'spa_pod_builder_add_object'
  633 | #define spa_pod_builder_add_object(b,type,id,...)                               \
      |                                                                                 ^
  634 | ({                                                                              \
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  635 |         struct spa_pod_builder *_b = (b);                                       \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  636 |         struct spa_pod_frame _f;                                                \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  637 |         spa_pod_builder_push_object(_b, &_f, type, id);                         \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638 |         spa_pod_builder_add(_b, ##__VA_ARGS__, 0);                              \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  639 |         spa_pod_builder_pop(_b, &_f);                                           \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  640 | })
      | ~~
../src/portals/Screencopy.cpp:860:17: error: assigning to 'const spa_pod *' from incompatible type 'void *'
  860 |     params[2] = spa_pod_builder_add_object(&dynBuilder[1].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoTransform),
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  861 |                                            SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_videotransform)));
      |                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/builder.h:633:54: note: expanded from macro 'spa_pod_builder_add_object'
  633 | #define spa_pod_builder_add_object(b,type,id,...)                               \
      |                                                                                 ^
  634 | ({                                                                              \
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  635 |         struct spa_pod_builder *_b = (b);                                       \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  636 |         struct spa_pod_frame _f;                                                \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  637 |         spa_pod_builder_push_object(_b, &_f, type, id);                         \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638 |         spa_pod_builder_add(_b, ##__VA_ARGS__, 0);                              \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  639 |         spa_pod_builder_pop(_b, &_f);                                           \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  640 | })
      | ~~
../src/portals/Screencopy.cpp:863:17: error: assigning to 'const spa_pod *' from incompatible type 'void *'
  863 |     params[3] = spa_pod_builder_add_object(&dynBuilder[2].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoDamage), SPA_PARAM_META_size,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  864 |                                            SPA_POD_CHOICE_RANGE_Int(sizeof(struct spa_meta_region) * 4, sizeof(struct spa_meta_region) * 1, sizeof(struct spa_meta_region) * 4));
      |                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spa-0.2/spa/pod/builder.h:633:54: note: expanded from macro 'spa_pod_builder_add_object'
  633 | #define spa_pod_builder_add_object(b,type,id,...)                               \
      |                                                                                 ^
  634 | ({                                                                              \
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  635 |         struct spa_pod_builder *_b = (b);                                       \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  636 |         struct spa_pod_frame _f;                                                \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  637 |         spa_pod_builder_push_object(_b, &_f, type, id);                         \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638 |         spa_pod_builder_add(_b, ##__VA_ARGS__, 0);                              \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  639 |         spa_pod_builder_pop(_b, &_f);                                           \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  640 | })
      | ~~
vaxerski commented 1 year ago

-Wnoaddress-of-temporary?

jbeich commented 1 year ago

It doesn't help with assigning to .. from incompatible type ... or cannot initialize a variable of type ... with an rvalue of type ....

vaxerski commented 1 year ago

these functions are copied from xdpw, so whatever compile args they use should work here too.

jbeich commented 1 year ago

xdpw is built by C compiler, not C++.

vaxerski commented 1 year ago

well then figuring out how to build with clang is left to you. It builds with gcc, I've never used clang.

igor-ramazanov commented 1 year ago

Yeah, the nix flake appears to be broken:

error: builder for '/nix/store/zaqcs468knh8yxldwiaqd8by6mp3w7np-xdg-desktop-portal-hyprland-1.0.0+date=2023-09-13_8f45a64.drv' failed with exit code 1;
       last 10 log lines:
       >       |                                                                        ^~~
       > ../src/shared/ScreencopyShared.cpp:283:59: note: in expansion of macro 'SPA_POD_CHOICE_RANGE_Fraction'
       >   283 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(framerate, 1), &SPA_FRACTION(1, 1), &SPA_FRACTION(framerate, 1)), 0);
       >       |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > ../src/shared/ScreencopyShared.cpp:283:140: note: in expansion of macro 'SPA_FRACTION'
       >   283 |     spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(framerate, 1), &SPA_FRACTION(1, 1), &SPA_FRACTION(framerate, 1)), 0);
       >       |                                                                                                                                            ^~~~~~~~~~~~
       > [29/32] Compiling C++ object src/xdg-desktop-portal-hyprland.p/core_PortalManager.cpp.o
       > [30/32] Compiling C++ object hyprland-share-picker/hyprland-share-picker.p/main.cpp.o
       > ninja: build stopped: subcommand failed.
       For full logs, run 'nix log /nix/store/zaqcs468knh8yxldwiaqd8by6mp3w7np-xdg-desktop-portal-hyprland-1.0.0+date=2023-09-13_8f45a64.drv'.

The git hash: aca51609d4c415b30e88b96c6f49f0142cbcdae7.

jbeich commented 1 year ago

Builds fine after f9461b0b7d30.