Permalink
Browse files

ocamlbuild: only show backtrace in verbose mode

Building foo.cmo in an empty directory (so with in particular no
foo.ml) currently returns the following output:

> Solver failed:
>   Ocamlbuild cannot find or build foo.ml.  A file with such a name
>   would usually be a source file.  I suspect you have given a wrong
>   target name to Ocamlbuild.
> Backtrace:
>   - Failed to build the target foo.cmo
>       - Building foo.cmo:
>           - Failed to build all of these:
>               - Building foo.ml:
>                   - Failed to build all of these:
>                       - Building foo.mly
>                       - Building foo.mll
>               - Building foo.mli:
>                   - Building foo.mly
>               - Building foo.mlpack
>               - Building foo.mli:
>                   - Building foo.mly
> Compilation unsuccessful after building 0 targets (0 cached) in 00:00:00.

While the "Solver failed" part is nice and reasonably easy to
understand, users report that the "Backtrace" part is confusing
(it talks about files they don't know about) -- and it can be so large
that the explanation above is completely hidden.

This patch disables backtrace-printing by default; it is now only
shown when some "-verbose N" (N starting at 1) argument is passed.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14732 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
gasche committed May 3, 2014
1 parent b691a28 commit 5ca901cfa6c78365cf829d1c6b4e9efa75a0781b
Showing with 4 additions and 2 deletions.
  1. +4 −2 ocamlbuild/main.ml
View
@@ -282,8 +282,10 @@ let main () =
Log.finish ~how:`Quiet ();
Pervasives.exit rc
| Solver.Failed backtrace ->
- Log.raw_dprintf (-1) "@[<v0>@[<2>Solver failed:@ %a@]@\n@[<v2>Backtrace:%a@]@]@."
- Report.print_backtrace_analyze backtrace Report.print_backtrace backtrace;
+ Log.raw_dprintf (-1) "@[<v0>@[<2>Solver failed:@ %a@]@."
+ Report.print_backtrace_analyze backtrace;
+ Log.raw_dprintf 1 "@[<v2>Backtrace:%a@]@]@."
+ Report.print_backtrace backtrace;
exit rc_solver_failed
| Failure s ->
Log.eprintf "Failure:@ %s." s;

0 comments on commit 5ca901c

Please sign in to comment.