From 1a2c0b89c6b322ad62fe16ad2e9b450880662f72 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 3 Nov 2023 13:37:27 -0400 Subject: [PATCH 1/4] perlPackages.Gtk2: fix build with clang 16 Fix pointer casts to 32-bit integers. --- ...-fix-incompatible-pointer-conversion.patch | 86 +++++++++++++++++++ pkgs/top-level/perl-packages.nix | 4 + 2 files changed, 90 insertions(+) create mode 100644 pkgs/development/perl-modules/Gtk2-fix-incompatible-pointer-conversion.patch diff --git a/pkgs/development/perl-modules/Gtk2-fix-incompatible-pointer-conversion.patch b/pkgs/development/perl-modules/Gtk2-fix-incompatible-pointer-conversion.patch new file mode 100644 index 000000000000..1ac68ee19d01 --- /dev/null +++ b/pkgs/development/perl-modules/Gtk2-fix-incompatible-pointer-conversion.patch @@ -0,0 +1,86 @@ +diff -ur a/gdk.typemap b/gdk.typemap +--- a/gdk.typemap 2017-05-21 15:02:54.000000000 -0400 ++++ b/gdk.typemap 2023-11-03 13:17:43.717890172 -0400 +@@ -23,6 +23,7 @@ + TYPEMAP + + # can be either a pointer or an integer, this handles both cases ++uintptr_t T_UV + GdkNativeWindow T_UV + + # GdkBitmap doesn't get its own type id, but needs to be treated separately. +diff -ur a/xs/GdkDnd.xs b/xs/GdkDnd.xs +--- a/xs/GdkDnd.xs 2017-05-21 15:02:54.000000000 -0400 ++++ b/xs/GdkDnd.xs 2023-11-03 13:23:22.478329089 -0400 +@@ -142,12 +142,12 @@ + void + gdk_drag_get_protocol_for_display (class, display, xid) + GdkDisplay *display +- guint32 xid ++ uintptr_t xid + PREINIT: + GdkDragProtocol protocol; +- guint32 ret; ++ uintptr_t ret; + PPCODE: +- ret = gdk_drag_get_protocol_for_display (display, xid, &protocol); ++ ret = (uintptr_t)gdk_drag_get_protocol_for_display (display, INT2PTR(GdkNativeWindow, xid), &protocol); + XPUSHs (sv_2mortal (newSVuv (ret))); + XPUSHs (sv_2mortal (ret + ? newSVGdkDragProtocol (protocol) +@@ -184,12 +184,12 @@ + =cut + void + gdk_drag_get_protocol (class, xid) +- guint32 xid ++ uintptr_t xid + PREINIT: + GdkDragProtocol protocol; +- guint32 ret; ++ uintptr_t ret; + PPCODE: +- ret = gdk_drag_get_protocol (xid, &protocol); ++ ret = (uintptr_t)gdk_drag_get_protocol (INT2PTR(GdkNativeWindow, xid), &protocol); + XPUSHs (sv_2mortal (newSVuv (ret))); + XPUSHs (sv_2mortal (newSVGdkDragProtocol (protocol))); + +diff -ur a/xs/GdkSelection.xs b/xs/GdkSelection.xs +--- a/xs/GdkSelection.xs 2017-05-21 15:02:54.000000000 -0400 ++++ b/xs/GdkSelection.xs 2023-11-03 13:26:58.976888906 -0400 +@@ -147,7 +147,7 @@ + ## void gdk_selection_send_notify (guint32 requestor, GdkAtom selection, GdkAtom target, GdkAtom property, guint32 time_) + void + gdk_selection_send_notify (class, requestor, selection, target, property, time_) +- guint32 requestor ++ GdkNativeWindow requestor + GdkAtom selection + GdkAtom target + GdkAtom property +@@ -161,7 +161,7 @@ + void + gdk_selection_send_notify_for_display (class, display, requestor, selection, target, property, time_) + GdkDisplay *display +- guint32 requestor ++ GdkNativeWindow requestor + GdkAtom selection + GdkAtom target + GdkAtom property +diff -ur a/xs/GtkWindow.xs b/xs/GtkWindow.xs +--- a/xs/GtkWindow.xs 2017-05-21 15:02:54.000000000 -0400 ++++ b/xs/GtkWindow.xs 2023-11-03 13:32:53.673168678 -0400 +@@ -581,13 +581,13 @@ + void + gtk_window_remove_embedded_xid (window, xid) + GtkWindow * window +- guint xid ++ GdkNativeWindow xid + + ## void gtk_window_add_embedded_xid (GtkWindow *window, guint xid) + void + gtk_window_add_embedded_xid (window, xid) + GtkWindow * window +- guint xid ++ GdkNativeWindow xid + + ##void gtk_window_reshow_with_initial_size (GtkWindow *window) + void diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix index 75e64329dd44..eb3c43befe74 100644 --- a/pkgs/top-level/perl-packages.nix +++ b/pkgs/top-level/perl-packages.nix @@ -11121,6 +11121,10 @@ with self; { url = "mirror://cpan/authors/id/X/XA/XAOC/Gtk2-1.24993.tar.gz"; hash = "sha256-ScRDdDsu7+EadoACck9/akxI78lP8806VZ+357aTyWc="; }; + patches = [ + # Fix incompatible function pointer conversion (assigning `GdkNativeWindow` to `guint32`). + ../development/perl-modules/Gtk2-fix-incompatible-pointer-conversion.patch + ]; buildInputs = [ pkgs.gtk2 ]; # https://rt.cpan.org/Public/Bug/Display.html?id=130742 # doCheck = !stdenv.isDarwin; From 80fc3eb8a63408474af1a492f8364d4b430d3799 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 3 Nov 2023 12:41:23 -0400 Subject: [PATCH 2/4] scheme48: fix build with clang 16 --- pkgs/development/interpreters/scheme48/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/interpreters/scheme48/default.nix b/pkgs/development/interpreters/scheme48/default.nix index 7a4178d82b15..82bd58469bd3 100644 --- a/pkgs/development/interpreters/scheme48/default.nix +++ b/pkgs/development/interpreters/scheme48/default.nix @@ -14,6 +14,15 @@ stdenv.mkDerivation rec { substituteInPlace build/build-usual-image --replace '"(made by $USER on $date)"' '""' ''; + # Silence warnings related to use of implicitly declared library functions and implicit ints. + # TODO: Remove and/or fix with patches the next time this package is updated. + env = lib.optionalAttrs stdenv.cc.isClang { + NIX_CFLAGS_COMPILE = toString [ + "-Wno-error=implicit-function-declaration" + "-Wno-error=implicit-int" + ]; + }; + meta = with lib; { homepage = "https://s48.org/"; description = "Scheme 48 interpreter for R5RS"; From ed24081baa569f319e2055c1eba9fd093b109493 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 3 Nov 2023 12:32:07 -0400 Subject: [PATCH 3/4] smpeg: fix build with clang 16 Apply upstream patches to remove usage of the `register` storage class specifier, which was removed from C++17 (the default with clang 16). --- pkgs/development/libraries/smpeg/default.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/smpeg/default.nix b/pkgs/development/libraries/smpeg/default.nix index f25ac14df864..099a3d838bbb 100644 --- a/pkgs/development/libraries/smpeg/default.nix +++ b/pkgs/development/libraries/smpeg/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, SDL, autoconf, automake, libtool, gtk2, m4, pkg-config, libGLU, libGL, makeWrapper }: +{ lib, stdenv, fetchFromGitHub, fetchpatch, SDL, autoconf, automake, libtool, gtk2, m4, pkg-config, libGLU, libGL, makeWrapper }: stdenv.mkDerivation rec { pname = "smpeg"; @@ -16,8 +16,24 @@ stdenv.mkDerivation rec { ./gcc6.patch ./libx11.patch ./gtk.patch + # These patches remove use of the `register` storage class specifier, + # allowing smpeg to build with clang 16, which defaults to C++17. + (fetchpatch { + url = "https://github.com/icculus/smpeg/commit/cc114ba0dd8644c0d6205bbce2384781daeff44b.patch"; + hash = "sha256-GxSD82j05pw0r2SxmPYAe/BXX4iUc+iHWhB9Ap4GzfA="; + }) + (fetchpatch { + url = "https://github.com/icculus/smpeg/commit/b369feca5bf99d6cff50d8eb316395ef48acf24f.patch"; + hash = "sha256-U+a6dbc5cm249KlUcf4vi79yUiT4hgEvMv522K4PqUc="; + }) ]; + postPatch = '' + substituteInPlace video/gdith.cpp \ + --replace 'register int' 'int' \ + --replace 'register Uint16' 'Uint16' + ''; + enableParallelBuilding = true; nativeBuildInputs = [ autoconf automake libtool m4 pkg-config makeWrapper ]; From 5b3a14283713b87b782b46d0f518b8c8831bc649 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 3 Nov 2023 13:37:10 -0400 Subject: [PATCH 4/4] stfl: fix build with clang 16 --- pkgs/development/libraries/stfl/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/libraries/stfl/default.nix b/pkgs/development/libraries/stfl/default.nix index 845e815be590..e848b4330955 100644 --- a/pkgs/development/libraries/stfl/default.nix +++ b/pkgs/development/libraries/stfl/default.nix @@ -13,6 +13,15 @@ stdenv.mkDerivation rec { buildInputs = [ ncurses libiconv ]; + # Silence warnings related to use of implicitly declared library functions and implicit ints. + # TODO: Remove and/or fix with patches the next time this package is updated. + env = lib.optionalAttrs stdenv.cc.isClang { + NIX_CFLAGS_COMPILE = toString [ + "-Wno-error=implicit-function-declaration" + "-Wno-error=implicit-int" + ]; + }; + preBuild = '' sed -i s/gcc/cc/g Makefile sed -i s%ncursesw/ncurses.h%ncurses.h% stfl_internals.h