Skip to content

Duplicate definitions in generated C #203

@rmn30

Description

@rmn30

When attempting to compile the current version of this PR: riscv/sail-riscv#197 I get an error when compiling the C file generated by Sail:

make csim
gcc -g  -I /mnt/rust/.opam/4.14.0/share/sail/lib -I c_emulator   -I c_emulator/SoftFloat-3e/source/include -fcommon -O3 -flto generated_definitions/c/riscv_model_RV64.c c_emulator/riscv_prelude.c c_emulator/riscv_platform_impl.c c_emulator/riscv_platform.c c_emulator/riscv_softfloat.c c_emulator/riscv_sim.c /mnt/rust/.opam/4.14.0/share/sail/lib/*.c -lgmp -lz c_emulator/SoftFloat-3e/build/Linux-RISCV-GCC/softfloat.a -o c_emulator/riscv_sim_RV64
generated_definitions/c/riscv_model_RV64.c:64842:6: error: redefinition of ‘zinternal_errorzIUMemoryOpResultzIozKzK’
 void zinternal_errorzIUMemoryOpResultzIozKzK(struct zMemoryOpResultzIozK *zcbz355, sail_string zfile, sail_int zline, sail_string zs)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generated_definitions/c/riscv_model_RV64.c:64623:6: note: previous definition of ‘zinternal_errorzIUMemoryOpResultzIozKzK’ was here
 void zinternal_errorzIUMemoryOpResultzIozKzK(struct zMemoryOpResultzIozK *zcbz350, sail_string zfile, sail_int zline, sail_string zs)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generated_definitions/c/riscv_model_RV64.c:64885:15: error: redefinition of ‘zinternal_errorzIERetiredz5zK’
 enum zRetired zinternal_errorzIERetiredz5zK(sail_string zfile, sail_int zline, sail_string zs)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generated_definitions/c/riscv_model_RV64.c:64710:15: note: previous definition of ‘zinternal_errorzIERetiredz5zK’ was here
 enum zRetired zinternal_errorzIERetiredz5zK(sail_string zfile, sail_int zline, sail_string zs)

I've not been able to reproduce in a smaller example yet. I suspect it is something to do with the interesting type of internal_error:

val internal_error : forall ('a : Type). (string, int, string) -> 'a effect {escape}
function internal_error(file, line, s) = {
    assert (false, file ^ ":" ^ string_of_int(line) ^ ": " ^ s);
    throw Error_internal_error()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions