Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors on OSX and Ubuntu 24.04 #63

Closed
philippeboyd opened this issue Jan 22, 2025 · 4 comments · Fixed by #65
Closed

Compilation errors on OSX and Ubuntu 24.04 #63

philippeboyd opened this issue Jan 22, 2025 · 4 comments · Fixed by #65

Comments

@philippeboyd
Copy link
Contributor

philippeboyd commented Jan 22, 2025

Currently working on my Mac (OSX) and running the build inside a docker container since it doesn't compile on OSX but compiles in ubuntu:22.04. Might be related to #55

Steps to reproduce

docker run one of the following:

# make builds successfully
docker run -it --platform linux/arm64 --rm ubuntu:22.04

# make doesn't compile
docker run -it --platform linux/arm64 --rm ubuntu:24.04

Execute inside the container

cd # go to ~
export DEBIAN_FRONTEND=noninteractive
apt update
apt install git make gcc -y
git clone --recursive https://github.com/redis/librdb
cd librdb
make

Error logs for ubuntu 24.04

> make
make -C deps  all
make[1]: Entering directory '/root/librdb/deps'
make -C redis all
make[2]: Entering directory '/root/librdb/deps/redis'
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c crc64.c -o crc64.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden crc64.c > crc64.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c crcspeed.c -o crcspeed.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden crcspeed.c > crcspeed.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c endianconv.c -o endianconv.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden endianconv.c > endianconv.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c fpconv_dtoa.c -o fpconv_dtoa.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden fpconv_dtoa.c > fpconv_dtoa.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c intset.c -o intset.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden intset.c > intset.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c listpack.c -o listpack.o -g3 -DDEBUG=1
listpack.c: In function 'lpFind':
listpack.c:640:50: error: 'vll' may be used uninitialized [-Werror=maybe-uninitialized]
  640 |                 if (vencoding != UCHAR_MAX && ll == vll) {
      |                                               ~~~^~~~~~
listpack.c:608:17: note: 'vll' declared here
  608 |     int64_t ll, vll;
      |                 ^~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:15: listpack.o] Error 1
make[2]: Leaving directory '/root/librdb/deps/redis'
make[1]: *** [Makefile:2: all] Error 2
make[1]: Leaving directory '/root/librdb/deps'
make: *** [Makefile:26: all] Error 2

☝ Setting ll and vll to int64_t ll = 0, vll = 0; works, but we get new errors:

> make
make -C deps  all
make[1]: Entering directory '/root/librdb/deps'
make -C redis all
make[2]: Entering directory '/root/librdb/deps/redis'
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c listpack.c -o listpack.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden listpack.c > listpack.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c lzf_c.c -o lzf_c.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden lzf_c.c > lzf_c.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c lzf_d.c -o lzf_d.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden lzf_d.c > lzf_d.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c rax.c -o rax.o -g3 -DDEBUG=1
rax.c: In function 'raxIteratorAddChars':
rax.c:1280:54: error: pointer 'old' may be used after 'realloc' [-Werror=use-after-free]
 1280 |             it->key = (!old) ? it->key_static_string : old;
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from rax.c:45:
rax_malloc.h:43:21: note: call to 'realloc' here
   43 | #define rax_realloc realloc
rax.c:1278:19: note: in expansion of macro 'rax_realloc'
 1278 |         it->key = rax_realloc(old,new_max);
      |                   ^~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:15: rax.o] Error 1
make[2]: Leaving directory '/root/librdb/deps/redis'
make[1]: *** [Makefile:2: all] Error 2
make[1]: Leaving directory '/root/librdb/deps'
make: *** [Makefile:26: all] Error 2

Am i missing something to build on latest LTS ubuntu 24?

Extra

Error logs for OSX

❯ make
/Library/Developer/CommandLineTools/usr/bin/make -C deps  all
/Library/Developer/CommandLineTools/usr/bin/make -C redis all
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c crc64.c -o crc64.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden crc64.c > crc64.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c crcspeed.c -o crcspeed.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden crcspeed.c > crcspeed.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c endianconv.c -o endianconv.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden endianconv.c > endianconv.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c fpconv_dtoa.c -o fpconv_dtoa.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden fpconv_dtoa.c > fpconv_dtoa.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c intset.c -o intset.o -g3 -DDEBUG=1
cc -MM -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden intset.c > intset.d
cc -fPIC -O3 -std=c99 -Wall -Wextra -pedantic -Werror -fvisibility=hidden -c listpack.c -o listpack.o -g3 -DDEBUG=1
In file included from listpack.c:45:
./listpack_malloc.h:42:10: fatal error: 'malloc.h' file not found
   42 | #include "malloc.h"
      |          ^~~~~~~~~~
1 error generated.
make[2]: *** [listpack.o] Error 1
make[1]: *** [all] Error 2
make: *** [all] Error 2
@moticless
Copy link
Collaborator

moticless commented Jan 28, 2025

Hi @philippeboyd,
Some, if not all, of those false issues are inherited from Redis source code (at folder /root/librdb/deps).
Unlike Redis, librdb bumped into those issues since it compiles with more restricted -Werror. I will remove this flag.

@moticless
Copy link
Collaborator

@philippeboyd , pls see if this commit resolves your issues.

@philippeboyd
Copy link
Contributor Author

philippeboyd commented Jan 28, 2025

@moticless thanks! That fixed it for linux.

About OSX, I've been trying a couple of things and can't seem to get it passed the following error after adjusting the dependency for malloc on OSX

in deps/redis/listpack_malloc.h I changed to the following to fix the issue of

In file included from listpack.c:45:
./listpack_malloc.h:45:10: fatal error: 'malloc.h' file not found
   45 | #include "malloc.h"
      |          ^~~~~~~~~~
1 error generated.
+#ifdef __APPLE__
+#include <malloc/malloc.h>
+#else
 #include "malloc.h"
+#endif

But I get the following error, not sure where to go from here.

listpack.c:176:16: error: call to undeclared function 'malloc_usable_size'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  176 |     if (size < lp_malloc_size(lp)) {
      |                ^
./listpack_malloc.h:53:24: note: expanded from macro 'lp_malloc_size'
   53 | #define lp_malloc_size malloc_usable_size
      |                        ^
listpack.c:176:16: note: did you mean 'malloc_good_size'?
./listpack_malloc.h:53:24: note: expanded from macro 'lp_malloc_size'
   53 | #define lp_malloc_size malloc_usable_size
      |                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/malloc/malloc.h:374:15: note: 'malloc_good_size' declared here
  374 | extern size_t malloc_good_size(size_t size);
      |               ^
listpack.c:176:14: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
  176 |     if (size < lp_malloc_size(lp)) {
      |         ~~~~ ^ ~~~~~~~~~~~~~~~~~~
listpack.c:771:30: error: call to undeclared function 'malloc_usable_size'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  771 |         new_listpack_bytes > lp_malloc_size(lp)) {
      |                              ^
./listpack_malloc.h:53:24: note: expanded from macro 'lp_malloc_size'
   53 | #define lp_malloc_size malloc_usable_size
      |                        ^
listpack.c:771:28: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long long') and 'int' [-Wsign-compare]
  771 |         new_listpack_bytes > lp_malloc_size(lp)) {
      |         ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~
2 warnings and 2 errors generated.
make[2]: *** [listpack.o] Error 1
make[1]: *** [all] Error 2
make: *** [all] Error 2

Relevant clang version

❯ clang -v
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin24.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

@philippeboyd
Copy link
Contributor Author

I managed to make it work on OSX, here's the relevant PR, let me know what you think :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants