dmedvinsky / gsimplecal

Simple and lightweight GTK calendar (BSD license)
http://dmedvinsky.github.io/gsimplecal
Other
198 stars 19 forks source link

[2.4.1] build failure with musl (gentoo) (works with glibc) #50

Closed jeandestouches closed 1 year ago

jeandestouches commented 1 year ago

Hi, I'm trying to build gsimplecal 2.4.1 on gentoo musl (with glibc, it compiles fine) but it fails with this error :

MainWindow.cpp:166:33: error: invalid cast from type 'std::nullptr_t' to type 'GtkAccelFlags'

system is x86-64, musl version 1.2.3, gcc 12.2.1

Full build log :

./configure --prefix=/usr --build=x86_64-gentoo-linux-musl --host=x86_64-gentoo-linux-musl --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --disable-silent-rules --docdir=/usr/share/doc/gsimplecal-2.4.1 --htmldir=/usr/share/doc/gsimplecal-2.4.1/html --libdir=/usr/lib
checking for a BSD-compatible install... /usr/lib/portage/python3.10/ebuild-helpers/xattr/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for x86_64-gentoo-linux-musl-g++... x86_64-gentoo-linux-musl-g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether x86_64-gentoo-linux-musl-g++ accepts -g... yes
checking for x86_64-gentoo-linux-musl-g++ option to enable C++11 features... none needed
checking whether make supports the include directive... yes (GNU style)
checking dependency style of x86_64-gentoo-linux-musl-g++... none
checking for x86_64-gentoo-linux-musl-pkg-config... /usr/bin/x86_64-gentoo-linux-musl-pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GTK... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for iostream... yes
checking for string... yes
checking for sstream... yes
checking for fstream... yes
checking for vector... yes
checking for cstdlib... yes
checking for stdlib.h... (cached) yes
checking for sys/time.h... yes
checking for sys/types.h... (cached) yes
checking for sys/ipc.h... yes
checking for sys/sem.h... yes
checking for sys/sysctl.h... no
checking for signal.h... yes
checking for limits.h... yes
checking for atexit... yes
checking for execl... yes
checking for fork... yes
checking for ftok... yes
checking for getexecname... no
checking for gettimeofday... yes
checking for kill... yes
checking for readlink... yes
checking for semctl... yes
checking for semget... yes
checking for setenv... yes
checking for signal... yes
checking for strlcpy... yes
checking for sysctl... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating src/config.h
config.status: executing depfiles commands
>>> Source configured.
>>> Compiling source in /var/tmp/portage/x11-misc/gsimplecal-2.4.1/work/gsimplecal-2.4.1 ...
make -j5 
Making all in src
make[1]: Entering directory '/var/tmp/portage/x11-misc/gsimplecal-2.4.1/work/gsimplecal-2.4.1/src'
make  all-am
make[2]: Entering directory '/var/tmp/portage/x11-misc/gsimplecal-2.4.1/work/gsimplecal-2.4.1/src'
x86_64-gentoo-linux-musl-g++ -DHAVE_CONFIG_H -I.  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -pthread    -march=core2 -O2 -pipe -c -o Boxable.o Boxable.cpp
x86_64-gentoo-linux-musl-g++ -DHAVE_CONFIG_H -I.  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -pthread    -march=core2 -O2 -pipe -c -o Calendar.o Calendar.cpp
x86_64-gentoo-linux-musl-g++ -DHAVE_CONFIG_H -I.  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -pthread    -march=core2 -O2 -pipe -c -o Clock.o Clock.cpp
x86_64-gentoo-linux-musl-g++ -DHAVE_CONFIG_H -I.  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -pthread    -march=core2 -O2 -pipe -c -o Config.o Config.cpp
x86_64-gentoo-linux-musl-g++ -DHAVE_CONFIG_H -I.  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -pthread    -march=core2 -O2 -pipe -c -o gsimplecal.o gsimplecal.cpp
x86_64-gentoo-linux-musl-g++ -DHAVE_CONFIG_H -I.  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -pthread    -march=core2 -O2 -pipe -c -o MainWindow.o MainWindow.cpp
x86_64-gentoo-linux-musl-g++ -DHAVE_CONFIG_H -I.  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -pthread    -march=core2 -O2 -pipe -c -o Timezones.o Timezones.cpp
x86_64-gentoo-linux-musl-g++ -DHAVE_CONFIG_H -I.  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -pthread    -march=core2 -O2 -pipe -c -o Unique.o Unique.cpp
MainWindow.cpp: In constructor 'MainWindow::MainWindow()':
MainWindow.cpp:166:33: error: invalid cast from type 'std::nullptr_t' to type 'GtkAccelFlags'
  166 |                                 (GtkAccelFlags)NULL, closure);
      |                                 ^
make[2]: *** [Makefile:414: MainWindow.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/var/tmp/portage/x11-misc/gsimplecal-2.4.1/work/gsimplecal-2.4.1/src'
make[1]: *** [Makefile:293: all] Error 2
make[1]: Leaving directory '/var/tmp/portage/x11-misc/gsimplecal-2.4.1/work/gsimplecal-2.4.1/src'
make: *** [Makefile:340: all-recursive] Error 1

It would be great to be able to compile gsimplecal with musl for a lightweight calendar on a minimal X system. The only alternative being orage, but it is quite old and deprecated by gentoo.

Thanks!

dmedvinsky commented 1 year ago

It would be great to get a patch. Because it's way too hard to reproduce the environment for me at the moment.

jeandestouches commented 1 year ago

After asking for help on gentoo forums, it turns out the error is caused by a change in musl 1.2.3 : https://bugs.gentoo.org/839975 A simple fix was to replace the NULL value to 0 :

index 02eca42..323d5db 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -163,7 +163,7 @@ MainWindow::MainWindow()
         closure = g_cclosure_new(G_CALLBACK(keys[key].func), (gpointer)this, NULL);
         gtk_accel_group_connect(accelerators, keys[key].key,
                                 (GdkModifierType)keys[key].modifier,
-                                (GtkAccelFlags)NULL, closure);
+                                (GtkAccelFlags)0, closure);
         g_closure_unref(closure);
     }

This is not needed if compiled with glibc obviously, although it still compiles without error using glibc with the small change applied. I just tried just in case. Thanks for reading.