Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors reported by mirage 4.5.0 #1520

Closed
Tracked by #1536
hannesm opened this issue Apr 23, 2024 · 6 comments · Fixed by #1539 or ocaml/opam-repository#25901
Closed
Tracked by #1536

Errors reported by mirage 4.5.0 #1520

hannesm opened this issue Apr 23, 2024 · 6 comments · Fixed by #1539 or ocaml/opam-repository#25901

Comments

@hannesm
Copy link
Member

hannesm commented Apr 23, 2024

I did some modification, namely Mirage_logs no longer being a functor. Now, I ran mirage configure, expecting the build to complain.

The error I got is:

$ gmake build
dune build --profile release --root . ./dist
File "lib/devices/runtime_arg.ml", line 161, characters 46-52:
Error: Unbound module Pclock
gmake: *** [Makefile:56: build] Error 1

It is not obvious to me, where I can find lib/devices/runtime_arg.ml

@samoht
Copy link
Member

samoht commented Apr 24, 2024

Could you post the generated main.ml or a way to reproduce?

This location refers to mirage source code. Which doesn't contain Pclock. So there's clearly something going wrong :-)

@hannesm
Copy link
Member Author

hannesm commented Apr 24, 2024

Dear Thomas,

here's the generated main.ml. The error is in the line module Mirage_logs_make__8 = Mirage_logs.Make(Pclock) -- since removed the Make from Mirage_logs.

What is strange is that lib/devices/runtime_arg.ml in my opam switch (~/.opam//lib/mirage/devices/runtime_arg.ml) only has 159 lines.

open Lwt.Infix
let return = Lwt.return
let run t = Solo5_os.Main.run t ; exit
0

let delay__key = Mirage_runtime.register @@
# 33 "lib/devices/runtime_arg.ml"
  Mirage_runtime.delay
;;

let backtrace__key = Mirage_runtime.register @@
# 34 "lib/devices/runtime_arg.ml"
  Mirage_runtime.backtrace
;;

let randomize_hashtables__key = Mirage_runtime.register @@
# 35 "lib/devices/runtime_arg.ml"
  Mirage_runtime.randomize_hashtables
;;

let allocation_policy__key = Mirage_runtime.register @@
# 36 "lib/devices/runtime_arg.ml"
  Mirage_runtime.allocation_policy
;;

let minor_heap_size__key = Mirage_runtime.register @@
# 37 "lib/devices/runtime_arg.ml"
  Mirage_runtime.minor_heap_size
;;

let major_heap_increment__key = Mirage_runtime.register @@
# 38 "lib/devices/runtime_arg.ml"
  Mirage_runtime.major_heap_increment
;;

let space_overhead__key = Mirage_runtime.register @@
# 39 "lib/devices/runtime_arg.ml"
  Mirage_runtime.space_overhead
;;

let max_space_overhead__key = Mirage_runtime.register @@
# 40 "lib/devices/runtime_arg.ml"
  Mirage_runtime.max_space_overhead
;;

let gc_verbosity__key = Mirage_runtime.register @@
# 41 "lib/devices/runtime_arg.ml"
  Mirage_runtime.gc_verbosity
;;

let gc_window_size__key = Mirage_runtime.register @@
# 42 "lib/devices/runtime_arg.ml"
  Mirage_runtime.gc_window_size
;;

let custom_major_ratio__key = Mirage_runtime.register @@
# 43 "lib/devices/runtime_arg.ml"
  Mirage_runtime.custom_major_ratio
;;

let custom_minor_ratio__key = Mirage_runtime.register @@
# 44 "lib/devices/runtime_arg.ml"
  Mirage_runtime.custom_minor_ratio
;;

let custom_minor_max_size__key = Mirage_runtime.register @@
# 45 "lib/devices/runtime_arg.ml"
  Mirage_runtime.custom_minor_max_size
;;

let logs__key = Mirage_runtime.register @@
# 158 "lib/devices/runtime_arg.ml"
  Mirage_runtime.logs
;;

module Mirage_logs_make__8 = Mirage_logs.Make(Pclock)

module Unikernel_main__10 = Unikernel.Main(Solo5_os.Time)

let bootvar__1 = lazy (
# 12 "lib/devices/argv.ml"
  Bootvar.argv ()
);;
# 84 "mirage/main.ml"

let struct_end__2 = lazy (
  let __bootvar__1 = Lazy.force bootvar__1 in
  __bootvar__1 >>= fun _bootvar__1 ->
# 47 "lib/functoria/job.ml"
  return Mirage_runtime.(with_argv (runtime_args ()) "speaking_clock" _bootvar__1)
);;
# 92 "mirage/main.ml"

let printexc__3 = lazy (
  let _backtrace = backtrace__key () in
# 396 "lib/mirage.ml"
  return (Printexc.record_backtrace _backtrace)
);;
# 99 "mirage/main.ml"

let hashtbl__4 = lazy (
  let _randomize_hashtables = randomize_hashtables__key () in
# 405 "lib/mirage.ml"
  return (if _randomize_hashtables then Hashtbl.randomize ())
);;
# 106 "mirage/main.ml"

let gc__5 = lazy (
  let _allocation_policy = allocation_policy__key () in
  let _minor_heap_size = minor_heap_size__key () in
  let _major_heap_increment = major_heap_increment__key () in
  let _space_overhead = space_overhead__key () in
  let _max_space_overhead = max_space_overhead__key () in
  let _gc_verbosity = gc_verbosity__key () in
  let _gc_window_size = gc_window_size__key () in
  let _custom_major_ratio = custom_major_ratio__key () in
  let _custom_minor_ratio = custom_minor_ratio__key () in
  let _custom_minor_max_size = custom_minor_max_size__key () in
# 457 "lib/mirage.ml"
  return (
let open Gc in
  let ctrl = get () in
  set ({ ctrl with allocation_policy = (match _allocation_policy with `Next_fit -> 0 | `First_fit -> 1 | `Best_fit -> 2);
  minor_heap_size = (match _minor_heap_size with None -> ctrl.minor_heap_size | Some x -> x);
  major_heap_increment = (match _major_heap_increment with None -> ctrl.major_heap_increment | Some x -> x);
  space_overhead = (match _space_overhead with None -> ctrl.space_overhead | Some x -> x);
  max_overhead = (match _max_space_overhead with None -> ctrl.max_overhead | Some x -> x);
  verbose = (match _gc_verbosity with None -> ctrl.verbose | Some x -> x);
  window_size = (match _gc_window_size with None -> ctrl.window_size | Some x -> x);
  custom_major_ratio = (match _custom_major_ratio with None -> ctrl.custom_major_ratio | Some x -> x);
  custom_minor_ratio = (match _custom_minor_ratio with None -> ctrl.custom_minor_ratio | Some x -> x);
  custom_minor_max_size = (match _custom_minor_max_size with None -> ctrl.custom_minor_max_size | Some x -> x) })
)
);;
# 135 "mirage/main.ml"

let mirage_runtime__6 = lazy (
  let _delay = delay__key () in
# 302 "lib/mirage.ml"
  Solo5_os.Time.sleep_ns (Duration.of_sec _delay)
);;
# 142 "mirage/main.ml"

let pclock__7 = lazy (
  return ()
);;
# 147 "mirage/main.ml"

let mirage_logs_make__8 = lazy (
  let __pclock__7 = Lazy.force pclock__7 in
  __pclock__7 >>= fun _pclock__7 ->
  let _logs = logs__key () in
# 22 "lib/devices/reporter.ml"
  let reporter = Mirage_logs_make__8.create () in
  Mirage_runtime.set_level ~default:(Some Logs.Info) _logs;
  Logs.set_reporter reporter;
  Lwt.return reporter
);;
# 159 "mirage/main.ml"

let solo5_os_time__9 = lazy (
  return ()
);;
# 164 "mirage/main.ml"

let unikernel_main__10 = lazy (
  let __solo5_os_time__9 = Lazy.force solo5_os_time__9 in
  __solo5_os_time__9 >>= fun _solo5_os_time__9 ->
  Unikernel_main__10.start _solo5_os_time__9
);;
# 171 "mirage/main.ml"

let mirage_runtime__11 = lazy (
  let __struct_end__2 = Lazy.force struct_end__2 in
  let __printexc__3 = Lazy.force printexc__3 in
  let __hashtbl__4 = Lazy.force hashtbl__4 in
  let __gc__5 = Lazy.force gc__5 in
  let __mirage_runtime__6 = Lazy.force mirage_runtime__6 in
  let __mirage_logs_make__8 = Lazy.force mirage_logs_make__8 in
  let __unikernel_main__10 = Lazy.force unikernel_main__10 in
  __struct_end__2 >>= fun _struct_end__2 ->
  __printexc__3 >>= fun _printexc__3 ->
  __hashtbl__4 >>= fun _hashtbl__4 ->
  __gc__5 >>= fun _gc__5 ->
  __mirage_runtime__6 >>= fun _mirage_runtime__6 ->
  __mirage_logs_make__8 >>= fun _mirage_logs_make__8 ->
  __unikernel_main__10 >>= fun _unikernel_main__10 ->
# 384 "lib/mirage.ml"
  return ()
);;
# 191 "mirage/main.ml"

let () =
  let t = Lazy.force struct_end__2 >>= fun _ ->
  Lazy.force printexc__3 >>= fun _ ->
  Lazy.force hashtbl__4 >>= fun _ ->
  Lazy.force gc__5 >>= fun _ ->
  Lazy.force mirage_runtime__6 >>= fun _ ->
  Lazy.force mirage_logs_make__8 >>= fun _ ->
  Lazy.force mirage_runtime__11 in
  run t
;;

@hannesm
Copy link
Member Author

hannesm commented Apr 24, 2024

My suspicion is that the line directive 158 "lib/devices/runtime_arg.ml" is used for all the lines below -- there's a missing yy "mirage/main.ml".

let logs__key = Mirage_runtime.register @@
# 158 "lib/devices/runtime_arg.ml"
  Mirage_runtime.logs
;;

module Mirage_logs_make__8 = Mirage_logs.Make(Pclock)

@samoht
Copy link
Member

samoht commented Apr 24, 2024

Ha yes we need to add a reset statement after the keys are defined so that the line directives refer to main.ml - thanks for spotting this. I am unfortunately a bit tied this week, but I'll welcome a PR if you can convince @Julow to hack on the tool :p

@hannesm
Copy link
Member Author

hannesm commented May 6, 2024

It would be great to have the reset statement at the right place. :)

@hannesm hannesm mentioned this issue May 16, 2024
14 tasks
@hannesm
Copy link
Member Author

hannesm commented May 16, 2024

I tried to find where the right place for a reset_pos would be, but I'm unable to follow the code.

samoht added a commit to samoht/mirage that referenced this issue May 17, 2024
hannesm added a commit that referenced this issue May 17, 2024
#1539)

* internal: reset the lexer location before applying functors in the generated code

Fix #1520

* Functoria: retrieve main on each device iteration

* update tests

---------

Co-authored-by: Hannes Mehnert <hannes@mehnert.org>
hannesm added a commit to hannesm/opam-repository that referenced this issue May 17, 2024
CHANGES:

- BREAKING: remove `~name` parameter from Mirage.Runtime_args.create
  (mirage/mirage#1541 @samoht, fixes mirage/mirage#1532)
- BREAKING: remove `~name` parameter from Mirage.runtime_arg, and use a
  string (instead of a format string) as third parameter (mirage/mirage#1541 @samoht)
- constrain the `start` function to `unit Lwt.t`. Previously, there was no
  restrictions, and lots of time was spent in debugging when a unikernel
  resulted in `unit Lwt.t Lwt.t` (@Julow mirage/mirage#1524)
- revise man page sections and ordering: ARGUMENTS, OPTIONAL, NETWORK OPTIONS,
  DISK OPTIONS, LOG AND MONITORING OPTIONS, OCAML RUNTIME OPTIONS. Previously,
  the ARGUMENTS and OPTIONS were put later, and were hard to find. These are
  the sections where unikernel-specific arguments are put by default
  (mirage/mirage#1531 @hannesm @reynir)
- add --net=host and --net=ocaml to reduce confusion. --net=host uses the
  TCP/IP socket stack, --net=ocaml the OCaml network stack (mirage/mirage#1525 @hannesm)
- quote Runtime_arg.call (mirage/mirage#1522 @Julow)
- documentation fixes (inline examples @Julow mirage/mirage#1523, @hannesm mirage/mirage#1537 (fixes
  mirage/mirage#1512 reported by @reynir), Runtime_args.create mirage/mirage#1541 @samoht)
- fix the build instructions of the generated opam file: since 4.5.0
  `mirage build` is no longer available, use `make "build"` (mirage/mirage#1527 @hannesm)
- add RELEASE.md, a guide on how to cut a mirage release (mirage/mirage#1519 @samoht)
- allow git 3.16 (mirage/mirage#1536 @hannesm)
- use mirage-bootvar (using dune variant) instead of parse-argv and
  mirage-bootvar-xen, mirage-bootvar-solo5, mirage-bootvar-unix
  (mirage/mirage#1533 @hannesm)
- BUGFIX: reset the lexer location before applying functors in generated code
  (mirage/mirage#1539 @samoht, fixes mirage/mirage#1520 @hannesm)
- BUGFIX: fix off-by-one locations for mirage/main.ml (mirage/mirage#1540 @samoht, fixes
  mirage/mirage#1528 @hannesm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants