Skip to content

Commit

Permalink
Fix -flto and RTS coverage detection
Browse files Browse the repository at this point in the history
Suppress a spurious clang warning
  • Loading branch information
Alasdair committed Apr 26, 2024
1 parent 6534384 commit e03293d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/rts.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
extern "C" {
#endif

extern void sail_rts_set_coverage_file(char *output_file);
extern void (*sail_rts_set_coverage_file)(const char *);

static uint64_t g_elf_entry;
uint64_t g_cycle_count = 0;
Expand Down Expand Up @@ -725,7 +725,7 @@ int process_arguments(int argc, char *argv[])
break;

case 'c':
if (&sail_rts_set_coverage_file) {
if (sail_rts_set_coverage_file != NULL) {
sail_rts_set_coverage_file(optarg);
} else {
fprintf(stderr, "Ignoring flag -c %s. Requires the model to be compiled with coverage\n", optarg);
Expand Down
6 changes: 2 additions & 4 deletions src/sail_c_backend/c_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2009,10 +2009,8 @@ let compile_ast env effect_info output_chan c_includes ast =
let header = string "#include \"sail_coverage.h\"" in
(* Generate a hook for the RTS to call if we have coverage
enabled, so it can set the output file with an option. *)
let coverage_hook =
string "void sail_rts_set_coverage_file(char *output_file) { sail_set_coverage_file(output_file); }"
in
let no_coverage_hook = string "void (*sail_rts_set_coverage_file)(char *) = NULL;" in
let coverage_hook = string "void (*sail_rts_set_coverage_file)(const char *) = &sail_set_coverage_file;" in
let no_coverage_hook = string "void (*sail_rts_set_coverage_file)(const char *) = NULL;" in
match !opt_branch_coverage with
| Some _ -> if !opt_no_rts then [header] else [header; coverage_hook]
| None -> if !opt_no_rts then [] else [no_coverage_hook]
Expand Down
2 changes: 1 addition & 1 deletion test/sailcov/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_sailcov():
step('./{}.bin -c {}.taken'.format(basename, basename))
step('{} --all {}.branches --taken {}.taken {}'.format(sailcov, basename, basename, filename))
step('diff {}.html {}.expect'.format(basename, basename))
step('rm {}.taken {}.bin'.format(basename, basename))
step('rm {}.taken {}.bin {}.branches'.format(basename, basename, basename))
print_ok(filename)
sys.exit()
results.collect(tests)
Expand Down

0 comments on commit e03293d

Please sign in to comment.