[sledge] Add dbg-opt build mode

Summary:
This adds an optimized debug build mode, which is compiled with
optimizations, and without assertions, but still has tracing enabled.

Reviewed By: kren1

Differential Revision: D16069452

fbshipit-source-id: 445cfa329
master
Josh Berdine 5 years ago committed by Facebook Github Bot
parent ddc1a028c4
commit d42908a5ff

@ -8,10 +8,11 @@ default: exes
EXES = src/sledge EXES = src/sledge
INSTALLS = sledge INSTALLS = sledge
FMTS = @_build/dev/src/fmt FMTS = @_build/dbg/src/fmt
DBG_TARGETS = $(patsubst %,_build/dev/%.exe,$(EXES)) $(patsubst %,_build/dev/%.install,$(INSTALLS)) _build/dev/sledge-help.txt DBG_TARGETS = $(patsubst %,_build/dbg/%.exe,$(EXES)) $(patsubst %,_build/dbg/%.install,$(INSTALLS)) _build/dbg/sledge-help.txt
OPT_TARGETS = $(patsubst %,_build/release/%.exe,$(EXES)) $(patsubst %,_build/release/%.install,$(INSTALLS)) _build/release/sledge-help.txt OPT_TARGETS = $(patsubst %,_build/opt/%.exe,$(EXES)) $(patsubst %,_build/opt/%.install,$(INSTALLS)) _build/opt/sledge-help.txt
DBG_OPT_TARGETS = $(patsubst %,_build/dbg-opt/%.exe,$(EXES)) $(patsubst %,_build/dbg-opt/%.install,$(INSTALLS)) _build/dbg-opt/sledge-help.txt
DUNEINS = $(shell find src model -name dune.in) DUNEINS = $(shell find src model -name dune.in)
DUNES = $(patsubst %.in,%,$(DUNEINS)) DUNES = $(patsubst %.in,%,$(DUNEINS))
@ -31,27 +32,31 @@ check: setup
.PHONY: exes .PHONY: exes
exes: setup exes: setup
dune build $(DBG_TARGETS) $(OPT_TARGETS) dune build $(DBG_TARGETS) $(DBG_OPT_TARGETS) $(OPT_TARGETS)
.PHONY: dbg .PHONY: dbg
dbg: setup dbg: setup
dune build $(DBG_TARGETS) dune build $(DBG_TARGETS)
.PHONY: do
do: setup
dune build $(DBG_OPT_TARGETS)
.PHONY: opt .PHONY: opt
opt: setup opt: setup
dune build $(OPT_TARGETS) dune build $(OPT_TARGETS)
.PHONY: watch .PHONY: watch
watch: setup watch: setup
dune build --watch $(DBG_TARGETS) $(OPT_TARGETS) dune build --watch $(DBG_TARGETS) $(DBG_OPT_TARGETS) $(OPT_TARGETS)
.PHONY: test .PHONY: test
test: setup test: setup
dune build @_build/dev/runtest --auto-promote dune build @_build/dbg/runtest --auto-promote
.PHONY: ci-test .PHONY: ci-test
ci-test: setup ci-test: setup
dune build @_build/dev/runtest dune build @_build/dbg/runtest
BISECT_DIR = $(CURDIR)/_coverage/out BISECT_DIR = $(CURDIR)/_coverage/out

@ -1 +1 @@
../_build/install/release/bin/sledge ../_build/install/opt/bin/sledge

@ -1 +1 @@
../_build/install/dev/bin/sledge ../_build/install/dbg/bin/sledge

@ -14,19 +14,21 @@ let common_flags =
let ocamlc_flags = let ocamlc_flags =
match Jbuild_plugin.V1.context with match Jbuild_plugin.V1.context with
| "release" -> "-w -26-32 -noassert" | "opt" | "dbg-opt" -> "-w -26-32 -noassert"
| _ -> "-g" | _ -> "-g"
let ocamlopt_flags = let ocamlopt_flags =
match Jbuild_plugin.V1.context with match Jbuild_plugin.V1.context with
| "release" -> ocamlc_flags ^ " -w -a -O3" | "opt" | "dbg-opt" -> ocamlc_flags ^ " -w -a -O3"
| _ -> ocamlc_flags | _ -> ocamlc_flags
let coverage_ppx = let coverage_ppx =
match Jbuild_plugin.V1.context with "coverage" -> "bisect_ppx" | _ -> "" match Jbuild_plugin.V1.context with "coverage" -> "bisect_ppx" | _ -> ""
let ppx_flags = let ppx_flags =
match Jbuild_plugin.V1.context with "dev" -> "--debug" | _ -> "" match Jbuild_plugin.V1.context with
| "dbg" | "dbg-opt" -> "--debug"
| _ -> ""
let flags exe_or_lib deps = let flags exe_or_lib deps =
Printf.sprintf Printf.sprintf

@ -1,5 +1,6 @@
(lang dune 1.0) (lang dune 1.0)
(context (opam (switch sledge) (name dev) (merlin))) (context (opam (switch sledge) (name dbg) (merlin)))
(context (opam (switch sledge) (name dbg-opt)))
(context (opam (switch sledge) (name opt)))
(context (opam (switch sledge) (name coverage))) (context (opam (switch sledge) (name coverage)))
(context (opam (switch sledge) (name release)))

@ -7,7 +7,7 @@ dev-repo: "git://github.com/facebook/infer.git"
license: "MIT" license: "MIT"
build: [ build: [
[make "setup"] [make "setup"]
["dune" "build" "-p" name "-j" jobs] ["dune" "build" "-p" name "--profile" "opt" "-j" jobs]
] ]
depends: [ depends: [
"ocaml" "ocaml"

@ -108,18 +108,20 @@ module Invariant = struct
include Base.Invariant include Base.Invariant
let invariant here t sexp_of_t f = let invariant here t sexp_of_t f =
try f () assert (
with exn -> ( try f ()
let bt = Caml.Printexc.get_raw_backtrace () in with exn ->
let exn = let bt = Caml.Printexc.get_raw_backtrace () in
Error.to_exn let exn =
(Error.create_s Error.to_exn
(Base.Sexp.message "invariant failed" (Error.create_s
[ ("", Source_code_position.sexp_of_t here) (Base.Sexp.message "invariant failed"
; ("exn", sexp_of_exn exn) [ ("", Source_code_position.sexp_of_t here)
; ("", sexp_of_t t) ])) ; ("exn", sexp_of_exn exn)
in ; ("", sexp_of_t t) ]))
Caml.Printexc.raise_with_backtrace exn bt in
Caml.Printexc.raise_with_backtrace exn bt ) ;
true )
end end
let map_preserving_phys_equal map t ~f = let map_preserving_phys_equal map t ~f =

Loading…
Cancel
Save