[cocci] Build configuration for OPAM support?

Markus Elfring <[email protected]> Thu, 23 Apr 2026 16:52:02 +0200
Newsgroups fr.inria.cocci
Message-ID <[email protected]>
Hello,

I occasionally prefer to reuse OCaml components by OPAM interfaces.

Program parameters need to be adjusted accordingly.


diff --git a/ocaml/yes_prepare_ocamlcocci.ml b/ocaml/yes_prepare_ocamlcocci.ml
index 1680856e4..da36af522 100644
--- a/ocaml/yes_prepare_ocamlcocci.ml
+++ b/ocaml/yes_prepare_ocamlcocci.ml
@@ -582,8 +582,9 @@ let load_file mlfile =
   let (ldlibs, inc) = dep_flag cmifile mlfile in
   (* add ocaml and ocaml/coccilib as search directories for the ocaml scripting *)
   let flags =
-    Printf.sprintf "-g -I %s %s -I %s -for-pack Coccinelle_modules"
-      (Filename.dirname cmifile) inc (sysdir ()) in
+    Printf.sprintf
+      "-g -I %s %s -I \"$(opam exec -- ocamlc.opt -where)\" -for-pack Coccinelle_modules"
+      (Filename.dirname cmifile) inc in
   let (obj, cmd) =
     if Cocciconfig.dynlink_is_native
     then compile_native_cmd flags mlfile



Can further users of the Coccinelle software benefit from such a code refinement?
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/03a1af0a3316ddfc2b54d827b8b9627a841c85c9/cocci.ml#L1586-1590

Regards,
Markus