linuxmint / muffin

The window management library for the Cinnamon desktop (libmuffin) and its sample WM binary (muffin)
GNU General Public License v2.0
197 stars 93 forks source link

Fails to Compile with GCC14 - muffin-6.0.1/src/core/prefs.c:2261:32: error: passing argument 1 of ‘g_strdupv’ from incompatible pointer type [-Wincompatible-pointer-types] #687

Closed immolo closed 9 months ago

immolo commented 9 months ago

Distribution

Gentoo

Package version

6.0.1

Graphics hardware in use

Nvidia GTX 970

Frequency

Always

Bug description

GCC14 release brings stricter defaults when compiling as part of enforcing C99 standards. Please see https://wiki.gentoo.org/wiki/Modern_C_porting for more information.

Error:

FAILED: src/libmuffin.so.0.0.0.p/core_prefs.c.o 
x86_64-pc-linux-gnu-gcc -Isrc/libmuffin.so.0.0.0.p -Isrc -I../muffin-6.0.1/src -I. -I../muffin-6.0.1 -Iclutter -I../muffin-6.0.1/clutter -Iclutter/clutter -I../muffin-6.0.1/clutter/clutter -Icogl -I../muffin-6.0.1/cogl -Icogl/cogl -I../muffin-6.0.1/cogl/cogl -Isrc/meta -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/atk-1.0 -I/usr/include/gio-unix-2.0 -I/usr/include/json-glib-1.0 -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/cinnamon-desktop -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/elogind -I/usr/include/gudev-1.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gobject-introspection-1.0 -I/usr/include/uuid -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -D_GNU_SOURCE -O2 -pipe -fPIC -D_REENTRANT -pthread -mfpmath=sse -msse -msse2 -DCLUTTER_ENABLE_COMPOSITOR_API -DCLUTTER_ENABLE_EXPERIMENTAL_API -DCOGL_ENABLE_EXPERIMENTAL_API -DCOGL_ENABLE_EXPERIMENTAL_2_0_API -DCOGL_ENABLE_MUTTER_API -DCLUTTER_DISABLE_DEPRECATION_WARNINGS -DCOGL_DISABLE_DEPRECATION_WARNINGS '-DG_LOG_DOMAIN="mutter"' -DSN_API_NOT_YET_FROZEN=1 '-DGETTEXT_PACKAGE="muffin"' -DWITH_VERBOSE_MODE -MD -MQ src/libmuffin.so.0.0.0.p/core_prefs.c.o -MF src/libmuffin.so.0.0.0.p/core_prefs.c.o.d -o src/libmuffin.so.0.0.0.p/core_prefs.c.o -c ../muffin-6.0.1/src/core/prefs.c
../muffin-6.0.1/src/core/prefs.c: In function ‘meta_preference_to_string’:
../muffin-6.0.1/src/core/prefs.c:1839:3: warning: enumeration value ‘META_PREF_BACKGROUND_TRANSITION’ not handled in switch [-Wswitch]
 1839 |   switch (pref)
      |   ^~~~~~
../muffin-6.0.1/src/core/prefs.c:1839:3: warning: enumeration value ‘META_PREF_INVERT_WORKSPACE_FLIP_DIRECTION’ not handled in switch [-Wswitch]
../muffin-6.0.1/src/core/prefs.c: In function ‘init_bindings’:
../muffin-6.0.1/src/core/prefs.c:2012:16: warning: unused variable ‘pref’ [-Wunused-variable]
 2012 |   MetaKeyPref *pref;
      |                ^~~~
../muffin-6.0.1/src/core/prefs.c: In function ‘meta_prefs_add_keybinding’:
../muffin-6.0.1/src/core/prefs.c:2261:32: error: passing argument 1 of ‘g_strdupv’ from incompatible pointer type [-Wincompatible-pointer-types]
 2261 |           strokes = g_strdupv (bindings);
      |                                ^~~~~~~~
      |                                |
      |                                const gchar ** {aka const char **}
In file included from /usr/include/glib-2.0/glib/gstring.h:37,
                 from /usr/include/glib-2.0/glib/giochannel.h:36,
                 from /usr/include/glib-2.0/glib.h:56,
                 from ../muffin-6.0.1/src/core/prefs.c:31:
/usr/include/glib-2.0/glib/gstrfuncs.h:381:55: note: expected ‘gchar **’ {aka ‘char **’} but argument is of type ‘const gchar **’ {aka ‘const char **’}
  381 | gchar**               g_strdupv        (gchar       **str_array);
      |                                         ~~~~~~~~~~~~~~^~~~~~~~~

Full build log: muffin-6.0.1.build.log.txt

Steps to reproduce

This can be reproduced with either adding GCC14 to your system to compile or adding the CFLAGS -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types to an earlier version of GCC.

See https://wiki.gentoo.org/wiki/Modern_C_porting#How_do_I_reproduce_these_bugs.3F

Expected behavior

Successful compile.

Additional information

Linked Gentoo bug (previous version same error): https://bugs.gentoo.org/919091

mtwebster commented 9 months ago

already fixed: https://github.com/linuxmint/muffin/commit/38919a88b2b8381f5b24b69742d1b9db32029c61

immolo commented 9 months ago

Ah sorry, I couldn't find that in a search. just out of curiosity should this have already made it into the 6.0.1 or is it planned in the .2?

mtwebster commented 9 months ago

No, there hasn't been a new version yet. This type of thing isn't normally something we'd do a point release for, but if we end up needing to publish a bugfix at some point, it'll probably end up getting included.

By the way, you can usually tell if a commit has made it into a release yet by looking at the annotations below the commit message: image

In this example the commit is in 6.0.1 but nothing earlier.

immolo commented 9 months ago

Thanks for your help, I'll remember this tip in future as well.

eli-schwartz commented 5 months ago

Unfortunately this doesn't even begin to solve the problem. :(

I still get these errors:

[32/59] x86_64-pc-linux-gnu-gcc -Iclutter/clutter/libmuffin-clutter-0.so.0.0.0.p -Iclutter/clutter -I../muffin-6.0.1/clutter/clutter -Iclutter -I../muffin-6.0.1/clutter -Icogl -I../muffin-6.0.1/cogl -Icogl/cogl -I../muffin-6.0.1/cogl/cogl -I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/cairo -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/pixman-1 -I/usr/include/gio-unix-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/json-glib-1.0 -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -fvisibility=hidden -flto=4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -D_GNU_SOURCE -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -fPIC -mfpmath=sse -msse -msse2 -pthread '-DCLUTTER_SYSCONFDIR="/etc"' -DCLUTTER_COMPILATION=1 -DCOGL_DISABLE_DEPRECATION_WARNINGS '-DG_LOG_DOMAIN="Clutter"' -MD -MQ clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-paint-node.c.o -MF clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-paint-node.c.o.d -o clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-paint-node.c.o -c ../muffin-6.0.1/clutter/clutter/clutter-paint-node.c
FAILED: clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-paint-node.c.o 
x86_64-pc-linux-gnu-gcc -Iclutter/clutter/libmuffin-clutter-0.so.0.0.0.p -Iclutter/clutter -I../muffin-6.0.1/clutter/clutter -Iclutter -I../muffin-6.0.1/clutter -Icogl -I../muffin-6.0.1/cogl -Icogl/cogl -I../muffin-6.0.1/cogl/cogl -I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/cairo -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/pixman-1 -I/usr/include/gio-unix-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/json-glib-1.0 -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -fvisibility=hidden -flto=4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -D_GNU_SOURCE -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -fPIC -mfpmath=sse -msse -msse2 -pthread '-DCLUTTER_SYSCONFDIR="/etc"' -DCLUTTER_COMPILATION=1 -DCOGL_DISABLE_DEPRECATION_WARNINGS '-DG_LOG_DOMAIN="Clutter"' -MD -MQ clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-paint-node.c.o -MF clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-paint-node.c.o.d -o clutter/clutter/libmuffin-clutter-0.so.0.0.0.p/clutter-paint-node.c.o -c ../muffin-6.0.1/clutter/clutter/clutter-paint-node.c
In file included from /usr/include/glib-2.0/glib/gthread.h:34,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:34,
                 from /usr/include/glib-2.0/glib.h:34,
                 from /usr/include/glib-2.0/gobject/gbinding.h:30,
                 from /usr/include/glib-2.0/glib-object.h:24,
                 from /usr/include/pango-1.0/pango/pango-coverage.h:25,
                 from /usr/include/pango-1.0/pango/pango-font.h:25,
                 from /usr/include/pango-1.0/pango/pango-attributes.h:25,
                 from /usr/include/pango-1.0/pango/pango.h:25,
                 from ../muffin-6.0.1/clutter/clutter/clutter-paint-node.c:65:
../muffin-6.0.1/clutter/clutter/clutter-paint-node.c: In function ‘clutter_paint_node_get_type’:
/usr/include/glib-2.0/glib/gatomic.h:131:5: error: argument 2 of ‘__atomic_load’ discards ‘volatile’ qualifier [-Werror=incompatible-pointer-types]
  131 |     __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
      |     ^~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gthread.h:262:7: note: in expansion of macro ‘g_atomic_pointer_get’
  262 |     (!g_atomic_pointer_get (location) &&                             \
      |       ^~~~~~~~~~~~~~~~~~~~
../muffin-6.0.1/clutter/clutter/clutter-paint-node.c:241:7: note: in expansion of macro ‘g_once_init_enter’
  241 |   if (g_once_init_enter (&paint_node_type_id__volatile))
      |       ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

ad nauseam. The actual number of such errors is so big I'm afraid to post them all inline. I'll upload a build log instead.

build.log

leigh123linux commented 5 months ago

@eli-schwartz Does gentoo enable some insane gcc defaults for gcc?

-Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types

leigh123linux commented 5 months ago

I can't reproduce the compile error using the same flags

[32/711] gcc -Icogl/cogl/libmuffin-cogl-0.so.0.0.0.p -Icogl/cogl -I../cogl/cogl -Icogl -I../cogl -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-6 -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/libxml2 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/webp -I/usr/include/libmount -I/usr/include/blkid -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -D_GNU_SOURCE -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -fPIC -pthread -DWITH_GZFILEOP -mfpmath=sse -msse -msse2 '-DCOGL_LOCALEDIR="/usr/share/locale"' -DCOGL_COMPILATION '-DCOGL_GL_LIBNAME="libGL.so.1"' '-DCOGL_GLES2_LIBNAME="libGLESv2.so.2"' -MD -MQ cogl/cogl/libmuffin-cogl-0.so.0.0.0.p/cogl-object.c.o -MF cogl/cogl/libmuffin-cogl-0.so.0.0.0.p/cogl-object.c.o.d -o cogl/cogl/libmuffin-cogl-0.so.0.0.0.p/cogl-object.c.o -c ../cogl/cogl/cogl-object.c
In file included from /usr/include/glib-2.0/glib/gthread.h:34,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:34,
                 from /usr/include/glib-2.0/glib.h:34,
                 from ../cogl/cogl/cogl-object.c:34:
../cogl/cogl/cogl-object.c: In function ‘cogl_object_get_gtype’:
/usr/include/glib-2.0/glib/gatomic.h:131:5: warning: argument 2 of ‘__atomic_load’ discards ‘volatile’ qualifier [-Wdiscarded-qualifiers]
  131 |     __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
      |     ^~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gthread.h:272:7: note: in expansion of macro ‘g_atomic_pointer_get’
  272 |     (!g_atomic_pointer_get (location) &&                             \
      |       ^~~~~~~~~~~~~~~~~~~~
../cogl/cogl/cogl-gtype-private.h:93:7: note: in expansion of macro ‘g_once_init_enter’
   93 |   if (g_once_init_enter (&type_id__volatile))                           \
      |       ^~~~~~~~~~~~~~~~~
../cogl/cogl/cogl-gtype-private.h:137:3: note: in expansion of macro ‘_COGL_GTYPE_DEFINE_BASE_CLASS_BEGIN’
  137 |   _COGL_GTYPE_DEFINE_BASE_CLASS_BEGIN(Name,name)         \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../cogl/cogl/cogl-object.c:42:1: note: in expansion of macro ‘COGL_GTYPE_DEFINE_BASE_CLASS’
   42 | COGL_GTYPE_DEFINE_BASE_CLASS (Object, object);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[33/711]
gcc version 14.1.1 20240522 (Red Hat 14.1.1-4) (GCC)
eli-schwartz commented 5 months ago

Gentoo doesn't enable anything, I enabled those myself since they all detect actual bugs.

There are three groups of flags I'm using there (and :

You'll notice in my logs, meson reports that GCC is GCC 13. The important thing is I added -Werror=incompatible-pointer-types, and it errors out.

You get the same warning, except on GCC 14 it isn't an error after all, even though that warning was switched to a default error...

Because it shows -Wdiscarded-qualifiers instead.

It turns out this is a GCC bug reporting the wrong warning, fixed in GCC 14 (so muffin will never actually error out with stock flags after all). Sorry for the confusion.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113050