Bug #5667
Broken build with uClibc
0%
Description
Current git head
https://github.com/tvheadend/tvheadend/commit/771dfd6bea7bd4035ed991eccbe735dc00d3f800
does not build with uClibC:
src/tvh_thread.h:163:25: error: unknown type name â__do_not_use_pthread_mutex_tâ #define pthread_mutex_t __do_not_use_pthread_mutex_t
Removing
#ifndef TVH_THREAD_C #define pthread_cond __do_not_use_pthread_cond #define pthread_cond_t __do_not_use_pthread_cond_t #define pthread_mutex __do_not_use_pthread_mutex #define pthread_mutex_t __do_not_use_pthread_mutex_t #endif
from src/tvh_thread.h fixes the problem but I am unsure whether such a patch would be accepted.
History
Updated by Jaroslav Kysela over 5 years ago
Which .c file causes this problem? The pthread_mutex_t should not be used anywhere in tvh except in the tvh_thread.c.
Updated by b kuhls over 5 years ago
CC src/main.o In file included from src/main.c:19:0: /home/buildroot/br5/output/build/tvheadend-771dfd6bea7bd4035ed991eccbe735dc00d3f800/src/tvh_thread.h:163:25: error: unknown type name â__do_not_use_pthread_mutex_tâ #define pthread_mutex_t __do_not_use_pthread_mutex_t ^
Updated by Jaroslav Kysela over 5 years ago
main.c does not use pthread_mutex_t . It apears like a compiler issue.
Updated by b kuhls over 5 years ago
src/main.c includes tvh_thread.h in line 19:
https://github.com/tvheadend/tvheadend/blob/master/src/main.c#L19
This header file in line 163 has the code which is broken on uClibc:
https://github.com/tvheadend/tvheadend/blob/master/src/tvh_thread.h#L163
This line is only included when TVH_THREAD_C is not defined.
TVH_THREAD_C is only defined in tvh_thread.c but not in main.c which seems
to me the cause of the problem. I see two possible solutions here:
- delete at least line 163 from tvh_thread.h
- add "#define TVH_THREAD_C 1" to main.c (and tvhlog.c & tvh_locale.c)
If you agree on either one of these solutions I will send a patch.
Updated by Jaroslav Kysela over 5 years ago
You've not got the point. It's only define, so if the pthread_mutex_t is not used in the code (and it should not be used in main.c) then the compilation error should not occur because of the forced invalid symbol (and yes - it's defined by purpose to catch all occurences of pthread usage to not mix the special tvheadend mutex code). I don't see anything from your report why uclibc compilation ends with such error. So again, where is the pthread_mutex_t symbol used when main.c is being compiled?
You may use 'gcc -E' and inspect the source code after the preprocessor run to get an overview where is pthread_mutex_t used in uclibc.
Updated by b kuhls over 5 years ago
This line is included during the build of main.c:
https://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common/bits/uClibc_stdio.h#n214
Updated by Jaroslav Kysela over 5 years ago
What about to include uclibc's stdio.h before tvheadend's header files? It would be probably nice to make those hacks visible using #ifdef like:
#ifdef __UCLIBC_HAS_THREADS__ #include <stdio.h> /* uses pthread_mutex_t */ #endif
Updated by b kuhls over 5 years ago
Jaroslav Kysela wrote:
What about to include uclibc's stdio.h before tvheadend's header files?
Thx, this fixes the problem for me, sent PR: https://github.com/tvheadend/tvheadend/pull/1283