Snapchat / KeyDB

A Multithreaded Fork of Redis
https://keydb.dev
BSD 3-Clause "New" or "Revised" License
11.02k stars 564 forks source link

[BUG] Building on MacOS Fails (Apple Silicon) (v6.3.4) #825

Open MrBlaise opened 2 months ago

MrBlaise commented 2 months ago

UPDATE: See my comment. The issue seems to be solved on the latest commit, but building with FLASH support is still broken.

Describe the bug

I am trying to build KeyDB from source as the binary available through homebrew was not built with Flash support enabled. The build fails with the following error:

... (lines removed for brevity)
...
...
MAKE hdr_histogram
...
...
... (lines removed for brevity)
replication.cpp:2112:31: error: variable has incomplete type 'struct stat64'
            struct redis_stat buf;
                              ^
replication.cpp:2112:20: note: forward declaration of 'stat64'
            struct redis_stat buf;
                   ^
./config.h:47:20: note: expanded from macro 'redis_stat'
#define redis_stat stat64
                   ^
1 error generated.
make[1]: *** [replication.o] Error 1
make: *** [all] Error 2

To reproduce Doesn't matter whether I build with ENABLE_FLASH or not the issue is the same, so it is probably not connected to FLASH support at all.

Expected behavior

KeyDB should be built on MacOS

Additional information

MacOS Sonoma Version 14.4.1 - M1 Apple Silicon (ARM)

MrBlaise commented 2 months ago

Update:

I've tried building it against the main branch. This time the build finished successfully, so this issue must have been fixed since the latest release. However when I try to build it with FLASH support it fails, so now it becomes a FLASH issue.

The following error occurs:

  CC       cache/lru_cache.o
cache/lru_cache.cc:98:12: error: variable 'count' set but not used [-Werror,-Wunused-but-set-variable]
  uint32_t count = 0;
           ^
1 error generated.
make[3]: *** [cache/lru_cache.o] Error 1
make[2]: *** [rocksdb] Error 2
MrBlaise commented 2 months ago

We were able to work around it by running the make command like so:

make ENABLE_FLASH=yes CFLAGS="-Wno-unused-but-set-variable -I/opt/homebrew/opt/openssl/include" LDFLAGS="-L/opt/homebrew/opt/openssl/lib" KEYDB_LDFLAGS="-L/opt/homebrew/opt/zstd/lib -L/opt/homebrew/opt/lz4/lib -L/opt/homebrew/opt/snappy/lib"

The error in my latest comment was solved by adding: -Wno-unused-but-set-variable. On top of that we had to manually set all the libs required for FLASH as on macOS they aren't resolved automatically. We also needed to add LDFLAGS=“-L/opt/homebrew/opt/openssl/lib” specifically for hiredis.

This seems to work for both the latest stable release (6.3.4) and the main branch.