Skip to content

Commit 0fdd5d3

Browse files
committed
Fix for issue 1215
1 parent 055a023 commit 0fdd5d3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/sail_c_backend/c_backend.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,15 +2364,16 @@ module Codegen (Config : CODEGEN_CONFIG) = struct
23642364

23652365
let header_doc_opt, docs = List.map (codegen_def ctx) cdefs |> List.concat |> merge_file_docs in
23662366

2367-
let coverage_include, coverage_hook =
2367+
let coverage_include, coverage_hook_header, coverage_hook =
23682368
let header = string "#include \"sail_coverage.h\"" in
23692369
(* Generate a hook for the RTS to call if we have coverage
23702370
enabled, so it can set the output file with an option. *)
2371+
let coverage_hook_header = string "extern void (*sail_rts_set_coverage_file)(const char *);" in
23712372
let coverage_hook = string "void (*sail_rts_set_coverage_file)(const char *) = &sail_set_coverage_file;" in
23722373
let no_coverage_hook = string "void (*sail_rts_set_coverage_file)(const char *) = NULL;" in
23732374
match Config.branch_coverage with
2374-
| Some _ -> if Config.no_rts then ([header], []) else ([header], [coverage_hook])
2375-
| None -> if Config.no_rts then ([], []) else ([], [no_coverage_hook])
2375+
| Some _ -> if Config.no_rts then ([header], [], []) else ([header], [coverage_hook_header], [coverage_hook])
2376+
| None -> if Config.no_rts then ([], [], []) else ([], [coverage_hook_header], [no_coverage_hook])
23762377
in
23772378

23782379
let preamble in_header =
@@ -2384,7 +2385,7 @@ module Codegen (Config : CODEGEN_CONFIG) = struct
23842385
else List.map (fun h -> string (Printf.sprintf "#include \"%s\"" h)) Config.includes
23852386
)
23862387
@ [string "#ifdef __cplusplus"; string "extern \"C\" {"; string "#endif"]
2387-
@ if in_header = Config.generate_header then coverage_hook else []
2388+
@ if in_header then coverage_hook_header else coverage_hook
23882389
)
23892390
in
23902391

0 commit comments

Comments
 (0)