[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] Fix warnings in Xen C code



On 13 August 2015 at 13:19, Len Maxwell <len@xxxxxxxx> wrote:
>
> On Thu, Aug 6, 2015 at 4:58 AM, Thomas Leonard <talex5@xxxxxxxxx> wrote:
>>
>> On 6 August 2015 at 00:26, Len Maxwell <len@xxxxxxxx> wrote:
>> >
>> > Hi,
>> >
>> > After working with minios-xen a bit, I thought I could help with this
>> > pioneer project.  There seem to be significantly fewer C warnings than
>> > the
>> > last time I looked (months ago).
>>
>> That would be very useful!
>>
>
> Hi,
>
> If I start from mirage-platform master (@ 94f01d), and make this change to
> xen-posix/include/stdio.h:
>
> -#define fprintf(x,rest...) printk(rest)
> +int fprintf(FILE *stream, const char *format, ...) __THROW
> __attribute__((__format__(__printf__,2,3)));
>
> ...it should eliminate a missing prototype warning for printk in xen-ocaml.
> The package builds OK, but produces link errors when I try to make a
> unikernel:
>
> $ make clean && make
> [ ... ]
> ld -d -static -nostdlib \
>   _build/main.native.o \
>   -L/opt/ml/opam/4.02.1/lib/io-page -lio_page_xen_stubs \
>   $(pkg-config --static --libs mirage-xen) \
>   /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a \
>   -o mir-console.xen
> /opt/ml/opam/4.02.1/lib/pkgconfig/../../lib/mirage-xen-ocaml/libxenasmrun.a(fail.o):
> In function `caml_array_bound_error':
> fail.c:(.text+0x2c8): undefined reference to `fwrite'
> /opt/ml/opam/4.02.1/lib/pkgconfig/../../lib/mirage-xen-ocaml/libxenasmrun.a(misc.o):
> In function `caml_fatal_error':
> misc.c:(.text+0x42): undefined reference to `fputs'
> /opt/ml/opam/4.02.1/lib/pkgconfig/../../lib/mirage-xen-ocaml/libxenasmrun.a(parsing.o):
> In function `caml_parse_engine':
> parsing.c:(.text+0x225): undefined reference to `fputs'
> parsing.c:(.text+0x258): undefined reference to `fputc'
> parsing.c:(.text+0x273): undefined reference to `fwrite'
> parsing.c:(.text+0x420): undefined reference to `fwrite'
> parsing.c:(.text+0x46b): undefined reference to `fwrite'
> Makefile:34: recipe for target 'build' failed
> make: *** [build] Error 1
>
>
> Each of these caml_ functions calls fprintf.  fprintf is implemented in
> xen-posix/src/mini_libc.c, but it does not use fwrite/fputs/fputc, it's just
> a wrapper for mini-os print().
>
> How do I find out where these undefined references are coming from?

Most likely, the C compiler is optimising the calls to fprintf and
replacing them with calls to the other functions.


-- 
Dr Thomas Leonard        http://roscidus.com/blog/
GPG: DA98 25AE CAD0 8975 7CDA  BD8E 0713 3F96 CA74 D8BA

_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.