Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3035408

Browse files
committedApr 10, 2011
build: add profiling build option to add -pg/-p to ocaml and c builds
·
1 parent 90451e2 commit 3035408

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
 

‎lib/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
.PHONY: all unix clean
22

33
JOBS ?= -j 4
4+
OFLAGS ?= -classic-display
45

56
all: unix-direct unix-socket
67

78
unix-direct:
89
@mkdir -p _build
9-
@env MIRAGEOS=unix MIRAGEFLOW=direct ocamlbuild $(JOBS) unix.otarget
10+
@env MIRAGEOS=unix MIRAGEFLOW=direct ocamlbuild $(OFLAGS) $(JOBS) unix.otarget
1011

1112
unix-socket:
1213
@mkdir -p _build
13-
@env MIRAGEOS=unix MIRAGEFLOW=socket ocamlbuild $(JOBS) unix.otarget
14+
@env MIRAGEOS=unix MIRAGEFLOW=socket ocamlbuild $(OFLAGS) $(JOBS) unix.otarget
1415

1516
xen-direct:
1617
@mkdir -p _build

‎lib/myocamlbuild.ml

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ let ps = Printf.sprintf
88
let ep = Printf.eprintf
99

1010
let debug = false
11+
let profiling = false
1112

1213
(* This decides the global OS backend. It could be moved into explicit
1314
dependencies in the future, but for now is set as an environment
@@ -230,6 +231,8 @@ let _ = dispatch begin function
230231
(* do not compile and pack with the standard lib *)
231232
flag ["ocaml"; "compile"; "mirage" ] & S [A"-nostdlib"];
232233
flag ["ocaml"; "pack"; "mirage"] & S [A"-nostdlib"];
234+
if profiling then
235+
flag ["ocaml"; "compile"; "native" ] & S [A"-p"];
233236

234237
(* use pa_`lib` syntax extension if the _tags file specifies it *)
235238
let p4_build = "../../../syntax/_build" in
@@ -264,6 +267,8 @@ let _ = dispatch begin function
264267
(* base cflags for C code *)
265268
flag ["c"; "compile"] & S CC.cc_cflags;
266269
flag ["asm"; "compile"] & S [A "-D__ASSEMBLY__"];
270+
if profiling then
271+
flag ["c"; "compile"] & S [A"-pg"];
267272

268273
(* xen code needs special cflags *)
269274
flag ["c"; "compile"; "include_xen"] & S CC.xen_incs;

0 commit comments

Comments
 (0)
Please sign in to comment.