Summary:ASTERISK-05410: Cannot compile against UcLibc-0.9.27
Reporter:hwstar (hwstar)Labels:
Date Opened:2005-10-31 22:45:37.000-0600Date Closed:2008-01-15 15:53:29.000-0600
Versions:Frequency of
Environment:Attachments:( 0) localtime-uclibc-patch
A change made to lock.h on 10/28 appears to have broken the compile process when asterisk is compiled against uClibc-0.9.27. Asterisk compiled against libc on my developement box has no issues.

Here is the output from the failed build:

gcc  -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -g  -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE  -O6 -march=i586 -DZAPTEL_OPTIMIZATIONS         -DRADIO_RELAX -DLOW_MEMORY -fomit-frame-pointer    -c -o localtime.o localtime.c
In file included from /usr/include/stdio.h:72,
                from private.h:82,
                from localtime.c:62:
/usr/include/bits/uClibc_stdio.h:286: error: parse error before "use_ast_mutex_t_instead_of_pthread_mutex_t"
make[2]: *** [localtime.o] Error 1
make[2]: Leaving directory `/usr/src/asterisk/stdtime'
make[1]: *** [stdtime/libtime.a] Error 2
make[1]: Leaving directory `/usr/src/asterisk'
make: *** [.asterisk-built] Error 2
Comments:By: hwstar (hwstar) 2005-10-31 23:07:23.000-0600

Additional info: Compiler version

[root@wa6zft-test ~]# gcc -v
Using built-in specs.
Configured with: /home/srodgers/projects/limey-linux/ll-vers-0.6/build/buildroot/toolchain_build_i386/gcc-3.4.2/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-linux-uclibc --target=i386-linux-uclibc --enable-languages=c --enable-shared --with-gxx-include-dir=/usr/include/c++ --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --enable-multilib --enable-sjlj-exceptions
Thread model: posix
gcc version 3.4.2
[root@wa6zft-test ~]#

By: Kevin P. Fleming (kpfleming) 2005-10-31 23:26:38.000-0600

This is probably a header ordering issue; the inclusion of Asterisk headers in stdtime/localtime.c should occur _after_ all the system headers are included, not before. Can you try making that change and report the results?

By: hwstar (hwstar) 2005-11-01 08:03:39.000-0600

Reordering the header files fixed the compile issue for localtime.c. I uploaded  a diff -Naur patch file for localtime.c

I did run in to another problem with devicestate.c. devicestate.c also will not complile and it also uses lock.h. The header files are ordered as follows:

#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

#include "asterisk.h"

ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.11 $")

#include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/logger.h"
#include "asterisk/devicestate.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"

The output from the failed build is:

gcc  -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -g  -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE  -O6 -march=i586 -DZAPTEL_OPTIMIZATIONS         -DRADIO_RELAX -DLOW_MEMORY -fomit-frame-pointer    -c -o devicestate.o devicestate.c
In file included from /usr/include/stdio.h:72,
                from include/asterisk/monitor.h:26,
                from include/asterisk/channel.h:52,
                from devicestate.c:34:
/usr/include/bits/uClibc_stdio.h:286: error: parse error before "use_ast_mutex_t_instead_of_pthread_mutex_t"
make[1]: *** [devicestate.o] Error 1
make[1]: Leaving directory `/usr/src/asterisk'
make: *** [.asterisk-built] Error 2

Any suggestions?


By: Kevin P. Fleming (kpfleming) 2005-11-01 10:25:58.000-0600

Yes, it appears that devicestate.c will need an explicit include of <stdio.h> prior to including any Asterisk headers... The recent changes to use FILE * for streams is probably the cause of this.

By: Kevin P. Fleming (kpfleming) 2005-11-01 17:20:18.000-0600

Committed to CVS HEAD, thanks!

By: hwstar (hwstar) 2005-11-02 00:20:51.000-0600

But wait, there's more than 2 files with this issue!

I just tried the latest CVS, and got the the same syntax errors on the following files:

cryptostub.c, res_indications.c, chan_iax2.c, iax2-parser.c, iax2-provision.c,
pbx_dundi.c, pbx_loopback.c, pbx_realtime.c, app_playback.c, app_system.c,
app_echo.c, app_record.c, app_image.c, app_url.c, app_getcpeid.c, app_milliwatt.c, app_zapateller.c, app_setcallerid.c, app_senddtmf.c, app_parkandannounce.c,  app_striplsd.c, app_setcidname.c, app_lookupcidname.c,
app_substring.c, app_macro.c, app_softhangup.c, app_lookupblacklist.c,
app_waitforring.c, app_privacy.c, app_db.c, app_chanisavail.c, app_enumlookup.c,
app_transfer.c, app_setcidnum.c, app_cdr.c,  app_hasnewvoicemail.c, app_read.c,
app_setcdruserfield.c, app_sendtext.c, app_txtcidname.c, app_controlplayback.c,
app_talkdetect.c, app_userevent.c, app_test.c, app_forkcdr.c, app_realtime.c,
app_dumpchan.c, app_waitforsilence.c, app_while.c, app_setrdnis.c, app_md5.c,
app_chanspy.c, app_settransfercapability.c, app_dictate.c, app_externalivr.c,
app_directed_pickup.c, app_mixmonitor.c, app_meetme.c, app_flash.c, app_zapbarge.c, app_zapscan.c, app_sms.c, cdr_csv.c, cdr_manager.c,
cdr_custom.c, pbx_functions.c, func_callerid.c, func_enum.c, func_uri.c

The failed build output is (example for all files above):

gcc  -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -g  -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE  -O6 -march=i586 -DZAPTEL_OPTIMIZATIONS         -DRADIO_RELAX -DLOW_MEMORY -fomit-frame-pointer  -Wno-missing-prototypes -Wno-missing-declarations -DZAPATA_PRI -DIAX_TRUNKING -DCRYPTO -fPIC    -c -o iax2-parser.o iax2-parser.c
In file included from /usr/include/stdio.h:72,
                from iax2-parser.c:40:
/usr/include/bits/uClibc_stdio.h:286: error: parse error before "use_ast_mutex_t_instead_of_pthread_mutex_t"
make[2]: *** [iax2-parser.o] Error 1
make[2]: Leaving directory `/usr/src/asterisk/channels'
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory `/usr/src/asterisk'
make: *** [.asterisk-built] Error 2

By: Michael Jerris (mikej) 2005-11-02 00:31:07.000-0600

I am having the same error on cygwin in localtime.c.  I commented out the re-define of pthread_mutex_t in lock.h and it fixed the problem for me.  It appears to be releated to the fact that in pthread.h, PTHREAD_MUTEX_INITIALIZER is defined as #define PTHREAD_MUTEX_INITIALIZER (pthread_mutex_t)20, and the re-define seems to break this.  Not sure what the best real solution for this is.

By: hwstar (hwstar) 2005-11-02 08:55:09.000-0600


What CVS time and date were you using for the localtime.c compile fail? There was a patch for this checked in to CVS on 11/1. Is the patched version broke on Cygwin?

BTW: I'm also having link problems with getloadavg when compiling against uClibc, but I haven't reported it yet. I just commented out those calls as a workaround so that I could find all the modules complaining about the mutex problem. The CVS checkout I was using was from 11/1 17:48.


By: Michael Jerris (mikej) 2005-11-02 09:07:37.000-0600

I have the issue with localtime back to the commit where lock.h was added to it.  Does the patch on 5569 resolve your getloadavg issues?

By: Kevin P. Fleming (kpfleming) 2005-11-08 21:05:42.000-0600

This should be fixed in CVS HEAD now.

By: Digium Subversion (svnbot) 2008-01-15 15:53:29.000-0600

Repository: asterisk
Revision: 6940

U   trunk/ChangeLog
U   trunk/devicestate.c
U   trunk/stdtime/localtime.c

r6940 | kpfleming | 2008-01-15 15:53:29 -0600 (Tue, 15 Jan 2008) | 2 lines

issue ASTERISK-5410