mirage / mirage-platform

Archived, see https://github.com/mirage/mirage/issues/1159 for details. Old: Core platform libraries for Mirage (UNIX and Xen). This provides the `OS` library which handles timers, device setup and the main loop, as well as the runtime for the Xen unikernel.
https://mirage.io
Other
77 stars 42 forks source link

#require "mirage";; fails on Linux with 4.00.1 #22

Closed vbmithr closed 11 years ago

vbmithr commented 11 years ago

Just so that we keep a track of this somewhere:

utop $ #require "mirage";;
/usr/lib/ocaml/threads: added to search path                                                                                                                                                                     /usr/lib/ocaml/dynlink.cma: loaded                                                                                                                                                                               /usr/lib/ocaml/camlp4: added to search path                                                                                                                                                                      
/home/vb/.opam/system/lib/optcomp: added to search path
/home/vb/.opam/system/lib/ocplib-endian: added to search path
/home/vb/.opam/system/lib/ocplib-endian/ocplib_endian.cma: loaded
/home/vb/.opam/system/lib/ocplib-endian/bigstring.cma: loaded
/home/vb/.opam/system/lib/cstruct: added to search path
/home/vb/.opam/system/lib/cstruct/cstruct.cma: loaded
/home/vb/.opam/system/lib/lwt: added to search path
/home/vb/.opam/system/lib/mirage: added to search path
/home/vb/.opam/system/lib/mirage/oS.cma: loaded
Error: The external function `pcap_opendev' is not available

And here is Haris answer:


This is something I did a while back in order to allow interfaces to open in Mac environments. It was the only way to open raw ethernet sockets in MacOSX. The equivalent action in Linux should open a raw ethernet socket using Libc (Something along this lines http://aschauf.landshut.org/fh/linux/udp_vs_raw/ch01s03.html). At the moment I haven't fixed the Linux code to work. In the case of Linux I had an ifdef function which implements an empty function for this.

It is a bit complicated to handle this case because there is a different approach on how to read packets from pcap fd in Macosx and from raw ethernet sockets in Linux. The difference is that in pcap you need to skip the pcap header. This is not the case in Linux. I can fix quickly the code if you could give me some hint on how I could detect in Ocaml the OS type.

vbmithr commented 11 years ago

Actually, the problem is not related at all to the implementation (or absence of) of pcap_opendev, but it is a link problem (the C .o objects are not linked to oS.cma). Trying to solve this…

vbmithr commented 11 years ago

Well, or it might be that utop (via the META file) do not load libunixrun.a. Not sure how is this supposed to work though…

avsm commented 11 years ago

It's normally the -cclib or -ccopt passed during compilation. I wouldn't be surprised if the cmd script gets this wrong!

vbmithr commented 11 years ago

Here is what happens exactly:

/usr/bin/ocamlopt.opt -a -I /usr/lib/ocaml -I /usr/lib/ocaml -I /usr/lib/ocaml/camlp4 -I /home/vb/.opam/system/lib/optcomp -I /home/vb/.opam/system/lib/ocplib-endian -I /home/vb/.opam/system/lib/ocplib-endian -I /home/vb/.opam/system/lib/cstruct -I /home/vb/.opam/system/lib/lwt -I /home/vb/.opam/system/lib/lwt -cclib -lunixrun lib/oS.cmx -o lib/oS.cmxa
cc -I/home/vb/code/mirage-platform/unix/lib -c -Wall -O3 -fPIC -I/usr/lib/ocaml -o lib/checksum_stubs.o lib/checksum_stubs.c
cc -I/home/vb/code/mirage-platform/unix/lib -c -Wall -O3 -fPIC -I/usr/lib/ocaml -o lib/tap_stubs_os.o lib/tap_stubs_os.c
/usr/bin/ocamlc.opt -a -I /usr/lib/ocaml -I /usr/lib/ocaml -I /usr/lib/ocaml/camlp4 -I /home/vb/.opam/system/lib/optcomp -I /home/vb/.opam/system/lib/ocplib-endian -I /home/vb/.opam/system/lib/ocplib-endian -I /home/vb/.opam/system/lib/cstruct -I /home/vb/.opam/system/lib/lwt -I /home/vb/.opam/system/lib/lwt lib/oS.cmo -o lib/oS.cma
/usr/bin/ocamlmklib -o lib/unixrun lib/checksum_stubs.o lib/tap_stubs_os.o
# Parallel statistics: { count(total): 4(35), max: 8, min: 2, average(total): 4.500(1.400) }
avsm commented 11 years ago

Do you want to try this under obuild and see how far you can get? The CFLAGS are large but static...

(it's ok to break NS3 for the moment; Xen and UNIX are the important ones for a first cut)

On 28 Feb 2013, at 14:43, Vincent Bernardoff notifications@github.com wrote:

Here is what happens exactly:

/usr/bin/ocamlopt.opt -a -I /usr/lib/ocaml -I /usr/lib/ocaml -I /usr/lib/ocaml/camlp4 -I /home/vb/.opam/system/lib/optcomp -I /home/vb/.opam/system/lib/ocplib-endian -I /home/vb/.opam/system/lib/ocplib-endian -I /home/vb/.opam/system/lib/cstruct -I /home/vb/.opam/system/lib/lwt -I /home/vb/.opam/system/lib/lwt -cclib -lunixrun lib/oS.cmx -o lib/oS.cmxa cc -I/home/vb/code/mirage-platform/unix/lib -c -Wall -O3 -fPIC -I/usr/lib/ocaml -o lib/checksum_stubs.o lib/checksum_stubs.c cc -I/home/vb/code/mirage-platform/unix/lib -c -Wall -O3 -fPIC -I/usr/lib/ocaml -o lib/tap_stubs_os.o lib/tap_stubs_os.c /usr/bin/ocamlc.opt -a -I /usr/lib/ocaml -I /usr/lib/ocaml -I /usr/lib/ocaml/camlp4 -I /home/vb/.opam/system/lib/optcomp -I /home/vb/.opam/system/lib/ocplib-endian -I /home/vb/.opam/system/lib/ocplib-endian -I /home/vb/.opam/system/lib/cstruct -I /home/vb/.opam/system/lib/lwt -I /home/vb/.opam/system/lib/lwt lib/oS.cmo -o lib/oS.cma /usr/bin/ocamlmklib -o lib/unixrun lib/checksum_stubs.o lib/tap_stubs_os.o

Parallel statistics: { count(total): 4(35), max: 8, min: 2, average(total): 4.500(1.400) }

— Reply to this email directly or view it on GitHub.