Trying to cross compile on arm on redis 5rc giving unknown error

Hello,

I am not a very big C builder, I was able to build the Redis 4 stable for LEDE and OpenWrt, but I cannot understand my error on Redis 5rc, says:

src/background_thread.c:89:12: warning: implicit declaration of function 'sched_setaffinity'; did you mean 'SYS_sched_setaffinity'? [-Wimplicit-function-declaration]
  int ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
            ^~~~~~~~~~~~~~~~~
            SYS_sched_setaffinity
src/background_thread.c:89:40: error: 'cpu_set_t' undeclared (first use in this function); did you mean 'cpuset'?
  int ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
                                        ^~~~~~~~~
                                        cpuset
src/background_thread.c:89:40: note: each undeclared identifier is reported only once for each function it appears in
src/background_thread.c: In function 'background_thread_entry':
src/background_thread.c:512:2: warning: implicit declaration of function 'pthread_setname_np'; did you mean 'pthread_setcanceltype'? [-Wimplicit-function-declaration]
  pthread_setname_np(pthread_self(), "jemalloc_bg_thd");
  ^~~~~~~~~~~~~~~~~~
  pthread_setcanceltype
Makefile:349: recipe for target 'src/background_thread.sym.o' failed
make[3]: *** [src/background_thread.sym.o] Error 1
make[3]: Leaving directory '/build/source/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/redis-5.0-rc4/deps/jemalloc'
Makefile:91: recipe for target '/build/source/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/redis-5.0-rc4/.built' failed
make[2]: *** [/build/source/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/redis-5.0-rc4/.built] Error 2
make[2]: Leaving directory '/build/source/feeds/redis/redis'
Command exited with non-zero status 2
time: package/feeds/redis/redis/compile#14.84#1.41#15.66
package/Makefile:107: recipe for target 'package/feeds/redis/redis/compile' failed
make[1]: *** [package/feeds/redis/redis/compile] Error 2
make[1]: Leaving directory '/build/source'
/build/source/include/toplevel.mk:216: recipe for target 'package/feeds/redis/redis/compile' failed
make: *** [package/feeds/redis/redis/compile] Error 2

Do you have any idea what this error could say?

OK, I fixed it, but it is ugly, because I just uncommented the code, but it works though.
My question is, that what I need to do is to undefine with JEMALLOC_HAVE_SCHED_SETAFFINITY and JEMALLOC_HAVE_PTHREAD_SETNAME_NP. I tried in redis-5.0-rc4/deps/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h.in as

#undef JEMALLOC_HAVE_SCHED_SETAFFINITY
#undef JEMALLOC_HAVE_PTHREAD_SETNAME_NP

then I tried

override undefine JEMALLOC_HAVE_SCHED_SETAFFINITY
override undefine JEMALLOC_HAVE_PTHREAD_SETNAME_NP

But if was saying it is an error.
So how can I undefined a define in C CMAKE or MAKE?

Thanks so much.

I fix like this:

Index: redis-5.0-rc4/deps/jemalloc/src/background_thread.c
===================================================================
--- redis-5.0-rc4.orig/deps/jemalloc/src/background_thread.c
+++ redis-5.0-rc4/deps/jemalloc/src/background_thread.c
@@ -82,16 +82,16 @@ background_thread_info_init(tsdn_t *tsdn

 static inline bool
 set_current_thread_affinity(UNUSED int cpu) {
-#if defined(JEMALLOC_HAVE_SCHED_SETAFFINITY)
-       cpu_set_t cpuset;
-       CPU_ZERO(&cpuset);
-       CPU_SET(cpu, &cpuset);
-       int ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
-
-       return (ret != 0);
-#else
+//#if defined(JEMALLOC_HAVE_SCHED_SETAFFINITY)
+//     cpu_set_t cpuset;
+//     CPU_ZERO(&cpuset);
+//     CPU_SET(cpu, &cpuset);
+//     int ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
+//
+//     return (ret != 0);
+//#else
        return false;
-#endif
+//#endif
 }

 /* Threshold for determining when to wake up the background thread. */
@@ -508,9 +508,9 @@ static void *
 background_thread_entry(void *ind_arg) {
        unsigned thread_ind = (unsigned)(uintptr_t)ind_arg;
        assert(thread_ind < max_background_threads);
-#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
-       pthread_setname_np(pthread_self(), "jemalloc_bg_thd");
-#endif
+//#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
+//     pthread_setname_np(pthread_self(), "jemalloc_bg_thd");
+//#endif
        if (opt_percpu_arena != percpu_arena_disabled) {
                set_current_thread_affinity((int)thread_ind);
        }
(

But it is ugly and it could much easier to undef a defined variable in MAKE/CMAKE, want it to be CAKE : )

ok, i disabled jemalloc for redis memory allocator to use the smaller libc, which is better for embedded system and finally redis 5 works with openwrt.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.