ikiwiki/doc/bugs/build_in_opensolaris.mdwn

75 lines
2.9 KiB
Markdown

I've learned I'm not yet clever enough to get IkiWiki to build in OpenSolaris (as running on a [Joyent Accelerator][ja]). Anyone figured this out already?
I think problem lies mostly, if not entirely, in getting ikiwiki.cgi.c to compile in an OpenSolaris context (this is ikiwiki-2.2):
> <code>$ ikiwiki --setup ~/etc/ikiwiki/ikiwiki-edit.setup
> [...]
> Error: failed to compile /home/username/domains/domain.tld/cgi-bin/ikiwiki.cgi.c at /opt/local/lib/perl5/site_perl/IkiWiki.pm line 104.
BEGIN failed--compilation aborted at (eval 3) line 145.</code>
More specifically,
> <code>$ /usr/sfw/bin/gcc ikiwiki.cgi.c
> Undefined first referenced
> symbol in file
> asprintf /var/tmp//cczPaG7R.o
> ld: fatal: Symbol referencing errors. No output written to a.out
> collect2: ld returned 1 exit status</code>
[ja]: <http://www.joyent.com/accelerator/technical-specifications/>
Thanks, Joey et al., for a really cool tool.
--Mike
> Looks like the ikiwiki wrapper uses asprintf. glibc has that, and I think some other libc implementations have that, but apparently the Solaris libc does not. The same problem will come up on other platforms that don't use glibc. The ikiwiki wrapper needs to either avoid asprintf or use a portable asprintf implementation from somewhere like gnulib. --[[JoshTriplett]]
>> I used asprintf because it was easy, and safe. That is a good reason for
>> C libraries to support asprintf, IMHO. Note that both linux and *BSD
>> support asprintf.
>>
>> Of the possible patches to make this more portable, I'd generally prefer
>> one that uses portable functions (safely), rather than one that includes
>> an asprintf implementation in ikiwiki. --[[Joey]]
> I got ikiwiki working (sort of) on OpenSolaris today. I ran into this problem too, and wrote a version of asprintf() from scratch which uses more portable APIs:
<code>
#include &lt;stdarg.h&gt;
int
asprintf(char **string_ptr, const char *format, ...)
{
va_list arg;
char *str;
int size;
int rv;
va_start(arg, format);
size = vsnprintf(NULL, 0, format, arg);
size++;
va_start(arg, format);
str = malloc(size);
if (str == NULL) {
va_end(arg);
/*
* Strictly speaking, GNU asprintf doesn't do this,
* but the caller isn't checking the return value.
*/
fprintf(stderr, "failed to allocate memory\\n");
exit(1);
}
rv = vsnprintf(str, size, format, arg);
va_end(arg);
*string_ptr = str;
return (rv);
}
</code>
> I added this after the rest of the #include's in Wrapper.pm, and it seems to work. --Blake
>> I have this marked [[bugs/done]] already, because I changed it in svn to
>> not use asprintf --[[Joey]]