Skip to content

Commit 3db5be6

Browse files
committed
Human-readable stack trace in case of cycle
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
1 parent f3cd6e8 commit 3db5be6

File tree

3 files changed

+10
-40
lines changed

3 files changed

+10
-40
lines changed

src/dune_rules/ml_sources.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@ let make
469469
~include_subdirs:(loc_include_subdirs, (include_subdirs : Dune_file.Include_subdirs.t))
470470
~dirs
471471
=
472+
Memo.push_stack_frame ~human_readable_description:(fun () ->
473+
Pp.textf "Finding source files in directory %s" (Path.Build.to_string dir))
474+
@@ fun () ->
472475
let+ modules_of_stanzas =
473476
let modules =
474477
let dialects = Dune_project.dialects project in

src/dune_rules/modules_field_evaluator.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ let eval
404404
(settings : Stanza_common.Modules_settings.t)
405405
=
406406
let open Memo.O in
407+
Memo.push_stack_frame ~human_readable_description:(fun () ->
408+
Pp.textf "Evaluating modules field in directory %s" (Path.Build.to_string src_dir))
409+
@@ fun () ->
407410
let* modules0 =
408411
eval0 ~expander ~loc:stanza_loc ~all_modules ~standard:all_modules settings.modules
409412
in

test/blackbox-tests/test-cases/modules-expansion.t

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -134,44 +134,8 @@ appears. We need to handle this cycle gracefully and report it to the user.
134134
> EOF
135135

136136
$ dune exec ./mod.exe
137-
Internal error, please report upstream including the contents of _build/log.
138-
Description:
139-
("internal dependency cycle",
140-
{ frames =
141-
[ ("build-file", In_build_dir "default/lst")
142-
; ("<unnamed>", ())
143-
; ("<unnamed>", ())
144-
; ("load-dir", In_build_dir "default")
145-
]
146-
})
147-
Raised at Memo.Exec.exec_dep_node.(fun) in file "src/memo/memo.ml", line
148-
1289, characters 29-62
149-
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
150-
line 76, characters 8-11
151-
Re-raised at Stdune__Exn.raise_with_backtrace in file
152-
"otherlibs/stdune/src/exn.ml", line 38, characters 27-56
153-
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
154-
line 76, characters 8-11
155-
Re-raised at Stdune__Exn.raise_with_backtrace in file
156-
"otherlibs/stdune/src/exn.ml", line 38, characters 27-56
157-
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
158-
line 76, characters 8-11
159-
Re-raised at Stdune__Exn.raise_with_backtrace in file
160-
"otherlibs/stdune/src/exn.ml", line 38, characters 27-56
161-
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
162-
line 76, characters 8-11
163-
Re-raised at Stdune__Exn.raise_with_backtrace in file
164-
"otherlibs/stdune/src/exn.ml", line 38, characters 27-56
165-
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
166-
line 76, characters 8-11
167-
Re-raised at Stdune__Exn.raise_with_backtrace in file
168-
"otherlibs/stdune/src/exn.ml", line 38, characters 27-56
169-
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
170-
line 76, characters 8-11
171-
172-
I must not crash. Uncertainty is the mind-killer. Exceptions are the
173-
little-death that brings total obliteration. I will fully express my cases.
174-
Execution will pass over me and through me. And when it has gone past, I
175-
will unwind the stack along its path. Where the cases are handled there will
176-
be nothing. Only I will remain.
137+
Error: Dependency cycle between:
138+
Finding source files in directory _build/default
139+
-> Evaluating modules field in directory _build/default
140+
-> Finding source files in directory _build/default
177141
[1]

0 commit comments

Comments
 (0)