varnish: fix builds of varnish, varnish77, and varnish60 on macOS (#416291)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
lib,
|
||||
stdenv,
|
||||
fetchurl,
|
||||
fetchpatch2,
|
||||
pcre,
|
||||
pcre2,
|
||||
jemalloc,
|
||||
@@ -56,6 +57,24 @@ let
|
||||
|
||||
buildFlags = [ "localstatedir=/var/run" ];
|
||||
|
||||
patches =
|
||||
lib.optionals (stdenv.isDarwin && lib.versionAtLeast version "7.7") [
|
||||
# Fix VMOD section attribute on macOS
|
||||
# Unreleased commit on master
|
||||
(fetchpatch2 {
|
||||
url = "https://github.com/varnishcache/varnish-cache/commit/a95399f5b9eda1bfdba6ee6406c30a1ed0720167.patch";
|
||||
hash = "sha256-T7DIkmnq0O+Cr9DTJS4/rOtg3J6PloUo8jHMWoUZYYk=";
|
||||
})
|
||||
# Fix endian.h compatibility on macOS
|
||||
# PR: https://github.com/varnishcache/varnish-cache/pull/4339
|
||||
./patches/0001-fix-endian-h-compatibility-on-macos.patch
|
||||
]
|
||||
++ lib.optionals (stdenv.isDarwin && lib.versionOlder version "7.6") [
|
||||
# Fix duplicate OS_CODE definitions on macOS
|
||||
# PR: https://github.com/varnishcache/varnish-cache/pull/4347
|
||||
./patches/0002-fix-duplicate-os-code-definitions-on-macos.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace bin/varnishtest/vtc_main.c --replace /bin/rm "${coreutils}/bin/rm"
|
||||
'';
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
From 7a1c7020db85699e0693d637f6e31d49bf9ca3d0 Mon Sep 17 00:00:00 2001
|
||||
From: Rui Chen <rui@chenrui.dev>
|
||||
Date: Sun, 25 May 2025 23:54:29 -0400
|
||||
Subject: [PATCH] libvarnish: Fix endian.h compatibility for macOS builds
|
||||
|
||||
Signed-off-by: Rui Chen <rui@chenrui.dev>
|
||||
---
|
||||
lib/libvarnish/vsha256.c | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/lib/libvarnish/vsha256.c b/lib/libvarnish/vsha256.c
|
||||
index 29f97fe40..541b6e612 100644
|
||||
--- a/lib/libvarnish/vsha256.c
|
||||
+++ b/lib/libvarnish/vsha256.c
|
||||
@@ -31,7 +31,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
-#ifndef __DARWIN_BYTE_ORDER
|
||||
+#ifdef __APPLE__
|
||||
+# include <machine/endian.h>
|
||||
+# include <libkern/OSByteOrder.h>
|
||||
+# define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
+# define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
+# define VBYTE_ORDER __DARWIN_BYTE_ORDER
|
||||
+# define VBIG_ENDIAN __DARWIN_BIG_ENDIAN
|
||||
+#else
|
||||
# include <endian.h>
|
||||
# ifdef _BYTE_ORDER
|
||||
# define VBYTE_ORDER _BYTE_ORDER
|
||||
@@ -43,9 +50,6 @@
|
||||
# else
|
||||
# define VBIG_ENDIAN __BIG_ENDIAN
|
||||
# endif
|
||||
-#else
|
||||
-# define VBYTE_ORDER __DARWIN_BYTE_ORDER
|
||||
-# define VBIG_ENDIAN __DARWIN_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifndef VBYTE_ORDER
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
From f56b314408d22252bf62d6cd2e098cf8139bd048 Mon Sep 17 00:00:00 2001
|
||||
From: Sander <hey@sandydoo.me>
|
||||
Date: Fri, 13 Jun 2025 01:12:59 +0200
|
||||
Subject: [PATCH] build: fix duplicate OS_CODE definitions on macOS
|
||||
|
||||
`TARGET_OS_MAC` and `__APPLE__` are both true on macOS, which results in
|
||||
duplicate definitions for `OS_CODE`.
|
||||
|
||||
Upstream removed the check for `TARGET_OS_MAC`, as well as the ancient
|
||||
compat code, in
|
||||
https://github.com/madler/zlib/commit/4bd9a71f3539b5ce47f0c67ab5e01f3196dc8ef9.
|
||||
|
||||
This was fixed in varnish >= 7.6 as part of https://github.com/varnishcache/varnish-cache/commit/86df12b6c1ad8208899ea353fdcbea227356fcf8.
|
||||
---
|
||||
lib/libvgz/zutil.h | 11 +----------
|
||||
1 file changed, 1 insertion(+), 10 deletions(-)
|
||||
|
||||
diff --git a/lib/libvgz/zutil.h b/lib/libvgz/zutil.h
|
||||
index 1c80e3842..294ea2b2d 100644
|
||||
--- a/lib/libvgz/zutil.h
|
||||
+++ b/lib/libvgz/zutil.h
|
||||
@@ -137,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
-#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
+#if defined(MACOS)
|
||||
# define OS_CODE 7
|
||||
-# ifndef Z_SOLO
|
||||
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||
-# include <unix.h> /* for fdopen */
|
||||
-# else
|
||||
-# ifndef fdopen
|
||||
-# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
-# endif
|
||||
-# endif
|
||||
-# endif
|
||||
#endif
|
||||
|
||||
#ifdef __acorn
|
||||
--
|
||||
2.49.0
|
||||
|
||||
Reference in New Issue
Block a user