Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,9 @@ let configure i =
let target = Key.(get ctx target) in
Log.info (fun m -> m "Configuring for target: %a" Key.pp_target target);
let opam_name = unikernel_name target name in
let target_debug = Key.(get ctx target_debug) in
if target_debug && target <> `Ukvm then
Log.warn (fun m -> m "-g not supported for target: %a" Key.pp_target target);
configure_myocamlbuild () >>= fun () ->
configure_opam ~name:opam_name i >>= fun () ->
configure_makefile ~opam_name >>= fun () ->
Expand Down Expand Up @@ -1797,7 +1800,7 @@ let ldflags pkg = pkg_config pkg ["--variable=ldflags"]

let ldpostflags pkg = pkg_config pkg ["--variable=ldpostflags"]

let link info name target =
let link info name target target_debug =
let libs = Info.libraries info in
match target with
| `Unix | `MacOSX ->
Expand Down Expand Up @@ -1861,7 +1864,7 @@ let link info name target =
| "mirage-net-solo5" -> "net" :: acc
| "mirage-block-solo5" -> "blk" :: acc
| _ -> acc)
[] libs
[] libs @ (if target_debug then ["gdb"] else [])
in
pkg_config "solo5-kernel-ukvm" ["--variable=libdir"] >>= function
| [ libdir ] ->
Expand All @@ -1878,9 +1881,10 @@ let build i =
let warn_error = Key.(get ctx warn_error) in
let target = Key.(get ctx target) in
let libs = Info.libraries i in
let target_debug = Key.(get ctx target_debug) in
check_entropy libs >>= fun () ->
compile libs warn_error target >>= fun () ->
link i name target >>| fun out ->
link i name target target_debug >>| fun out ->
Log.info (fun m -> m "Build succeeded: %s" out)

let clean i =
Expand Down Expand Up @@ -1927,6 +1931,7 @@ module Project = struct
method keys = [
Key.(abstract target);
Key.(abstract warn_error);
Key.(abstract target_debug);
]
method packages =
let common = [
Expand Down
7 changes: 7 additions & 0 deletions lib/mirage_key.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ let warn_error =
let key = Arg.(opt ~stage:`Configure bool false doc) in
Key.create "warn_error" key

let target_debug =
let doc = "Enables target-specific support for debugging. Supported \
targets: ukvm (compiles ukvm-bin with GDB server support)." in
let doc = Arg.info ~docs:mirage_section ~docv:"DEBUG" ~doc ["g"] in
let key = Arg.flag ~stage:`Configure doc in
Key.create "target_debug" key

(** {3 Tracing} *)

let tracing_size default =
Expand Down
3 changes: 3 additions & 0 deletions lib/mirage_key.mli
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ val warn_error: bool key
(** [--warn-error]. Enable {i -warn-error} for OCaml sources. Set to [false] by
default, but might might enabled by default in later releases. *)

val target_debug: bool key
(** Enables target-specific support for debugging. *)

val tracing_size: int -> int key
(** [--tracing-size]: Key setting the tracing ring buffer size. *)

Expand Down