summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Richardson2020-05-15 09:43:12 +0100
committerAlex Richardson2020-05-15 13:44:00 +0100
commitdc5a39649116c7fd76a024d069707f8b3aa7e201 (patch)
treec7a73d73e6370e5d42b2daadd09b67177fa76714 /src
parent363cf77a75cb8237fb13b028c0046b7817dbe734 (diff)
Also make the letbinding C variables static
I was getting run-time failures when code generate from cheri128 and cheri64 in the same process. This was caused because my compiler defaults to -fcommon so it merged multiple variables (with conflicting types!). When initializing the second set of letbindings, the first one was overwritten (first variable was lbits, the other was uint64_t). Compiling with -fno-common exposes this problem.
Diffstat (limited to 'src')
-rw-r--r--src/jib/c_backend.ml3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/jib/c_backend.ml b/src/jib/c_backend.ml
index e6610e93..080be248 100644
--- a/src/jib/c_backend.ml
+++ b/src/jib/c_backend.ml
@@ -2127,7 +2127,8 @@ let codegen_def' ctx = function
let cleanup =
List.concat (List.map (fun (id, ctyp) -> [iclear ctyp (name id)]) bindings)
in
- separate_map hardline (fun (id, ctyp) -> string (Printf.sprintf "%s %s;" (sgen_ctyp ctyp) (sgen_id id))) bindings
+ let static = if !opt_static then "static " else "" in
+ separate_map hardline (fun (id, ctyp) -> string (Printf.sprintf "%s%s %s;" static (sgen_ctyp ctyp) (sgen_id id))) bindings
^^ hardline ^^ string (Printf.sprintf "static void create_letbind_%d(void) " number)
^^ string "{"
^^ jump 0 2 (separate_map hardline codegen_alloc setup) ^^ hardline