Skip to content

Commit

Permalink
ocamlc -custom: add extern modifiers when using a C++ compiler (#12791)
Browse files Browse the repository at this point in the history
Fixes: #12790

Co-authored-by: Shayne Fletcher <shaynefletcher@meta.com>
  • Loading branch information
shayne-fletcher and Shayne Fletcher committed Dec 3, 2023
1 parent 039af06 commit 16969c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ Working version

### Bug fixes:

- # 12791: `extern` is applied to definitions of `caml_builtin_cprim`
and `caml_names_of_builtin_cprim` when linking bytecode '-custom'
executables with a C++ linker
(Shayne Fletcher, review by Antonin Décimo and Xavier Leroy)

- #12712, #12742: fix an assertion boundary case in `caml_reset_young_limit`
(Jan Midtgaard, review by Guillaume Munch-Maccagnoni and KC Sivaramakrishnan)

Expand Down
6 changes: 6 additions & 0 deletions bytecomp/symtable.ml
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,17 @@ let output_primitive_table outchan =
fprintf outchan "extern value %s(void);\n" prim.(i)
done;
fprintf outchan "typedef value (*c_primitive)(void);\n";
fprintf outchan "#if defined __cplusplus\n";
fprintf outchan "extern\n";
fprintf outchan "#endif\n";
fprintf outchan "const c_primitive caml_builtin_cprim[] = {\n";
for i = 0 to Array.length prim - 1 do
fprintf outchan " %s,\n" prim.(i)
done;
fprintf outchan " 0 };\n";
fprintf outchan "#if defined __cplusplus\n";
fprintf outchan "extern\n";
fprintf outchan "#endif\n";
fprintf outchan "const char * const caml_names_of_builtin_cprim[] = {\n";
for i = 0 to Array.length prim - 1 do
fprintf outchan " \"%s\",\n" prim.(i)
Expand Down

0 comments on commit 16969c2

Please sign in to comment.