On Thu, Aug 13, 2015 at 9:02 AM, Thomas Leonard <[email protected]> wrote:
> On 13 August 2015 at 13:19, Len Maxwell <[email protected]> wrote: > > > > On Thu, Aug 6, 2015 at 4:58 AM, Thomas Leonard <[email protected]> wrote: > >> > >> On 6 August 2015 at 00:26, Len Maxwell <[email protected]> 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. > > Adding `-fno-builtin` to the xen-ocaml build resolves this. Without this flag, gcc makes assumptions about the semantics/implementation of standard library functions. In this case, as you suggest, it is inlining calls to fprintf using its own built-in implementation instead of mini_libc's. Very interesting. Not sure how this affects other parts of xen-ocaml; it can be made more specific with `-fno-builtin-fprintf`. -- Len > > -- > Dr Thomas Leonard http://roscidus.com/blog/ > GPG: DA98 25AE CAD0 8975 7CDA BD8E 0713 3F96 CA74 D8BA >
_______________________________________________ MirageOS-devel mailing list [email protected] http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel
