From 34b48d4af610d2aa8ea4bf285871066d0f464d88 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Wed, 8 Nov 2023 00:07:01 -0500 Subject: [PATCH 1/4] python2: fix build with clang 16 on x86_64-darwin Apply the patch to fix using libutil.h instead of util.h on Darwin for `forkpty` and `openpty`. --- pkgs/development/interpreters/python/cpython/2.7/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix index b336caf6a0ad..5cdd307e70fe 100644 --- a/pkgs/development/interpreters/python/cpython/2.7/default.nix +++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix @@ -133,6 +133,11 @@ let ] ++ lib.optionals (x11Support && stdenv.isDarwin) [ ./use-correct-tcl-tk-on-darwin.patch + + ] ++ lib.optionals stdenv.isDarwin [ + # Fix darwin build https://bugs.python.org/issue34027 + ../3.7/darwin-libutil.patch + ] ++ lib.optionals stdenv.isLinux [ # Disable the use of ldconfig in ctypes.util.find_library (since From 3925a35d86afa37405290ba59a42442643b3b69f Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Wed, 8 Nov 2023 18:21:00 -0500 Subject: [PATCH 2/4] lftp: fix build with clang 16 The `configure` script fails to detect several C standard library functions due to not including the required headers. Suppressing the warning about implicit function declarations allows the checks to succeed and lftp build. --- pkgs/tools/networking/lftp/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/tools/networking/lftp/default.nix b/pkgs/tools/networking/lftp/default.nix index aaa26a38c3ae..637214809d41 100644 --- a/pkgs/tools/networking/lftp/default.nix +++ b/pkgs/tools/networking/lftp/default.nix @@ -18,6 +18,11 @@ stdenv.mkDerivation rec { hardeningDisable = lib.optional stdenv.isDarwin "format"; + env = lib.optionalAttrs stdenv.isDarwin { + # Required to build with clang 16 or `configure` will fail to detect several standard functions. + NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration"; + }; + configureFlags = [ "--with-openssl" "--with-readline=${readline.dev}" From 75f32855304ecf6306ee7060bb93c22220a8d202 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Wed, 8 Nov 2023 18:58:03 -0500 Subject: [PATCH 3/4] packcc: fix failing test due to clang 16 Downgrade -Wstrict-prototypes and -Wint-conversion to non-errors, so the code_generation.d test does not fail unexpectedly. --- pkgs/development/tools/packcc/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/tools/packcc/default.nix b/pkgs/development/tools/packcc/default.nix index b16b0491c9b6..4f618665573c 100644 --- a/pkgs/development/tools/packcc/default.nix +++ b/pkgs/development/tools/packcc/default.nix @@ -35,6 +35,8 @@ stdenv.mkDerivation rec { # Disable a failing test. rm -rf ../../tests/style.d + '' + lib.optionalString stdenv.cc.isClang '' + export NIX_CFLAGS_COMPILE+=' -Wno-error=strict-prototypes -Wno-error=int-conversion' ''; installPhase = '' From 1cd0d4b62d60ef2aa1b7daa583eec275c750acf7 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Wed, 8 Nov 2023 17:48:06 -0500 Subject: [PATCH 4/4] resholve: fix build of oil-pyyajl with clang 16 Fixes several incompatible function pointer conversion errors by updating the function definitions and casts. --- ...patible_function_pointer_conversions.patch | 42 +++++++++++++++++++ pkgs/development/misc/resholve/oildev.nix | 4 ++ 2 files changed, 46 insertions(+) create mode 100644 pkgs/development/misc/resholve/0014-clang_incompatible_function_pointer_conversions.patch diff --git a/pkgs/development/misc/resholve/0014-clang_incompatible_function_pointer_conversions.patch b/pkgs/development/misc/resholve/0014-clang_incompatible_function_pointer_conversions.patch new file mode 100644 index 000000000000..52d5e6adfe74 --- /dev/null +++ b/pkgs/development/misc/resholve/0014-clang_incompatible_function_pointer_conversions.patch @@ -0,0 +1,42 @@ +diff -ur a/decoder.c b/decoder.c +--- a/decoder.c 1980-01-02 00:00:00.000000000 -0500 ++++ b/decoder.c 2023-11-08 17:42:43.981838074 -0500 +@@ -94,7 +94,7 @@ + return PlaceObject(ctx, PyBool_FromLong((long)(value))); + } + +-static int handle_number(void *ctx, const char *value, unsigned int length) ++static int handle_number(void *ctx, const char *value, size_t length) + { + //fprintf(stderr, "handle_number: "); + //fwrite(value, length, 1, stderr); +@@ -127,7 +127,7 @@ + return status; + } + +-static int handle_string(void *ctx, const unsigned char *value, unsigned int length) ++static int handle_string(void *ctx, const unsigned char *value, size_t length) + { + return PlaceObject(ctx, PyString_FromStringAndSize((char *)value, length)); + } +@@ -142,7 +142,7 @@ + return success; + } + +-static int handle_dict_key(void *ctx, const unsigned char *value, unsigned int length) ++static int handle_dict_key(void *ctx, const unsigned char *value, size_t length) + { + PyObject *object = PyString_FromStringAndSize((const char *) value, length); + +diff -ur a/yajl.c b/yajl.c +--- a/yajl.c 1980-01-02 00:00:00.000000000 -0500 ++++ b/yajl.c 2023-11-08 17:41:18.781350335 -0500 +@@ -161,7 +161,7 @@ + } + + static struct PyMethodDef yajl_methods[] = { +- {"dumps", (PyCFunctionWithKeywords)(py_dumps), METH_VARARGS | METH_KEYWORDS, ++ {"dumps", (PyCFunction)(py_dumps), METH_VARARGS | METH_KEYWORDS, + "yajl.dumps(obj [, indent=None])\n\n\ + Returns an encoded JSON string of the specified `obj`\n\ + \n\ diff --git a/pkgs/development/misc/resholve/oildev.nix b/pkgs/development/misc/resholve/oildev.nix index 3e7dbc8e0108..2459c492ebc0 100644 --- a/pkgs/development/misc/resholve/oildev.nix +++ b/pkgs/development/misc/resholve/oildev.nix @@ -42,6 +42,10 @@ rec { hash = "sha256-H3GKN0Pq1VFD5+SWxm8CXUVO7zAyj/ngKVmDaG/aRT4="; fetchSubmodules = true; }; + patches = [ + # Fixes several incompatible function pointer conversions, which are errors in clang 16. + ./0014-clang_incompatible_function_pointer_conversions.patch + ]; # just for submodule IIRC nativeBuildInputs = [ git ]; };