2011-04-05 05:46:02 Cross-compiling SSHGuard?
Gilles Ganault (FRANCE)
Message: 99592
Hello
I'm trying to cross-compile SSHGuard on a Ubuntu host, but I'm getting a warning when running "configure" and the build fails:
=============
# ./configure --with-firewall=iptables --host=i686-pc-linux-gnu --target=bfin-linux-uclibc CC=/usr/src/baps/opt/uClinux/bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc CFLAGS="-O2 -Wall -ansi -pedantic -I/usr/src/baps/uClinux-dist/linux-2.6.x/include -I/usr/src/baps/uClinux-dist/staging/usr/include" AR="/usr/src/baps/opt/uClinux/bfin-linux-uclibc/bin/bfin-linux-uclibc-ar" RANLIB="/usr/src/baps/opt/uClinux/bfin-linux-uclibc/bin/bfin-linux-uclibc-ranlib"
configure: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used
...
=============
# make
...
make[4]: Entering directory `/usr/src/sshguard-1.5/src/parser'
/usr/src/baps/opt/uClinux/bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I../../src -I. -I.. -Wall -O2 -std=c99 -D_POSIX_C_SOURCE=200112L -O2 -Wall -ansi -pedantic -I/usr/src/baps/uClinux-dist/linux-2.6.x/include -I/usr/src/baps/uClinux-dist/staging/usr/include -MT attack_parser.o -MD -MP -MF .deps/attack_parser.Tpo -c -o attack_parser.o attack_parser.c
In file included from attack_parser.y:39:
../sshguard_logsuck.h:42: error: expected â;â, â,â or â)â before âfilenameâ
../sshguard_logsuck.h:51: error: expected â;â, â,â or â)â before âbufâ
=============
Has someone already experience this and knows what to do?
Thank you.
QuoteReplyEditDelete
2011-04-05 10:34:21 Re: Cross-compiling SSHGuard?
Mike Frysinger (UNITED STATES)
Message: 99601
and what kind of code is at the spot where it is complaining ?
QuoteReplyEditDelete
2011-04-05 11:13:00 Re: Cross-compiling SSHGuard?
Gilles Ganault (FRANCE)
Message: 99606
I checked parser/attack_parser.c, which includes a reference to parser/attack_parser.y, which includes a reference to sshguard_logsuck.h, where lines 42 and 51 are:
===========
int logsuck_add_logsource(const char *restrict filename);
int logsuck_getline(char *restrict buf, size_t buflen, bool from_previous_source, sourceid_t *restrict whichsource);
===========
So it looks like the Blackfin toolchain doesn't like the "*restrict" instruction. What should I do?
Thank you.
QuoteReplyEditDelete
2011-04-05 11:19:08 Re: Cross-compiling SSHGuard?
Mike Frysinger (UNITED STATES)
Message: 99607
the restrict attribute works just fine with Blackfin compilers. the compiler flags in use though make no sense and are most likely causing your problem: -std=c99 -ansi
either you want the C99 standard or you want the ANSI standard (C89). you cant have both.
QuoteReplyEditDelete
2011-04-05 11:30:54 Re: Cross-compiling SSHGuard?
Gilles Ganault (FRANCE)
Message: 99609
Thanks for the tip. Removing "-ansi" did enable "make" to proceed.
However, it fails a few seconds later:
============
...
/usr/src/baps/opt/uClinux/bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc -I. -O2 -Wall -std=c99 -D_XOPEN_SOURCE -O2 -Wall -pedantic -I/usr/src/baps/uClinux-dist/linux-2.6.x/include -I/usr/src/baps/uClinux-dist/staging/usr/include -o sshguard sshguard.o seekers.o sshguard_whitelist.o sshguard_log.o sshguard_procauth.o sshguard_blacklist.o sshguard_options.o sshguard_logsuck.o simclist.o hash_32a.o parser/libparser.a fwalls/libfwall.a -lpthread
sshguard_options.o: In function `.L17':
sshguard_options.c:(.text+0x1d0): undefined reference to `_rpl_malloc'
fwalls/libfwall.a(command.o): In function `_run_command':
============
Does it mean SSHGuard is one of those applications that must be rewritten to work on Blackfin/uClinux?
QuoteReplyEditDelete
2011-04-05 11:36:54 Re: Cross-compiling SSHGuard?
Mike Frysinger (UNITED STATES)
Message: 99610
no, it doesnt mean that at all. you must force the malloc configure test yourself. the uclinux-dist already takes care of this for you.
look at all the settings you should be using in vendors/config/bfin/config.site.
QuoteReplyEditDelete
2011-04-05 17:13:24 Re: Cross-compiling SSHGuard?
Gilles Ganault (FRANCE)
Message: 99611
Thanks. I'll check vendors/config/bfin/config.site to see what to add to SSHGuard's config file to handle malloc().
QuoteReplyEditDelete
2011-04-06 09:57:52 Re: Cross-compiling SSHGuard?
Gilles Ganault (FRANCE)
Message: 99625
SSHGuard's config.h.in contains Malloc/vfork-related settings:
=================
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK
/* Define to 1 if you have the <vfork.h> header file. */
#undef HAVE_VFORK_H
/* Define to 1 if `fork' works. */
#undef HAVE_WORKING_FORK
/* Define to 1 if `vfork' works. */
#undef HAVE_WORKING_VFORK
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define as `fork' if `vfork' does not work. */
#undef vfork
=================
Should I change some of those settings to get the Blackfin toolchain to compile it?
Thank you.
QuoteReplyEditDelete
2011-04-06 10:10:14 Re: Cross-compiling SSHGuard?
Gilles Ganault (FRANCE)
Message: 99626
According to this page, we must export a variable before calling "configure":
=========
export ac_cv_func_malloc_0_nonnull=yes
=========
If possible, I'd rather modify configuration files so that I don't depend on this work-around, but that'll do for the time being.
HTH,
QuoteReplyEditDelete
2011-04-06 13:27:13 Re: Cross-compiling SSHGuard?
Mike Frysinger (UNITED STATES)
Message: 99627
export CONFIG_SITE=$PATH_TO_YOUR_OWN/config.site
./configure .......
QuoteReplyEditDelete
2011-04-07 07:31:17 Re: Cross-compiling SSHGuard?
Gilles Ganault (FRANCE)
Message: 99653
Thanks Mike for the info.
For those having the same issue, here are the different solutions:
- Configure the shell to export this variable: export ac_cv_func_malloc_0_nonnull=yes
- Write a configuration file, and export its location: export CONFIG_SITE=$PATH_TO_FILE/config.site
- Pass the variable to configure: ./configure ac_cv_func_malloc_0_nonnull=yes