cogl-cpu-caps.c and cogl-buffer.c fail to compile with clang on ARM64
Affected version
commit 3a94822e from origin/main
Bug summary
Compilation fails with clang-17.0.6 on at least cogl-buffer.c and cogl-cpu-caps.c. Unrelatedly there's also lots of compiler warnings, which might be of interest (lots from -Wcast-align
and more)
Steps to reproduce
CXX=clang++ AR=llvm-ar RANLIB=llvm-ranlib OBJCOPY=llvm-objcopy CC=clang CFLAGS="-O3 -pipe -fno-omit-frame-pointer -fdebug-default-version=4 -gdwarf-4" meson setup build -Dlibwacom=false
ninja -C build
What happened
Build failed on ARM64 (Apple M2, Gentoo)
What did you expect to happen
Successful compilation like in origin/gnome-45
branch
Relevant logs, screenshots, screencasts etc.
[36/1687] Compiling C object cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-buffer.c.o
FAILED: cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-buffer.c.o
clang -Icogl/cogl/libmutter-cogl-13.so.0.0.0.p -Icogl/cogl -I../cogl/cogl -Imtk -I../mtk -Imtk/mtk -I../mtk/mtk -Icogl -I../cogl -I. -I.. -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/gio-unix-2.0 -I/usr/include/libmount -I/usr/include/blkid -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/pixman-1 -I/usr/include/libpng16 -fvisibility=hidden -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -D_GNU_SOURCE -fno-strict-aliasing -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wundef -Wunused -Wcast-align -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-include-dirs -Wignored-qualifiers -Werror=redundant-decls -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=empty-body -Werror=write-strings -Werror=strict-aliasing -Wno-sign-compare -Wno-cast-function-type -Wno-unused-parameter -Wno-missing-field-initializers -Wno-type-limits -DG_ENABLE_DEBUG -fno-omit-frame-pointer -O3 -pipe -fno-omit-frame-pointer -fdebug-default-version=4 -gdwarf-4 -fPIC -pthread '-DCOGL_LOCALEDIR="/usr/local/share/locale"' -DCOGL_COMPILATION '-DCOGL_GL_LIBNAME="libGL.so.1"' '-DCOGL_GLES2_LIBNAME="libGLESv2.so.2"' -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_ENABLE_DEBUG -fno-omit-frame-pointer -MD -MQ cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-buffer.c.o -MF cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-buffer.c.o.d -o cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-buffer.c.o -c ../cogl/cogl/cogl-buffer.c
../cogl/cogl/cogl-buffer.c:135:7: error: expected expression
135 | gboolean use_malloc = FALSE;
| ^
../cogl/cogl/cogl-buffer.c:141:13: error: use of undeclared identifier 'use_malloc'
141 | use_malloc = TRUE;
| ^
../cogl/cogl/cogl-buffer.c:144:11: error: use of undeclared identifier 'use_malloc'; did you mean 'g_malloc'?
144 | if (use_malloc)
| ^~~~~~~~~~
| g_malloc
/usr/include/glib-2.0/glib/gmem.h:84:10: note: 'g_malloc' declared here
84 | gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
| ^
3 errors generated.
[42/1687] Compiling C object cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-cpu-caps.c.o
FAILED: cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-cpu-caps.c.o
clang -Icogl/cogl/libmutter-cogl-13.so.0.0.0.p -Icogl/cogl -I../cogl/cogl -Imtk -I../mtk -Imtk/mtk -I../mtk/mtk -Icogl -I../cogl -I. -I.. -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/gio-unix-2.0 -I/usr/include/libmount -I/usr/include/blkid -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/pixman-1 -I/usr/include/libpng16 -fvisibility=hidden -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -D_GNU_SOURCE -fno-strict-aliasing -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wundef -Wunused -Wcast-align -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-include-dirs -Wignored-qualifiers -Werror=redundant-decls -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=empty-body -Werror=write-strings -Werror=strict-aliasing -Wno-sign-compare -Wno-cast-function-type -Wno-unused-parameter -Wno-missing-field-initializers -Wno-type-limits -DG_ENABLE_DEBUG -fno-omit-frame-pointer -O3 -pipe -fno-omit-frame-pointer -fdebug-default-version=4 -gdwarf-4 -fPIC -pthread '-DCOGL_LOCALEDIR="/usr/local/share/locale"' -DCOGL_COMPILATION '-DCOGL_GL_LIBNAME="libGL.so.1"' '-DCOGL_GLES2_LIBNAME="libGLESv2.so.2"' -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_ENABLE_DEBUG -fno-omit-frame-pointer -MD -MQ cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-cpu-caps.c.o -MF cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-cpu-caps.c.o.d -o cogl/cogl/libmutter-cogl-13.so.0.0.0.p/cogl-cpu-caps.c.o -c ../cogl/cogl/cogl-cpu-caps.c
../cogl/cogl/cogl-cpu-caps.c:50:7: error: invalid output constraint '=a' in asm
50 | : "=a"(eax),
| ^
1 error generated.
The use_malloc case is somewhat obvious - it's not allowed to make a new variable in a case branch without a new block or something. No immediate idea about the asm myself though :(
Edited by Mart Raudsepp