File 1399-erts-Fix-compile-error-in-zlib-zconf.h.patch of Package erlang
From d4614d4262dcbc65e1bc86d76f3ed5c336a651ad Mon Sep 17 00:00:00 2001 From: Sverker Eriksson <sverker@erlang.org> Date: Thu, 26 Feb 2026 18:08:45 +0100 Subject: [PATCH 1/2] erts: Fix compile error in zlib/zconf.h zlib/zconf.h:450:5: error: 'HAVE_STDARG_H' is not defined, evaluates to 0 [-Werror,-Wundef] when building with either * --enable-builtin-zlib * without installed zlib * with installed zlib >= 1.3.1.2 --- erts/emulator/beam/dist.h | 2 +- erts/emulator/beam/erl_bif_chksum.c | 2 +- erts/emulator/beam/erl_bif_re.c | 2 +- erts/emulator/beam/erl_zlib.h | 19 +++++++++++++++++++ erts/emulator/nifs/common/zlib_nif.c | 3 ++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/erts/emulator/beam/dist.h b/erts/emulator/beam/dist.h index 766d2f9487..96a0d010b4 100644 --- a/erts/emulator/beam/dist.h +++ b/erts/emulator/beam/dist.h @@ -25,7 +25,7 @@ #include "erl_process.h" #include "erl_node_tables.h" -#include "zlib.h" +#include "erl_zlib.h" #define DFLAG_PUBLISHED ((Uint64)0x01) #define DFLAG_ATOM_CACHE ((Uint64)0x02) diff --git a/erts/emulator/beam/erl_bif_chksum.c b/erts/emulator/beam/erl_bif_chksum.c index a09675e355..e7181e6bc4 100644 --- a/erts/emulator/beam/erl_bif_chksum.c +++ b/erts/emulator/beam/erl_bif_chksum.c @@ -31,7 +31,7 @@ #include "bif.h" #include "erl_binary.h" #include "big.h" -#include "zlib.h" +#include "erl_zlib.h" #include "erl_md5.h" diff --git a/erts/emulator/beam/erl_zlib.h b/erts/emulator/beam/erl_zlib.h index 6167add102..10f72331a0 100644 --- a/erts/emulator/beam/erl_zlib.h +++ b/erts/emulator/beam/erl_zlib.h @@ -23,8 +23,27 @@ /* A sparse wrapper interface around zlib with erts memory allocation. */ +/* Workaround to make zlib.h compile with -Werror=undef */ +#ifndef HAVE_UNISTD_H +# define HAVE_UNISTD_H 0 +# define HAVE_UNISTD_H__UNDEF +#endif +#ifndef HAVE_STDARG_H +# define HAVE_STDARG_H 0 +# define HAVE_STDARG_H__UNDEF +#endif + #include <zlib.h> +#ifdef HAVE_UNISTD_H__UNDEF +# undef HAVE_UNISTD_H +# undef HAVE_UNISTD_H__UNDEF +#endif +#ifdef HAVE_STDARG_H__UNDEF +# undef HAVE_STDARG_H +# undef HAVE_STDARG_H__UNDEF +#endif + /* Initialize zalloc, zfree and opaque of a z_stream */ diff --git a/erts/emulator/nifs/common/zlib_nif.c b/erts/emulator/nifs/common/zlib_nif.c index 6b8df9f139..14750c9bdf 100644 --- a/erts/emulator/nifs/common/zlib_nif.c +++ b/erts/emulator/nifs/common/zlib_nif.c @@ -24,7 +24,8 @@ #define STATIC_ERLANG_NIF 1 #include <stdio.h> -#include <zlib.h> + +#include "erl_zlib.h" #include "erl_nif.h" #include "config.h" -- 2.51.0