Describe the bug

Redis 6.2.0 does not build without jemalloc on musl

To reproduce

On a musl based system (such as Alpine Linux), compile a fresh copy of the Redis 6.2.0 source code without jemalloc: make USE_JEMALLOC=no

The following Dockerfile can be used to reproduce the issue:

FROM alpine:latest

RUN apk update && apk add make gcc linux-headers libc-dev
RUN wget https://download.redis.io/releases/redis-6.2.0.tar.gz && tar xf redis-6.2.0.tar.gz
RUN cd redis-6.2.0 && make USE_JEMALLOC=no

This results in the following failure:

[...]
make[2]: Leaving directory '/redis-6.2.0/deps'
    CC adlist.o
    CC quicklist.o
    CC ae.o
    CC anet.o
    CC dict.o
    CC server.o
    CC sds.o
    CC zmalloc.o
zmalloc.c:56:28: error: missing binary operator before token "("
   56 | #define PREFIX_SIZE (sizeof(size_t))
      |                            ^
zmalloc.c:60:5: note: in expansion of macro 'PREFIX_SIZE'
   60 | #if PREFIX_SIZE > 0
      |     ^~~~~~~~~~~
make[1]: Leaving directory '/redis-6.2.0/src'
make[1]: *** [Makefile:359: zmalloc.o] Error 1
make: *** [Makefile:6: all] Error 2

Expected behavior

Redis 6.2.0 should compile succesfully without jemalloc on musl based systems.

Additional information

The conditional check in https://github.com/redis/redis/blob/6.2/src/zmalloc.c#L60-L64 appears to be wrong. In this file, we attempt to compare sizeof(something) with a literal constant in the preprocessor (ie in cpp). However, sizeof(something) is only known at compile time (ie in cc); as only the compiler knows about types and their sizes. Hence the error above.

Comment From: oranagra

thanks for the report.. this is already resolved in unstable and soon to be included in 6.2.1 see #8533